by Martin Monperrus

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:

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.

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.