部落格
When two AI agents edit the same file

When two agents change one file at the same time, the safe outcome is a refused write: the agent working from an older version re-reads the file and reapplies its change, so nothing is overwritten and no second copy appears.
Fabric checks every write against the version of the file it was based on. If an agent saves a change made to an older version, Fabric refuses the write. The agent then re-reads the current file, applies its change again on top, and saves. Nobody's work is silently replaced, and the folder doesn't fill up with near-identical copies.
That's the short answer. The rest of this post explains why the problem shows up so often once a team runs several agents, what the two usual outcomes are, and what a refused write looks like in practice.
How a team ends up with plan-final-v2.md
Most people have seen a folder like this. There's plan.md, then plan-final.md, then plan-final-v2.md, and somewhere a plan-final-v2 (1).md that nobody remembers making. Each file is a fork: a moment when two versions of the same work existed and nobody joined them back together.
With people, forks tend to happen slowly. Someone downloads a file on Monday, edits it on a train, and uploads it on Wednesday without noticing a colleague changed it on Tuesday. With agents, the same thing happens in minutes. A team might have Claude Code tidying a launch plan while Codex updates the dates in it and a third agent adds notes from a customer call. Each agent opens the file, thinks for a while, and saves. If their sessions overlap, two of them are working from the same starting point, and only one of them can be first.
We've written about how version confusion slows teams down in why your team can't find the latest version and how to tell which version of a file is the latest. Agents make the question more frequent, and they're less likely than a person to notice anything went wrong.
Last write wins, or a forked copy
When two edits collide, a storage system usually does one of two things.
The first is last write wins. Whichever save arrives second replaces the file, and the earlier save is gone from the current version. For a team of people this is often acceptable, since two people rarely save the same document within seconds of each other, and version history can recover the loser if someone notices. For agents it's risky. An agent that spent ten minutes restructuring a plan can have its work replaced by another agent that only changed one date, because the second agent saved its whole copy of the older file. Neither agent is told. The file looks fine, and the restructure has quietly disappeared.
The second is a forked copy. Some sync tools keep both versions by saving the second one under a new name. Dropbox, for example, creates what it calls a conflicted copy when people edit the same file at the same time, adding the editor's name and the date to the filename. That design protects people's work, and a person who sees the extra file can open both and combine them. An agent usually won't. It reads plan.md, as it was told to, and never looks at the copy beside it. The second version of the work is safe on disk and missing from everything that happens next.
Here's how the two compare with a refused write.
What happens to the second save | Last write wins | Forked copy | Refused write |
|---|---|---|---|
Earlier change kept in the current file | No | Yes | Yes |
Second change kept | Yes | In a separate file | Yes, after it's reapplied |
Number of files afterward | One | Two | One |
Does the agent learn about the conflict? | No | Rarely | Yes, at the moment it saves |
The last row is the one that matters most. In the first two cases the conflict is discovered later, by a person, if at all. A refused write tells the agent while it still has the context to fix things.
How a refused write works
Revision checking asks one question at save time: is this change based on the version that's there now? Every time a file is saved it becomes a new version. When an agent saves, Fabric compares the version the agent started from with the current one. If they match, the write goes through. If someone else has saved in the meantime, the write is refused, and the agent has to re-read before trying again.
A small example makes it concrete. Two co-founders keep a shared launch-plan.md in Fabric. Here's the file at the start of the afternoon, which for this example we'll call version 7.
markdown
One founder asks Claude to draft the pricing section. Claude reads version 7 and starts writing. A few minutes later, the other founder asks Codex to push both dates back a week. Codex also reads version 7, makes its edit, and saves first. The file is now version 8, with the beta on 10 March and the launch on 31 March.
Claude finishes its pricing section and saves. Its change is based on version 7, so Fabric refuses it. If the write had been accepted, the dates would have gone back to 3 March and 24 March without anyone asking for that. Instead, Claude reads version 8, sees the new dates, adds the pricing section to that version and saves again. Version 9 has both changes.
markdown
The reapplying is done by the agent. Fabric doesn't try to merge the two edits on its own; it makes sure the agent knows the file moved, and the agent does what a careful colleague would do: look at the latest version and redo its change on top. Most of the time that's easy, because two agents are rarely editing the same lines. When their changes do contradict each other, say both rewrite the same paragraph in different directions, the agent at least sees the other change before saving. That's a good moment for it to leave a short note in the file or in decisions.md and let a person choose.
What this means for a team
For the people involved, the practical effect is that there's one file and it's current. Nobody spends a morning comparing plan-final.md with plan-final-v2.md, which is most of the story in two founders, two agents, one plan. Each person keeps the agent they prefer, connected through the MCP server, the CLI, the API, or the desktop app that mounts Fabric as a drive on Mac, Windows and Linux.
It also matters at a larger scale. When many agents write results into one shared folder, as in running a research project with a hundred agents, the chance of two of them touching the same summary file at once goes up quickly. Refused writes keep that safe without a separate system for locking files or queueing work.
A few habits help. Keep shared files small and focused, so a plan, a decision log and a handoff note are separate files rather than one long document. Ask agents to re-read a file just before they edit it, especially after a long task. And when an agent finishes a session, have it write what it changed into a NEXT.md note, as described in how to hand off work between AI agents. If a bad edit does get through, Fabric keeps earlier versions in version history, and what happens when an AI agent deletes the wrong file covers the other safety nets.
Concurrent writes are one of several things a folder has to handle once agents use it. The others, from server-side search to access that expires, are in your AI agents need a shared drive, not a group chat, and the definition page what is a shared drive for AI agents? puts them in one place.
Frequently asked questions
What happens when two AI agents edit the same file at the same time?
In Fabric, the first save goes through. The second agent's save is refused because it was based on an older version, so that agent re-reads the file and reapplies its change.
Does Fabric merge the two edits automatically?
No. Fabric refuses the outdated write and the agent reapplies its own change to the latest version. The agent sees the other change before it saves again.
What is last write wins?
It's a rule where the most recent save replaces the file, whatever it was based on. An earlier change can disappear from the current version without anyone being told.
What is a conflicted copy?
Some sync tools save a second version of a file under a new name when two edits collide. Dropbox calls this a conflicted copy. Agents often keep reading the original file and miss the copy.
Will Fabric create duplicate files when agents overlap?
No. A refused write doesn't create a second file. There's one file, and each accepted save becomes its newest version.
What if both agents change the same paragraph?
The second agent re-reads the file and sees the first agent's change before saving. If the two changes contradict each other, it's best for the agent to note the conflict and let a person decide.
Can I get back an earlier version of a file?
Yes. Fabric keeps earlier versions in version history, so a change you didn't want can be undone.
Does this work if each person uses a different AI agent?
Yes. Writes are checked by Fabric, whichever agent makes them, so Claude, ChatGPT, Codex and Cursor can all work on the same files.
Related pages
其他部落格文章:

Agent memory vs a shared drive

Can AI agents use Google Drive or Dropbox?

What happens when an AI agent deletes the wrong file

Why AI agents give up searching your files

Why AI agent access should expire

Your agent instruction files are a security risk

When two AI agents edit the same file

Ask your files, don't build a dashboard