Learn/Multi-agent · 7 min · updated 2026-08-03

Agent collision detection: stopping two AI agents editing the same function

When several coding agents work on one repository, two of them will eventually rewrite the same function. How collision detection works at the file, symbol and branch level, and what to do when it fires.

Agent collision detection is the check that fires when two coding agents are about to change the same piece of code at the same time. It matters because parallel agents do not read each other's work. Each one starts from the state of the repository when it was launched, and if two of them are pointed at the same function, both will write a version of it and the second merge will either conflict or quietly undo the first.

Why Git alone does not catch it

Git detects overlap at the line level, at merge time, on the same file. That misses two cases that come up constantly with agents. The first is a semantic overlap in different files: one agent changes the signature of parseConfig while another writes three new call sites for the old signature. Git merges both cleanly and the build breaks. The second is timing: by the time the merge runs, both agents have finished, which is the most expensive moment to find out.

Three levels of detection

LevelWhat it watchesCatches
FileTwo sessions with the same path dirtyThe obvious case, and a lot of false alarms in a large file
SymbolTwo sessions touching the same function, class or methodReal overlap, with far fewer false alarms
DependencyOne session changing something the other depends onThe signature change above, which the other two levels miss

File-level detection is easy and noisy. Symbol-level detection needs a parser: the tool has to know that lines 40 to 78 are the body of parseConfig. Dependency-level detection needs a graph of what calls what, which is the same structure a semantic diff is built on.

How Aura does it

Aura tracks claims at the symbol level. When a session starts editing, it announces the symbols it is working on, and the engine compares that against every other live session and against recent commits on other branches. Two kinds of result come back. A direct collision means the same symbol is in flight in two places, and the sessions have to coordinate before either continues. A likely collision means the same file, or a symbol that has just landed underneath the session, which usually means re-read before editing.

Cross-branch overlap is reported separately as an impact alert: a function you depend on was modified or deleted on a branch that is not yours. That is the case teams find latest and fix slowest, because nothing in a normal workflow surfaces it until the branches meet.

What to do when a collision fires

  • Stop the second agent before it writes. Rolling back one session is cheaper than merging two.
  • Decide which session owns the symbol, and give the other one a different task.
  • If both changes are needed, sequence them: let the first land, rebase the second, re-read the function.
  • For a whole area of the codebase, claim the zone rather than the symbols, so nothing else is dispatched there.

Prevention beats detection

The best collision is the one that never gets dispatched. Splitting work by module rather than by ticket, and giving each agent its own worktree, removes most overlap before an agent starts. The detector is there for what is left, which in practice is refactors that reach further than anyone expected.

See also: the agent inbox for how sessions coordinate once a collision is found, and Aura compared with Conductor for two takes on the parallel model.

Questions

What is agent collision detection?

Noticing that two coding agents are about to change the same code, and saying so before either commits. It works at three widths: the same file, the same symbol inside that file, and the same symbol across separate branches, which is the one merges do not catch.

What happens when two AI agents edit the same function?

On one working directory, the second write silently overwrites the first. In separate worktrees both succeed, both branches pass, and the disagreement surfaces at merge — as a conflict if the lines overlap, and as a bug if they do not.

Does Git prevent two agents from editing the same code?

No. Git arbitrates at merge time and only over line ranges. Two branches that touch the same function in non-overlapping lines merge cleanly and produce a function neither agent intended. Nothing in Git is watching while the work happens.

How do you coordinate several coding agents on one repository?

Isolate them first — a worktree each — then add a shared signal for what is in flight. Announcing the symbols an agent is about to touch turns a merge-time surprise into a start-time warning, which is the only point where it is cheap to resolve.