We Checked Our Merge Check Against 26 Real Merges
When several coding agents work in separate checkouts, the first time anyone learns whether their work fits together is usually the merge. By then the agents have stopped, and the agent that could fix the conflict is gone.
Forkit's merge check moves that moment earlier. Each agent of a fan-out (a group of agents started together) sends its current change, and Forkit says whether it would merge with each peer's latest change. An agent whose change would conflict is held before it stops, told the file, both line ranges and the peer.
A check like this is only useful if it agrees with the real merge. This post explains how it decides, how it compared with git on the 26 merges recorded in our CooperBench runs, the cases it was tested against, and what it cannot see.
How the check decides
The rule is the one git's three-way merge uses for text: changes to the same or adjacent lines of the same base conflict, unless they are the same change.
In detail, from src/db/merge_check.ts:
- Each agent sends its change as a unified diff (
git diffoutput) against the commit it started from, and that commit's id. - For each file, Forkit reads the changed regions in the base file's line numbers: which base lines were removed or replaced, and where lines were inserted. Context lines around a hunk are not part of a region.
- Two regions from different agents conflict when they overlap or touch: one region ending on the line just before the other begins counts. Two insertions at the same point conflict.
- Two regions that cover the same lines and make exactly the same change do not conflict. Two agents that both applied the same patch merge cleanly.
- A new file at the same path with different content conflicts. Different new files merge.
The tests in src/test/merge_check.test.ts pin each rule down. A change to line 453 and a change to line 454 conflict. A change to line 453 and a change to line 455, with one unchanged line between them, merge. The case that started all this is a test too: two copies of the same block in mux.go, one keeping four lines the other removed, conflict.
Why we built it
In our CooperBench runs (written up in Two Coding Agents, One Function), two agents agreed that one would make both changes to a shared function. The other agent then tidied its own copy: "Wait, I need to remove the PathValue lines from my patch since they're part of my peer's feature, not mine." The two patches were four lines apart and conflicted. Nothing noticed until the merge failed.
CooperBench's own scoring merges the two agents' patches with git merge-file, and only if that fails tries a union merge and then a small learned resolver. If none produces a conflict-free result that passes, both features fail. So a check that agrees with git's verdict is a check that agrees with the first and most important step of the benchmark's scoring.
The comparison: 26 merges, the same verdict
Across our CooperBench runs, the benchmark recorded the two patches each pair of agents produced and the result of merging them. For each recorded pair we compared Forkit's verdict, conflict or clean, with git's.
On all 26, the verdict was the same. Those were the merges recorded when the check was built (23 November 2026). The later runs of that week added more; on all 37 recorded by the end, the verdict still matched git's, which is the figure in our CooperBench write-up.
What that does and does not show:
- It shows that on real patches written by coding agents to real repositories, the line rule above agreed with git every time.
- It does not show agreement on every kind of change. Twenty-six merges from six task pairs is a small sample. Kinds of change that did not occur in it, such as renames, binary files or changes only to file modes, are not covered by this comparison.
- We have not published the cases and the comparison script, and the raw logs of those runs were lost when our test machine restarted. Until we do, treat this as our claim rather than something you can check.
A correct verdict that came too late
Agreeing with git was not enough. In version 3 of our runs, the check ran in the Stop hook: when an agent finished, it asked whether its change would merge. Four runs in a row, the first agent to finish checked, found no peer had sent a change yet, and left. The second agent was then held alone with a conflict that only the first could fix.
The fix was to make an agent that finishes first wait for its peers to check in. The wait can be a fixed number of seconds (FORKIT_MERGE_WAIT, 300 by default) or adaptive (auto): keep waiting while some peer that has not checked in has an open session that was active recently (FORKIT_MERGE_QUIET, 180 seconds by default). In version 3.1 the go-chi pair merged for the first time, and in two other pairs the agents ended with byte-identical patches.
Waiting creates a new risk: a peer that never checks in could keep an agent forever. So the wait has hard caps that no setting removes: at most 840 seconds of waiting (FORKIT_MERGE_MAX, inside Claude Code's 900-second Stop hook limit) and at most 10 holds (FORKIT_MERGE_MAX_HOLDS). The scenario tests S78 to S81 in src/test/scenarios.test.ts check the cases we could think of:
- A peer that never started, or crashed, is not waited for.
- A peer that keeps looking busy but never checks in is waited for only up to the cap.
- A peer whose session is open but has gone quiet stops being waited for.
- The same conflict holds an agent once. Two diffs flipping back and forth hold twice. A peer that keeps inventing new conflicts is held against only up to the cap.
The check also refuses to be moved by strangers. It compares an agent only with peers of its own fan-out, so an agent in another fan-out in the same workspace cannot hold it. And it parses only peers' diffs that name one of the agent's own files, so a check in a large fan-out reads headers for most peers and full diffs for few.
When the bases differ
A line rule needs a shared base. If two agents started from different commits, line 453 in one diff is not line 453 in the other.
This turns out to matter a lot. MERGEGYM (Subramanian, Xu and Karthik, arXiv, 3 October 2026, a preprint) studied 715 pairs of concurrent agent pull requests and found that 79 of 167 textual conflicts (47.3%) happened even though the files the two agents authored were disjoint. The cause was a mismatch in bases: each pull request's diff was measured against its own base.
Forkit's check does not guess here. A peer whose base commit differs is reported under different_base and not compared. We met a version of this in our own runs. In one v3.1 run an agent ran git commit, which moved the commit the check compared from, and the check answered "started from another commit" while a conflict was real. Now the base is recorded the first time Forkit sees the checkout (in .git/forkit-base), and the diff an agent sends covers its tracked edits, commits and new files since then.
Cost of checking
MERGEGYM also measured that replaying a merge with git merge-tree took a median of 0.02 seconds in its logs, and concluded: "when exact replay is cheap, verify everything." We agree with the conclusion. Forkit's check runs on the server, without a checkout, from the diffs agents send, so it compares line regions instead of replaying git. A security review on 25 November 2026 found that comparing every pair of regions took seconds on crafted diffs. The comparison now sweeps both sorted lists once, caps the conflicts it lists at 200, and refuses diffs over 200,000 characters.
What it cannot see
The check is textual. Two changes that touch different lines can merge cleanly and still break each other: one agent renames a function another agent calls, or changes a rule another relies on.
How common that is depends on the work. "Passes Alone, Fails Together" (Xia, Wu and Park, arXiv, 21 September 2026, a preprint) found interference in 97% of runs on tasks built to cause it, and in 1 of 834 runs on 417 pairs of real Django pull requests once grading was corrected. The same paper found that giving an agent a message describing the completed concurrent change recovered 82% of runs. Forkit's closest tool for that is a patch carried on a message (forkit share, forkit apply), which tells an agent exactly what its peer changed.
Running the tests on the combined change before agents stop is the check that would catch these. Forkit does not do that yet. Until it does, run the full test suite after collecting the agents' work.
What we would not claim
- 26 merges when it was built and 37 by the end of the week, from a handful of task pairs and one benchmark. Agreement there is evidence, not proof of agreement everywhere.
- Every merge in the sample came from agents using one model, in our own runs.
- The cases and the script are not yet public.
- A clean verdict means the text merges. It says nothing about whether the result works.
Related: how to run 50 coding agents without merge conflicts, git worktrees vs file leases and file locking for AI agents.
Where Forkit fits
Forkit is the coordination system for agent teams: plans, handoffs, file claims and decisions, shared by every agent and the people behind them. It does not run agents. The merge check is one part: it works for agents of a fan-out that send their diffs, through forkit check-merge or the Claude Code Stop hook. It is free to try at forkit-mcp.com.
Sources
- Khatua et al., "CooperBench", arXiv 2601.13295, January 2026 (preprint; merge procedure in section 2.2 and appendix B): https://arxiv.org/html/2601.13295
- Subramanian, Xu and Karthik, "Asymmetric Repository Lineage Modeling and Verifier-Guided Coordination in Concurrent AI Coding Agents" (MERGEGYM), arXiv 2610.04779, 3 October 2026 (preprint): https://arxiv.org/abs/2610.04779
- Xia, Wu and Park, "Passes Alone, Fails Together", arXiv 2609.25396, 21 September 2026 (preprint): https://arxiv.org/abs/2609.25396
- Forkit, "Two Coding Agents, One Function: What We Learned Running CooperBench", 23 November 2026: https://forkit-mcp.com/blog/two-agents-one-function-cooperbench
- Forkit source:
src/db/merge_check.ts,src/test/merge_check.test.ts,src/test/scenarios.test.ts(S78 to S81), and engineering notes, "Would our work merge?", 23 November 2026.