How to Send a Patch From One Coding Agent to Another
Two coding agents working in parallel each have their own checkout: a worktree, a sandbox, a fork. That isolation stops them overwriting each other on disk. It also means neither can see what the other changed. When their work touches the same code, they have to agree who writes it, and then the other has to get the result. A message saying "I made both changes" does not put those changes in the second checkout.
This guide shows how to send the change itself from one agent to another with forkit share and forkit apply, what happens when the receiving agent has already edited the same files, and the safety check on what a patch may write.
A note on a shared word: Forkit's "factories" are saved fan-outs and are not part of this guide, and the company Factory is unrelated.
Why a message is not enough
Forkit added patches on messages after running CooperBench, a benchmark where two agents each implement one feature in the same codebase and their patches are merged at the end (two-agents-one-function-cooperbench, 23 Nov 2026). On go-chi task 26, both features had to change the same lines. With file claims in place, the agents negotiated an owner: "I'll make both changes together." The owner made them in its own copy. The other agent looked, saw nothing, and wrote: "We might be working in different workspaces." It made its own edits, and the two patches clashed (CLAUDE.md, "Patches between agents", 23 Nov 2026).
Research points the same way. Xia, Wu and Park ("Passes Alone, Fails Together", arXiv 2609.25396, 21 Sep 2026, preprint) built twelve tasks where parallel agents' changes interfere and found interference in 97% of runs. Giving an agent a message that described the finished concurrent change "recovered 82% of runs." They caution that their constructed tasks "do not estimate how often these problems occur in practice": on 417 pairs of real Django pull requests, only one of 834 runs showed interference once grading was corrected.
GitHub's "Multi-agent workflows often fail. Here's how to engineer ones that don't." (Gwen Davis, 24 Feb 2026) puts the general rule this way: "Most multi-agent workflow failures come down to missing structure, not model capability." It recommends typed schemas at every agent boundary. A patch is the most structured way to describe a code change there is: git apply either applies it or says where it does not fit.
Step 1: Agree who writes the shared change
Before anything is sent, one agent must own the shared lines. With Forkit, file claims make that explicit: a claim on a file another agent holds is refused and names the holder, and both are told (CLAUDE.md, "File leases", 23 Nov 2026). The agents then message each other and agree an owner. The owner writes the change for both features.
Step 2: Send the change
In the owner's checkout:
forkit share --to chi-agent-2 -m "Both edits to routeHTTP, as agreed. Take this instead of your own." -- mux.go
forkit share sends the checkout's change since HEAD, tracked edits and new files, as a patch on a Forkit message. Paths after -- limit it to those files; without them, the whole change goes. --reply-to MESSAGE_ID sends it as the answer to a question the other agent asked.
What Forkit does with it (CLAUDE.md, "Patches between agents"):
- A patch is a unified diff of at most 200,000 characters. It is kept in its own table and written in the same batch as the message, only if the message was.
- The message lists the files the patch changes.
- The delivered text names the files and tells the agent to run
forkit apply <id>. The patch itself is never put into the agent's context. GET /api/v1/messages/:id/patchgives the patch to its recipient or its sender only. Anyone else gets 404.
The message reaches the receiving agent like any Forkit message: after its next Bash or edit tool call, when its turn ends, or with its next prompt, through Claude Code's hooks. Agents without hooks read it with codemode.read_messages or wait for it with the wait_for_message tool.
Step 3: Check, then apply
In the receiving agent's checkout:
forkit apply am-1a2b3c --check
--check says whether the patch applies cleanly and changes nothing. Then:
forkit apply am-1a2b3c
This runs git apply --3way. If the patch is already applied, it says so and exits with code 3 instead of applying it twice. If parts conflict, they are marked in the files, and the agent resolves them or asks the sender.
Step 4: When the receiver already edited the same files
This is the case a real run found. On 25 Nov 2026, in a run with two Claude Code agents, one agent built both features. The other had already made its own edits to the same files, and could not take the combined version without discarding those edits. Discarding work by hand on a guess is a step an agent should not have to take.
--replace handles it:
forkit apply am-1a2b3c --replace
It saves the receiver's own change to those files as a backup patch in .git/forkit/<id>-mine.patch, puts the files back as they were at HEAD, and applies the sender's version. Nothing is lost: git apply on the backup brings the receiver's version back. When a plain forkit apply fails, its error message suggests --replace if the sender built both.
Use --replace only when the sender's version already contains the receiver's work. If it does not, a plain apply and a resolved conflict is the right path.
Step 5: Patches may not write settings
A patch from another agent is code you did not write. Some files make a tool run commands: agent settings, CI workflows, editor tasks, git hooks. forkit apply refuses a patch that touches any of these unless told --allow-config:
- folders:
.claude/,.codex/,.cursor/,.git/,.github/,.gitlab/,.vscode/,.idea/,.husky/,.devcontainer/,.circleci/; - files:
.mcp.json,.envrc,.gitlab-ci.yml,.pre-commit-config.yaml,.gitattributes,AGENTS.md,CLAUDE.md.
The refusal names the paths and says to read the patch first. This was found in a security review on 25 Nov 2026: a patch could have created a hook while naming other files in its message. Every path a patch touches is checked, including both sides of a rename.
What happened when agents used it
In Forkit's CooperBench runs, agents used patches in three of the four pairs where both features had to change the same lines. Patches alone did not make the work merge: one agent then tidied its own patch, removing four agreed lines, and the two were four lines apart and conflicted. What closed the gap was a merge check that waits for peers (see how to check that parallel agents' work will merge). With both, 3 of 4 colliding pairs merged, against 0 of 8 with CooperBench's own messaging. The later versions ran once per pair, so this is a signal, not a measured rate. On two pairs the agents ended with byte-identical patches.
A checklist
- Claim files before editing, so overlaps show early.
- When two features need the same lines, agree one owner by message.
- The owner sends the change with
forkit share --to AGENT -- PATHS. - The receiver runs
forkit apply ID --check, thenforkit apply ID. - If the receiver already edited those files and the sender's version contains its work,
forkit apply ID --replace. - Never pass
--allow-configwithout reading the patch. - Run
forkit check-mergebefore finishing.
What this does not cover
- A patch carries text. Two changes that apply cleanly can still break each other when run; only tests on the combined code find that. Forkit does not run them.
forkit sharesends the change since HEAD. Work an agent committed earlier is not included unless you name it another way.- Agents connected without hooks, such as Codex through
notifyalone orforkit run, cannot receive messages in their turn.
Related: agent handoff notes, agent-to-agent messaging patterns, what we learned running CooperBench and how to check that parallel agents' work will merge.
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. A patch on a message lets one agent's decision become the other agent's code. Forkit runs no agents; it carries the change between the ones you run. It is free to try at forkit-mcp.com.
Sources
- Xia, Wu and Park, "Passes Alone, Fails Together: Benchmarking Semantic Coordination in Parallel LLM-Agent Development", arXiv 2609.25396, 21 Sep 2026, https://arxiv.org/abs/2609.25396 (preprint; read 25 Nov 2026).
- GitHub, "Multi-agent workflows often fail. Here's how to engineer ones that don't.", Gwen Davis, 24 Feb 2026, https://github.blog/ai-and-ml/generative-ai/multi-agent-workflows-often-fail-heres-how-to-engineer-ones-that-dont/ (read 25 Nov 2026).
- Khatua et al., "CooperBench: Why Coding Agents Cannot be Your Teammates Yet", Jan 2026, https://arxiv.org/abs/2601.13295.
- Forkit, "Two Coding Agents, One Function: What We Learned Running CooperBench", 23 Nov 2026, /blog/two-agents-one-function-cooperbench.
- Forkit engineering notes (CLAUDE.md): "Patches between agents", 23 Nov 2026; "File leases", 23 Nov 2026; "Delivery into a running agent".
forkit shareandforkit apply, forkit-cli command reference, 25 Nov 2026.