---
title: "Agent collision: what it is when AI coding agents overwrite each other · Cork"
description: "An agent collision is when two AI coding agents change the same code, or code that depends on each other, without knowing, so one breaks or erases the other."
canonical: "https://corkcli.com/blog/agent-collision"
last_updated: "2026-11-14"
published: "2026-10-03"
author: "Kevin Vera"
---

# Agent collision: what it is when AI coding agents overwrite each other

An agent collision is when two AI coding agents change the same code, or code that depends on each other, without knowing, so one breaks or erases the other.

By Kevin Vera · October 3, 2026 · [Glossary](https://corkcli.com/blog/c/glossary) · 3 min read

An **agent collision** is what happens when two or more AI coding agents (or an agent and a person) change the same code, or code that depends on each other, at the same time without knowing about each other, so that one agent's work overwrites, breaks or silently contradicts the other's.

The term covers more than a git merge conflict. A merge conflict is one visible symptom. Many agent collisions never produce a conflict marker at all: the files merge cleanly and the program is still wrong.

## Why it happens

Coding agents work from what is in their own context window. Each agent reads the files it needs, forms a plan, and edits. Nothing in that loop tells it that another agent, in another terminal or on another machine, is editing the same function or the code that calls it. Claude Code's own documentation for agent teams states the problem plainly: "Two teammates editing the same file leads to overwrites."

Three conditions make collisions likely:

- **Shared checkout.** Several agents write to one working directory, so the last write wins.
- **Stale context.** An agent read a file ten minutes ago and edits from that memory after another agent changed it.
- **Hidden dependencies.** Agents touch different files, but one renames or re-signatures a function the other calls.

Running agents in separate git worktrees removes the first condition while they work. It does not remove the other two: the work still has to come back together at merge time.

## Examples

- **Overwrite.** Agent A adds input validation to `create_user`. Agent B, working from an older read of the same file, rewrites `create_user` for logging and saves. A's validation is gone, and nobody was told.
- **Broken caller.** Agent A renames `get_invoice` to `fetch_invoice` across the files it knows about. Agent B, in a worktree, adds three new calls to `get_invoice`. Both branches merge without a conflict and the build fails.
- **Duplicate work.** Two agents are each asked to "fix the flaky checkout test" and land two different fixes to the same helper.
- **Contradictory decisions.** One agent switches a module to async while another adds synchronous callers to it.

## How teams handle it

Common approaches, roughly from lightest to heaviest:

- **Split the work by files.** Claude Code's agent teams docs advise breaking work "so each teammate owns a different set of files." This works until a task crosses a boundary.
- **Isolate with git worktrees.** Each agent gets its own folder and branch. Collisions move to merge time, where they surface as merge conflicts or, worse, as clean merges that break.
- **Serialize.** Run one agent at a time on risky areas, which gives up most of the speed of parallel agents.
- **Review and CI.** Pull request review and tests catch some collisions after the fact.
- **A [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents).** Give agents live knowledge of each other while they work.

Cork takes the last approach. Cork is the coordination layer for multiplayer coding agents: it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned. In practice that means a briefing on the code an agent is about to touch, live notice when another agent changes code it depends on, a write gate that holds an edit against code another agent is changing right now until your agent has their version, [semantic lint](https://corkcli.com/blog/semantic-lint) for renames and signature changes, and a landing step that rebases onto teammates' commits, reruns the tests and pushes. One machine is Cork Free; across machines is the paid plan.

## Related terms

- [Agent merge conflict](https://corkcli.com/blog/agent-merge-conflict)
- [Semantic merge conflict](https://corkcli.com/blog/semantic-merge-conflict)
- [Write gate](https://corkcli.com/blog/write-gate)
- [Blast radius](https://corkcli.com/blog/blast-radius)
- Parallel AI coding agents
- Coordination layer (for AI coding agents)

## Sources

- <https://code.claude.com/docs/en/agent-teams>
- <https://git-scm.com/docs/git-worktree>

## Related reading

- [Coordination layer for AI coding agents: what it is and what it does](https://corkcli.com/blog/coordination-layer-ai-coding-agents): A coordination layer for AI coding agents sits under the tools that run agents and keeps parallel agents aware of each other's changes so the work fits.
- [Semantic merge conflict: changes that merge cleanly but break the code](https://corkcli.com/blog/semantic-merge-conflict): A semantic merge conflict is when two changes merge with no textual conflict but the result is wrong, such as a rename plus new calls to the old name.
- [How to stop Claude Code agents from overwriting each other's changes](https://corkcli.com/blog/stop-claude-code-agents-overwriting-changes): Why parallel Claude Code agents overwrite each other's edits, and how to stop it with worktrees, file ownership, deny rules, PreToolUse hooks and a write gate.
- [Blast radius in code: everything a change can break](https://corkcli.com/blog/blast-radius): The blast radius of a code change is the set of callers, dependents, tests and teammates' work that the change can affect, used to judge risk before editing.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/agent-collision
