Three Agents, One Repo: The Coordination Problem Nobody Designed For
One coding agent is a productivity tool. Two agents in the same repository is a sociology experiment. Three is a coordination problem that most teams solve for the first time in production, on a Friday.
The infrastructure conversation covers fleet orchestration and control planes. It skips the boring, decisive question: what happens when two agents touch the same file at the same time, and who resolves what they did to each other?
The Three Collisions
The mechanical collision is the friendly one. Two agents edit the same lines, git refuses to merge, and the failure is loud. Everyone notices. This is the good case, because the system said no.
The semantic collision is the dangerous one. Agent A changes the meaning of a function's return value. Agent B, working from the old contract, builds a feature that reads it. The merge is clean. The tests each wrote still pass in isolation. The system now believes two incompatible things, and nothing failed anywhere.
The duplicate collision is the expensive one. Two agents, given overlapping tickets, build the same feature twice with different names. Both PRs look competent. One of them is pure waste, and until someone notices, both are load.
None of these are exotic. They are the exact failure modes human teams have, at a speed that breaks the human mechanisms we built to catch them.
The Human Mechanism We Forgot to Port
Human teams coordinate through standups, hallway conversations, and ownership maps. "I'm touching the auth module, don't start there." It is informal, inefficient, and it works.
Agents attend no standup. They hold no grudges, share no memory, and read no hallway. The coordination layer has to become explicit, which means it has to become infrastructure:
A claim queue. Work is assigned or claimed, and a claim is visible. No two agents start the same ticket because the ticket said who started it. This is a work queue, not a scheduler, and it can be a spreadsheet before it is a platform.
An ownership map. Which files, modules, and decisions belong to which stream of work. Agents respect boundaries they are told about. They cannot respect boundaries nobody wrote down.
A merge gate between agents. Agent PRs that touch adjacent areas wait for the earlier one to land. Serializing the hot paths costs throughput and buys correctness, which is a trade humans already make every day.
A human integration owner. When agent PRs collide, a person who owns the integration decides. Not because humans are faster. Because someone has to be accountable for the seam, and accountability does not delegate to a process.
💡 Pro-tip: the semantic collision is the one to design against first. The mechanical one announces itself. The semantic one ships clean, passes its own tests, and gets discovered by a customer. A shared contract check between agents working in the same area is worth more than any lock.
Where This Breaks Down
Two or three agents on one repo is not a fleet, and the interesting failures will not always reproduce on demand. Solo developers with a single agent can skip all of this. The problem arrives the first time someone parallelizes "funnel all the open tickets to the agents" without anyone asking which tickets share a codepath.
There is also a real risk of over-engineering: most teams need a claim queue and a merge order, not a control plane, on day one.
But the direction of travel is obvious. The team now includes non-human contributors, and every org-design problem humans ever had, multiplied by speed and stripped of social instinct, is coming to a repository near you.
How many agents touch your repo before the first collision, and who resolved it? Was it loud, or was it clean?
References
- The fleet-level version of this problem, and why agent fleets need a control plane: Kubernetes for Agents
- The gatekeeper pattern for what agents may do when they get there: I Stopped Trusting AI Agents With Tools. So I Built a Gatekeeper.
Top comments (10)
The semantic collision is the one a clean merge can hide. A useful gate could bind each dependent change to a version of the shared contract, then run an integration scenario against the combined result after the first change lands. File ownership helps avoid simultaneous edits, but it won’t detect a consumer built against an old assumption. How do you decide which cross-agent contracts deserve that extra check?
Not all of them. The filter I use is whether another agent's file set consumes the contract. A function nobody outside the working set calls doesn't need a check. A return shape three streams import does. In practice that means exported signatures, shared schemas, error contracts, and anything crossing a service boundary.
The cheap version is to diff the public surface of the changed module at merge time and intersect it with the files the other agent touched. If the surface moved and someone else imports it, run their tests against the merged result before the merge lands.
The expensive version is a contract registry with version tags, and most teams don't need it on day one. I'd still start with the merge-time check, because the agent that changes the meaning is usually the one that doesn't know it did. That's the case you're describing, and it's the one a registry can't help with either.
Two implementer agents shared one worktree in one of my sessions, and git had nothing to flag. The orchestrating agent gave them file sets it called disjoint, with the rule "stage only your own paths". But the index is shared, so a plain git commit from either would have swept in the other's staged work. The orchestrator caught one fully staged just as the second started, and had both name their paths on the commit. Later it changed a brief and sent one of them into two files it had just declared off limits. That agent applied the edits but refused to commit them, since the commit would have carried unreviewed work.
That story is the mechanical collision being caught by a human-level actor rather than by git. The detail that matters is the refusal: the agent applied edits but wouldn't commit, because the commit would have carried work it hadn't reviewed. That behavior should be cheap and standard.
The shared index is the root cause. 'Disjoint file sets' is true about edits and false about the staging area, so any rule phrased in file paths fails silently at commit time. Worktrees fix it properly. Naming paths on the commit is a patch that works until someone forgets.
The test I'd want from your session: does the orchestrator notice when the second agent stages a path it was told to leave alone? Attention is the resource that runs out first, so I'd put a pre-commit check on out-of-scope paths instead of relying on someone looking.
The semantic collision is the one I'd worry about most. File-level ownership and Git locks can prevent agents from overwriting each other's work, but they don't protect shared assumptions. Two agents can produce perfectly clean PRs that are individually correct and collectively break the system.
When working on agentic systems at IT Path Solutions, I'd treat shared interfaces as coordination boundaries, not just shared files. Before parallel work starts, agents should have access to the same contract definitions, expected inputs and outputs, and dependency assumptions. Then integration checks should validate the combined changes against those contracts, rather than relying only on tests each agent creates for its own task.
I'd also add a dependency-aware claim queue: if one task changes an API contract, downstream tasks should either wait for that change or explicitly work against the updated contract. Parallelism is valuable, but only when the work is genuinely independent. Otherwise, you're just moving coordination costs from development into integration and debugging.
Agree on interfaces as the boundary, with one caveat: a contract definition that never runs rots. I've seen a shared schema file that three services pointed at and one validated against, so it documented an intention rather than a boundary.
The dependency-aware claim queue is where the leverage is. If a task changes a contract, downstream tasks should be blocked or rebased, and either way the block has to be visible in the queue instead of understood by the planner.
The two failure modes you name, clean PRs that are individually right and collectively wrong, are why I put semantic collision first. It doesn't announce itself, and no local test catches it.
Great breakdown, Debashish! Imagine three agents independently updating checkout, order processing, and payment validation, with each passing its own tests but introducing incompatible assumptions when merged. Would you rely on shared contract tests and dependency-aware scheduling, or introduce a central coordinator to catch these conflicts? I'm curious how you'd scale that approach to 20+ agents without creating a new bottleneck.
No central coordinator. At 20 agents the coordinator becomes the serialization point and then the outage. What scales is coordination as a data structure: a claim queue anyone can read, an ownership map that says which stream owns which module, and a merge order that serializes only the hot paths.
Contract tests cover the semantic case. Dependency-aware claims cover the duplicate case. Neither needs a broker process.
At 20 agents the bottleneck usually isn't coordination anyway, it's review. If three agents can produce ten mergeable PRs a day and a person can review four, the queue moves to the reviewer and the coordination problem reappears wearing a different hat.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.