TLDR: When a human and an AI coding agent write to the same file at the same time, naive syncing forces a choice — keep the human’s edits and drop the agent’s, or keep the agent’s and drop the human’s. This is the classic lost-update problem.
Problem
The problem is already happening at scale in production:
- me suferring with lost content in VSCode
- Antigravity’s autosave races the agent’s streaming write to a new file; if the editor’s autosave timer fires first, it flushes an empty buffer, the agent sees a file that “already exists,” and skips the rest of its own write — the generated content vanishes (writeup).
- VS Code has an open issue asking for a “strict mode” specifically to stop concurrent AI agent edits from corrupting files (microsoft/vscode#279589), and a separate report of Copilot applying superseded edits from earlier in the conversation, corrupting file state (microsoft/vscode#265794).
- Zed has a tracking issue for what happens when an agent wants to write a file the user has unsaved (“dirty”) changes in (zed-industries/zed#39738).
Three different editors, three variants of the same bug: one writer’s work disappears because the other writer didn’t know it was there.
Why “just diff and patch” doesn’t work
A full-file replace is the worst case: whoever writes second overwrites the other unconditionally. Taskade’s writeup on adding agents to a multiplayer document states the failure mode precisely: “Replacing the document destroys whatever a human is typing at that moment… A replace operation would vaporize their in-flight edits” (source).
The actual fix: treat the agent as a peer, not a writer
The systems that get this right stop treating “sync the file” as the problem and instead put both the human and the agent inside the same CRDT (or OT) document, where every edit is a small operation that merges by construction instead of a whole-file write that clobbers.
- Electric’s writeup on using Yjs describes the agent issuing tool calls that become CRDT operations rather than text diffs, so that “if two humans and an agent are all editing simultaneously, Yjs merges everything without coordination” (source).
- The CHI 2026 paper on collaborative document editing with multiple users and AI agents frames the same requirement academically: the agent has to be a participant in the CRDT session, not an external process poking at the file (DOI).
- Zed’s approach — multiple humans and multiple agents writing into the same buffer, with per-cursor attribution — is the product-level version of the same idea (overview).
To solve, this problem, I build gakoy-collab:
a CLI that shares a local folder for real-time browser editing while a
coding agent is also writing to it. The fix is the same one above — a
Yjs CRDT per watched file, so filesystem writes from the agent and
keystrokes from the browser merge instead of racing.
Final word
It’s good to have both humans and agents modifying document, but we need the right infrastracture for that.