skip to content

Why do multi-agent systems use single-writer discipline instead of locking concurrent writers?

level: middleimportance: must knowfreq 68%

answer

  1. one owner, everyone else proposes
  2. locks assume writers agents cannot be
  3. freeze the plan before anyone writes
  4. append findings, never overwrite
  5. enforce by tool allowlist, not by prompt

basics

~20 s

Locking assumes writers that wait, know their own blast radius, and roll back cleanly. LLM agents do none of that. Routing every write through one owner, while the others contribute proposals, removes the conflict rather than arbitrating it.

solid answer

~50 s

Single-writer discipline means that for any shared artifact exactly one agent may mutate it; the others read it and return **proposals** — diffs, findings, drafts — which the owner or orchestrator applies. Locks are the classical alternative, but they assume properties LLM agents lack: an agent rarely knows in advance which files it will touch, tends to rewrite a whole file rather than patch it, cannot be trusted to release a lock it is stalled behind, and if asked to resolve a conflict will invent a merge that satisfies neither intent. Two agents editing the same Terraform module can each emit valid HCL and jointly produce a plan that destroys and recreates resources neither intended. Two supports make it work: **phase gates** — nobody writes until the plan artifact is frozen — and **append-only** event or finding logs, so concurrent contributions accumulate instead of overwriting each other.

go deeper

for a junior

Know the rule and be able to state it plainly: in a multi-agent run, one agent owns writes to a shared artifact and the others suggest changes. Name the failure it prevents — two agents overwriting each other's work.

for a middle

Explain why locking does not transfer to agents: unknown write extent, whole-file rewrites that defeat merges, no reliable way to tell a stalled agent from a slow one. Describe phase gates and append-only artifacts as the supporting mechanics.

for a senior

Show how you would enforce it in a real system — ownership map, tool allowlists that remove the write tool from subagents, verification at the gate — and give a concrete corruption story, such as two agents jointly producing an infrastructure change neither intended.

for a principal

Own the tradeoff: serializing writes caps write throughput but the expensive work is reading and reasoning, which parallelizes. Be ready to argue when a partitioned parallel-writer design is justified, and to say what single-writer discipline still leaves unsolved.

## What single-writer discipline means In a multi-agent system several model-driven agents work on one task concurrently. Single-writer discipline is the rule that for any given shared artifact — a file, a plan document, a config module, a row in a task table — exactly one agent holds write authority. Every other agent may read the artifact and may produce *proposals*: a diff, a review finding, a draft section, a structured recommendation. Those proposals are applied by the owner, or by the orchestrator acting as owner. Nothing is applied by two hands at once. This is a coordination decision, not a storage decision. It says nothing about which database or filesystem you use; it says who is allowed to call the mutating tool. ## Why locking is the wrong reach Mutual exclusion works in conventional concurrent systems because writers satisfy four properties. First, a writer can declare the extent of what it will touch before touching it. Second, a blocked writer waits harmlessly. Third, conflicts are detectable mechanically — two writes to the same address, or a failed compare-and-swap. Fourth, a writer that dies mid-transaction rolls back. Agents violate all four. An agent exploring a repository does not know up front which files it will edit; the extent of its write set is discovered during execution, which is precisely when a lock would have to be acquired. A stalled agent — one looping, waiting on a slow tool, or dead — is externally indistinguishable from a thinking one, so a held lock is not obviously reclaimable. Agents frequently regenerate a whole file rather than emit a minimal patch, so a textual three-way merge sees the entire file as changed and cannot reconcile anything. And when you hand a conflict back to a model and say "resolve this", it will confidently produce a merged artifact that reads plausibly and preserves neither side's actual intent — a failure that is worse than a visible conflict marker, because it is silent. The Terraform case makes it concrete: two agents asked to modify the same module can each produce syntactically valid, individually reasonable HCL. Applied together, the result plans a destroy-and-recreate of resources neither agent was asked to touch, and the state file diverges from reality. No lock would have caught it, because at the level locks operate — bytes and files — there was no conflict. ## The two supports: phase gates and append-only **Phase gates** are barriers in the run. A common shape is: plan, freeze, fan out, merge, verify. No agent may write until the plan artifact is frozen and accepted. The gate does two jobs. It gives all workers one agreed referent so their parallel work aims at the same target, and it moves the moment of disagreement to a point where a single mind — the orchestrator, or a human — is looking at it, instead of spreading it across concurrent writes. **Append-only artifacts** handle the contributions that genuinely must arrive concurrently: findings, events, test results, notes. Appending never destroys information, so there is no lost update to reason about; last-write-wins on a mutable document always can. Reconciliation becomes a read-time or gate-time decision by the owner, who sees every contribution with its author attached. It also makes the run replayable and auditable, which matters when you are trying to work out why the fleet produced what it produced. ## What it costs The write path is serialized, so write throughput is bounded by one agent. In practice this is a cheap price: in agentic work the expensive part is reading, searching and reasoning, and that parallelizes perfectly. The industry converged on this by mid-2026 — the operative rule in surviving production designs is that writes stay single-threaded while the additional agents contribute intelligence rather than actions. Parallel-writer swarms are the design that consistently lost. ## Making it real rather than aspirational An instruction in a prompt is not enforcement. Enforce it at the capability layer: the subagents' tool allowlist simply does not contain the write tool, so a misaligned agent physically cannot mutate the artifact. Keep an explicit ownership map from artifact to owner. Have the orchestrator apply proposals and run whatever verification exists — tests, a plan/dry-run, a schema check — at the gate rather than after the fact. ## Where it does not apply, and what it does not fix If the work partitions cleanly — separate files, separate services, separate documents with no shared referent — parallel writers are fine, because there is no shared artifact to contend for. Single-writer discipline is about contention, not about parallelism in general. And it does not fix agents that disagree about what the task *means*. A perfectly serialized write path will happily record a wrong result if the proposals it merged were built on divergent readings of the goal. Single-writer discipline removes the mechanical class of conflict so the semantic class is the one you are left to design against.

  • If only one agent may write, what are the other agents actually producing?
    Proposals in a shape the owner can apply or reject: unified diffs, structured findings with file and line, draft sections, test results, or a recommendation with evidence. The value of extra agents is the reading and reasoning they do in their own isolated context — the owner keeps the merge decision, which is where conflicting intent would otherwise become silent corruption.
  • When is it safe to let several agents write in parallel?
    When ownership partitions cleanly: distinct files, distinct services, distinct documents with no shared referent and no cross-cutting invariant. Then there is no contention to arbitrate. Even so, one component should assemble and verify the whole at the end, because per-partition success does not imply the combination is coherent.
  • How do you enforce single-writer beyond telling agents in the prompt?
    Make it a capability, not an instruction. Subagents get a tool allowlist without the mutating tool, so writes are impossible rather than discouraged. The orchestrator, or a dedicated writer agent, holds the write tool and applies proposals. Prompt-level rules degrade under long contexts and adversarial input; a missing tool does not.

It is the difference between letting five people type into one document at once and having four of them leave tracked-change suggestions that one editor accepts.

saying these in an interview costs you the question

  • Suggesting file locks or mutexes so agents can write concurrently
  • Believing a model can merge two conflicting edits correctly
  • Treating a prompt instruction as enforcement of write ownership
  • Assuming parallel writers are always faster than one serialized writer
  • Confusing append-only logging with letting everyone mutate shared state

context