Launching today
agent-coherence
Stop AI agents from silently corrupting shared state
5 followers
Stop AI agents from silently corrupting shared state
5 followers
Two AI agents (two sessions, or an agent and a script) read the same file and both write it back. The later write silently clobbers the first: no error, the work is just gone. agent-coherence is a drop-in guard that catches the stale read before the overwrite lands, so the stale writer is denied and re-reads first. It ships as an MCP server, a LangGraph store drop-in, and a Python library. Single-host today (2+ agents on one machine); cross-host is opt-in, demo-grade. Open source, TLA+-checked.





how does it actually detect the stale read under the hood, like is it checking file mtimes or something fancier with the MCP session state?
Hi! Good question, and your session-state guess is close. It's not mtime. mtime is coarse and won't tell you whether the content actually changed.
A small local coordinator runs per workspace on 127.0.0.1, backed by SQLite-WAL. Per tracked artifact it holds a monotonic version, a SHA-256 content hash, and per-session MESI state. Two detection paths:
Coordinated writes go through the plugin hooks (PostToolUse on Edit/Write) or the MCP tools. A committed write bumps the version and pushes an invalidation to peer sessions, flipping them to INVALID. Their next read sees the stale view and catches it.
Foreign edits (someone edits the file directly) get caught on read by comparing the on-disk SHA-256 against the recorded hash. A mismatch means your view is stale. That's the part mtime can't do.
Honest scope: cooperative, and invalidation is pull, surfaced at your next tool action. Strict-mode deny is sticky, so recovery is reacquire plus a fresh read. It's open source if you want to read the coordinator directly, happy to go deeper.
ran a quick test with two langgraph agents editing the same json file and it actually caught the stale write before the clobber, which is the exact thing i kept hitting. nice that it’s tiny to drop in.