DEV Community

Merehead
Merehead

Posted on Edited on

A Correct Write Can Still Break Your CRM

In one 2026 CRM project, the AI's job fit in a sentence: read incoming emails, find the payment details, fill the payment fields on the deal. The integration was native to the CRM, so the model call itself was the easy part.

We tested it on 200 historical deals against manual entry, and anything that did not match went to an operator. Two weeks of the project went to something else: regression testing of the workflows the AI set off, and deduplication.

This post is about that part. It is the code and the checks around the model call, and they decide whether the thing is safe to switch on. The snippets below are sketches of the patterns, not our production code.

Reads are cheap. Writes are not.

An AI in a CRM either reads or writes. Reading means summarizing a thread or drafting a reply, and a bad result costs a person a minute. Writing means filling a field or moving a deal to the next stage, and a bad result sits in a record until it shows up in a report somebody trusts.

So we treat the two as different systems. Reads can ship early. Writes get a design.

Rule 1: a write is a proposal first

Don't let the model mutate anything. Let it produce a proposal that carries its own evidence, and let a separate piece of code decide what happens to it.

python
from dataclasses import dataclass

@dataclass(frozen=True)
class Proposal:
    record_id: str
    field: str
    value: str
    source_id: str       # e.g. the email message id
    source_kind: str     # "customer_email", "payment_confirmation", ...
    evidence: str        # the excerpt the value was taken from
    status: str = "pending"   # pending | accepted | rejected
Enter fullscreen mode Exit fullscreen mode

The evidence field earns its place on day one. A reviewer who sees the value next to the sentence it came from approves or rejects in seconds. A reviewer who sees only the value has to go and find the email.

From there, autonomy is a dial with four positions. The AI suggests and a person copies. It proposes a change that stays inactive until accepted. It writes and logs, and a reviewer samples the log. Or it writes and the write starts other workflows, which needs approval rules per action. Every field starts at the first position and moves up on its own evidence.

Rule 2: decide what each source can confirm

Picture a customer email that says "we'll pay on Friday". That is a fine reason to suggest a reminder task. It is no reason to flip the invoice to paid. The email confirms an intention, not a payment.

Write that down as data, not as a prompt instruction you hope the model respects:

python
# What each kind of evidence may do to each field.
POLICY = {
    "payment_status": {
        "payment_confirmation": "write",   # a bank notice or provider webhook
        "customer_email": "suggest",       # "we'll pay on Friday" lands here
    },
    "payment_due_date": {
        "customer_email": "propose",
    },
}

def allowed_action(field: str, source_kind: str) -> str:
    return POLICY.get(field, {}).get(source_kind, "suggest")
Enter fullscreen mode Exit fullscreen mode

Anything not listed falls back to the weakest action. The model can be wrong about what an email means. The policy table cannot be talked into anything.

Rule 3: make every write idempotent

Emails get reprocessed. Webhooks fire twice. A retry runs after a timeout that was not really a failure. If your write path is not idempotent, one of these will eventually create a duplicate or apply a value twice.

python
import hashlib

def write_key(record_id: str, field: str, source_id: str) -> str:
    raw = f"{record_id}:{field}:{source_id}"
    return hashlib.sha256(raw.encode()).hexdigest()

def apply(proposal, store, crm):
    key = write_key(proposal.record_id, proposal.field, proposal.source_id)
    if key in store.applied:
        return "skipped"
    crm.update(proposal.record_id, {proposal.field: proposal.value})
    store.applied.add(key)
    return "applied"
Enter fullscreen mode Exit fullscreen mode

The harder cousin of this is duplicate records. If a contact or a deal exists twice, both copies can receive AI-written values, and later nobody can say which one is true. Match before you create, and test that your matching holds when the same input comes in twice. Better to find that in a test than in a quarterly report.

Rule 4: map the blast radius

A field in a CRM is rarely just a field. Automations may start when its value changes. A report may filter on it. Somebody's weekly dashboard may be built on it. An integration you forgot about may subscribe to its change events.

When the AI writes a correct value into a field like that, the value is right and the consequence can be wrong. That is where our two weeks went: finding what a write sets in motion, then testing each of those paths before the AI was allowed to write.

Before any field becomes writable, list what depends on it. Check automations, report filters, webhooks and outbound integrations. If you cannot produce that list, the field stays at "suggest". We hold the same line on every project: if deduplication is unreliable, or you do not know which workflows a field change starts, hold off on autonomous writes and fix those first.

The replay harness

You cannot judge a write path by reading a few outputs and nodding. You need cases where the answer is already known, and historical records that people processed by hand are exactly that.

python
def replay(cases, run_ai, sandbox):
    results = []
    for case in cases:                       # historical, answer known
        first = run_ai(case.email, sandbox)
        second = run_ai(case.email, sandbox)  # the same input, twice
        results.append({
            "case": case.id,
            "match": first.fields == case.expected,
            "duplicate": sandbox.count(case.record_key) > 1,
            "triggered": sandbox.triggered_workflows(),  # however your CRM exposes it
        })
    return results
Enter fullscreen mode Exit fullscreen mode

Define "correct" before the first run. For a payment record it might mean that amount, date, counterparty and currency all match what the person entered. Mismatches go to an operator, and you read them. Patterns show up quickly: one field keeps coming out wrong, or one type of email confuses the model.

Run it against a copy of the CRM, and note that vendors differ a lot here, as of November 2026. HubSpot includes a sandbox with Enterprise editions, one per account (HubSpot). Salesforce's Developer sandbox holds no data, so testing on real deals needs Partial or Full Copy, which puts personal data into the sandbox (Salesforce). Pipedrive's developer sandbox is a separate account, not a copy of yours, so you export and import data yourself (Pipedrive). If your plan has nothing suitable, make a test account and load a small set of exported records with personal data removed or masked.

Scope the tools before you connect the model

If you give an assistant access through MCP, the model only ever gets the tools you expose, so start with read-only ones.

HubSpot's remote MCP server became generally available with a changelog date of April 13, 2026, and uses OAuth 2.1 with PKCE (HubSpot changelog). Salesforce documents hosted MCP servers with per-user OAuth and PKCE, but when we checked they were labeled beta and aimed at customers with Flex Credits, so confirm the status before you plan around them (Salesforce).

Read vendor claims about logging with a pen in hand. Pipedrive's press release says its MCP server follows user permissions and records actions in change logs (Pipedrive). It does not say how long the logs are kept or whether a change made by an AI is marked as such. Ask.

With middleware the approval step may be yours to build. On Zapier's MCP page (checked November 26, 2026), one tool call uses two tasks from your plan, and no approval step before an action runs is described (Zapier MCP).

Count the review time

An AI that fills a field in seconds has saved nothing if a person spends minutes checking it. Track the share of outputs accepted without edits, the time spent reviewing and correcting, and errors that reached a report or a customer. Compare them with a baseline you wrote down before the pilot. Without a baseline, the pilot only tells you that it felt faster.

Run the first pilot beside the manual process with one team. People still do the task, and the AI's result is compared with theirs, so you collect real corrections without real damage.

If you are weighing a use case like this

Merehead is an AI development company that has developed AI systems since 2023. When a team is not sure a CRM use case is ready, we review it before anything gets built. For $2,000 and 1 to 2 weeks, we look at one AI scenario in one CRM and hand over a dependency map, a test protocol, a scorecard and a pilot estimate, with a recommendation on whether to run it. You can contact our team to start.

The full non-code guide, with the data audit and cost drivers, is on our blog: https://merehead.com/blog/integrate-ai-into-your-crm/

Top comments (0)