ArchitecturePart 6 of 8

Version-Checked Writes and Proposals: Optimistic Concurrency for AI Agents

Agents read state, think for seconds, then write. That window is where updates get lost. How version-checked writes and owner proposals stop agents from overwriting each other.

DNotifier Team••6 min read
Back to blog
Version-Checked Writes and Proposals: Optimistic Concurrency for AI Agents

Part 5 gave every state key an owner and a write rule. That removes most conflicts. It doesn't remove the most common one in agent systems: two agents reading the same value, both deciding to change it, and the second write erasing the first.

Database people call this the lost update problem. It's an old problem. What's new is how wide the window is.

The window is seconds, not microseconds

In a normal service, the time between reading a row and writing it back is a few milliseconds. Collisions happen, but rarely.

An agent works differently. It reads the plan, sends it to a model with a pile of context, waits six or nine seconds for a response, maybe calls a tool, and then writes. For that whole stretch it's acting on a snapshot that may already be out of date. Run three agents in parallel on the same task and the chance of two of them writing over each other stops being an edge case. It's Tuesday.

Locks don't help much, for the reasons in part 5: you'd be holding them for the length of an LLM call. What does help is checking at write time.

Version-checked writes

The idea is simple, and it's the same one HTTP uses with If-Match headers and databases use with compare-and-set:

  1. Every key has a version number that goes up on each write.
  2. When an agent reads a key, it gets the value and the version.
  3. When it writes, it says which version it read.
  4. If the key is still at that version, the write succeeds and the version goes up.
  5. If someone wrote in between, the write is refused, and the server returns the current value along with the conflict.

No locks. Nobody waits while anyone thinks. The cost is only paid when there's an actual collision.

Version-checked writes between two agents
Version-checked writes between two agents

Why return the current value

Returning the fresh value with the conflict, rather than a bare "409, try again", does two useful things.

It saves a round trip, which matters when every agent step is already slow.

More importantly, it forces the agent to look at what changed. The worst thing an agent can do with a conflict is retry the same write with the new version number stuck on. That's last-write-wins with extra steps. The right move is to put the current value back in front of the model ("since you read this, the plan changed to X; does your change still make sense?") and let it decide again.

What an agent should do with a conflict

We give agents three options, in this order of preference:

  • Merge. If the other agent's change and yours don't overlap (they added a step, you reordered two others), combine them and write with the new version.
  • Reconsider. If they do overlap, re-run the reasoning on the fresh value. Often the agent concludes its change is no longer needed.
  • Give up, visibly. After a small number of attempts (two or three), stop and record that this agent couldn't apply its change. A silent infinite retry loop between two agents is a real failure mode, and it burns tokens.

Every conflict is a trace event. When you see the same key conflicting on every run, that's usually a design smell: two agents doing overlapping jobs, or a key that should have been append instead of a single value.

Proposals: when it isn't your key

Version checks handle races between agents that are allowed to write. Proposals handle agents that aren't.

With the owner_approves rule from part 5, only the owner can write a key directly. When another agent tries, its write doesn't fail and it doesn't go through. It becomes a proposal:

  • the proposed value,
  • who proposed it and why,
  • the version it was based on.

The owner agent then accepts or rejects it, or a rule decides automatically ("accept proposals from the fraud agent that set hold: true, because being cautious is always allowed").

In the refund example from part 1, this is exactly what you want. The fraud agent can't override the refund decision. It can say, on the record, "I propose deny, because of three chargebacks", and the refund agent has to deal with that before it pays.

Owners that don't answer

Proposals need a timeout policy, or a stuck owner blocks the run forever. Three sensible defaults:

Timeout policyUse when
RejectThe owner's current value is the safe one. Most decisions involving money or sending.
AcceptThe proposal is the safe direction, like a hold or a flag.
EscalateNeither side is safe to assume. Send it to a judge, a vote or a person (part 7).

Pick per key, not per system. "Reject on timeout" is right for refund.decision and wrong for account.freeze.

How DNotifier handles it

Version-checked writes. Every key in shared state has a version. A write includes the version it read, and if someone wrote in between, the server returns a conflict with the current value instead of overwriting. Two simultaneous writes: one succeeds, the other gets the fresh value back.

Proposals. A non-owner's write to an owner_approves key becomes a proposal. The owner agent accepts or rejects it, or a rule decides, and a timeout policy (reject, accept or escalate) handles owners that don't answer.

All of it in Traces. Conflicts, retries, proposals and their outcomes are recorded next to the run, so a key that conflicts on every run is easy to spot.

Together with the per-key rules from part 5, this is what lets us say: shared context with ownership and version checks, where no agent silently overwrites another.

A checklist for your own system

  • Can two agents write the same key in one run? Which one wins today, and is anything recorded?
  • Do your writes carry the version they were based on?
  • When a write conflicts, does the agent see the new value, or just an error?
  • Is there a retry limit?
  • For keys one agent owns, can others propose instead of overwrite?
  • Does every proposal have a timeout and a default?

FAQ

Isn't optimistic concurrency just a retry loop?

Only if you implement it as one. The point is to hand the fresh value back to the agent and let it reason again. A retry that ignores the new value defeats the purpose.

How many retries should an agent get?

Two or three. Past that, two agents are fighting over the same key every time, and the fix is in the design, not the retry count.

Do proposals slow everything down?

Only for keys marked owner_approves, which should be the few decisions that matter. Everything else uses append, sum or plain version-checked writes.

What's the difference between a proposal and an escalation?

A proposal goes to the owner. An escalation goes past the owner, to a judge, a vote or a human, when the owner and the proposer still disagree or the owner doesn't answer.

Trust in multi-agent systems

Part 6 of 8

  1. Part 1Multi-Agent Systems Need Shared Context, Not Just Message Passing
  2. Part 2Agent Identity: How an Agent Proves Who It Is
  3. Part 3Who Can Call Whom: Agent-to-Agent Authorization
  4. Part 4Requested vs Granted: Tool Permissions for AI Agents
  5. Part 5Conflict Resolution on Shared State: Owners and Write Rules for Every Key
  6. Part 6Version-Checked Writes and Proposals: Optimistic Concurrency for AI Agents
  7. Part 7Consensus for AI Agents: Validation, Judges, Votes and Humans
  8. Part 8Agent-to-Agent Prompt Injection and Earned Trust

Tags

#multi-agent-systems#agent-trust#optimistic concurrency ai agents#version checked writes#compare and set agents#agent proposals#lost update problem

Keep reading

Related articles

View all →