The awkward moment in AI-assisted editing isn't the agent writing something wrong. It is the agent and a person changing the same article at the same time. One of them saves, the other saves a moment later, and one set of changes quietly disappears.
emDash has two protections against this, and version 1.4 closed a gap in one of them. We tested both on a copy of this site, with an AI agent working through the MCP server while a person had the same entry open in the admin. Most collisions are now refused, with a clear message. One still ends with the agent's work overwritten, and it is worth knowing which.
Two protections, two different jobs
The revision token guards against stale information. Every read returns an opaque value called _rev. A change has to send it back, and if anyone has saved since that read, emDash refuses the change with a conflict. The MCP tools require the token; the REST API accepts it but doesn't insist; the command line insists.
The edit lock guards against working on the same thing at the same time. Opening an entry in the admin takes a lock for that entry and language. It is renewed while the editor stays open and expires seven minutes after the last renewal. While someone else holds it, changes from the API, the command line or an MCP client are refused, unless the request explicitly overrides the lock. Administrators can switch locking off per collection.
The token answers "has this changed since I looked?" The lock answers "is someone working on this right now?" An agent meets both.
What we tested
We ran a copy of this site on emDash 1.4.0 locally, with Cloudflare's local runtime and database. Two users took part: an administrator using the admin in a browser, and a separate agent account with its own token, calling the MCP server and the REST API. Nothing touched the live site.
| Situation | What happened |
|---|---|
| Agent saves twice from the same read | First saved; second refused: content modified since last read |
| Two MCP saves from the same read, sent at the same moment (5 rounds) | Every round: one saved, one refused with a conflict |
| The same through the REST API, with the token (5 rounds) | Every round: one saved, one refused with a conflict |
| Two REST saves without the token | Both reported success; the second replaced the first |
| Agent saves while the administrator has the entry open | Refused: the entry is locked, naming the administrator; still refused after re-reading |
| Agent saves with the lock override | Saved; the administrator kept the lock |
| Administrator then types in the open editor | Autosave refused; a warning offers Save anyway |
| Administrator chooses Save anyway | Saved; the agent's change was reverted, and survives only in the revision history |
What 1.4 changed
Refusing a change based on an old read is not new. What 1.4 fixed is the narrow case of two saves based on the same version arriving together. Before, on Cloudflare D1, Durable Objects and PostgreSQL, both could report success while the first was overwritten. In our five rounds of simultaneous saves, through MCP and through REST, emDash 1.4 saved exactly one change each time and refused the other.
That case sounds rare for two people. It is not rare for software. An agent working through a list of articles, a script fixing metadata, and an editor's autosave, which fires two seconds after typing stops, can easily land on the same entry within the same second.
The two ways work is still lost
Scripts that skip the token
The REST API treats the revision token as optional, so a script can deliberately write without it. When two of ours did, both were told they had succeeded, and the first change was replaced. Nothing warned either script.
If you write scripts against the REST API, make the token mandatory in your own code. Read the entry, send its _rev with the change, and handle the conflict. The command line already works this way: emdash content update won't run without --rev.
An editor who saves anyway
When the agent overrode the lock and changed the standfirst, the administrator's open editor didn't refresh. It still showed the old standfirst. As soon as the administrator typed in another field, autosave was refused and the editor said:
The warning is accurate, but it doesn't say what changed. Choosing Save anyway saved the whole form, including the old standfirst, so the agent's change vanished from the entry. It was still in the revision history, attributed to the agent's account, and could be restored from there.
The safer response to that warning is to copy what you typed, reload the entry to see the newer version, and apply your change again. If you did press Save anyway, open the revisions and check what the other save contained.
Writing an agent or script that backs off
The rules are short. Read immediately before changing. Send the token from that read. On a conflict, read again and re-apply the change to the newer version, rather than resending an old copy of the whole entry. On a lock, stop and report who holds the entry. Send only the fields you mean to change, since both the MCP tools and the REST API leave other fields alone.
Here is the pattern for the REST API, with a personal access token:
// Change some fields of an emDash entry without overwriting anyone else's work.// change() receives the latest saved fields and returns only the fields to update.async function safeUpdate(site, token, collection, id, change, attempts = 3) { const headers = { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }; const url = `${site}/_emdash/api/content/${collection}/${id}`; for (let attempt = 1; attempt <= attempts; attempt++) { const read = await fetch(url, { headers }).then((res) => res.json()); const { item, _rev } = read.data; const res = await fetch(url, { method: "PUT", headers, body: JSON.stringify({ data: change(item.data), _rev }), }); if (res.ok) return (await res.json()).data; const { error } = await res.json(); if (error?.code === "ENTRY_LOCKED") { const who = error.details?.userName ?? "Someone"; throw new Error(`${who} has this entry open until ${error.details?.expiresAt}`); } if (error?.code !== "CONFLICT") throw new Error(error?.message ?? `HTTP ${res.status}`); // Someone saved in between: loop, read the newer version and apply the change to it. } throw new Error(`Gave up after ${attempts} conflicts`);} // Example: tidy one standfirst.await safeUpdate(site, token, "posts", entryId, (data) => ({ excerpt: data.excerpt.trim() }));
An AI agent using the MCP server needs the same rules in its instructions, because the tools report a conflict or a lock but leave the decision to the agent. These are the lines we give ours:
- Read an entry immediately before changing it, and use the _rev from that read.- If a save returns CONFLICT, read the entry again, apply your change to the new version and try once more. If it conflicts again, stop and tell me.- If a save returns ENTRY_LOCKED, stop and tell me who holds the entry and until when. Never pass overrideLock unless I ask for that specific entry.- Change only the fields you were asked to change.
Making agents and editors share a site
- Running an emDash site yourself. Upgrade to 1.4, keep edit locking on, and give your assistant the four lines above. If you ever see the conflict warning, reload rather than saving anyway.
- Evaluating emDash. Optimistic conflicts plus edit locks, with the lock holder's name in the error, is a sound design for mixed human and AI editing. Ask how your current CMS handles the same collision.
- Running an agency. Every integration you build for a client should send the revision token and handle both errors. Make it part of code review, and explain the conflict warning in the client's editor training.




