Timeouts turn helpful agents into duplicate-write machines
Your coding agent creates a GitHub issue or fires a webhook, the call times out right after the server accepts it, and the agent immediately retries. Now you have two identical issues, a duplicate comment, or a double webhook delivery.
Then, at the end of a long session, the agent summarizes its external changes from compressed chat memory and either misses a git push or claims a timed-out write landed.
I built sidefx to put a durable local SQLite write-ahead journal in front of mutating MCP (Model Context Protocol, the standard way agents talk to external tool servers) and shell calls, so retries reconcile instead of double-posting and session receipts come straight from database rows.
Why a local SQLite WAL instead of prompt rules or a hosted proxy
Telling an agent in a system prompt not to retry blindly does not work when a timeout leaves the agent with no way to know whether the write landed. Standing up a separate proxy server or external database for local CLI workflows is overkill nobody will actually maintain.
SQLite with a WAL (write-ahead log, SQLite's crash-safe commit log) and full synchronous disk flushes is already built into Python's standard library. It handles concurrent local worker processes cleanly, survives crashes, needs no third-party dependencies, and lives inside an owner-only local directory that automatically gitignores itself.
I also made a deliberate privacy trade-off early: the journal stores SHA-256 hashes of tool arguments and command arrays rather than raw payloads, and redacts URL credentials, webhook path tokens, auth headers, and API keys before saving targets or error snippets.
How the MCP proxy, CLI wrapper, and crash reconcilers fit together
sidefx sits in front of external writes in two places: a drop-in stdio MCP proxy for Claude Code, Cursor, or Codex, and a CLI wrapper for shell commands like git push, GitHub CLI writes, and curl webhooks.
In the MCP proxy, read-only tools and protocol handshakes pass straight through with roughly 0.02 ms of median overhead. Mutating tool calls first hit deterministic preflight rules in your project config, where you can enforce required arguments, numeric caps like maximum refund amounts, protected-branch denylists, and allowed email domains. A violation fails closed before anything reaches the upstream server.
Calls that pass preflight take two durable WAL commits: first writing the action as pending (keyed by actor, target, and action ID) before calling upstream, and second marking it confirmed once the reply arrives. On macOS with full fsync (flushing data all the way to disk) enabled, those two commits add about 8.0 ms of median overhead.
Once confirmed, identical MCP retries in the same session replay directly from disk in 0.044 ms without touching upstream when deterministic IDs are enabled or when an explicit action ID is supplied. Reusing the same action ID with modified arguments is rejected immediately as a payload mismatch.
When a call times out or crashes mid-flight, sidefx marks the row unknown and blocks blind retries with an explicit outcome-unknown error containing exact recovery commands. For git push, the built-in reconciler checks the remote read-only with git ls-remote. For GitHub issues, pull requests, and comments, sidefx injects a tiny hidden HTML comment marker into outgoing bodies and checks both open and closed items through the GitHub REST API to recover the exact URL instead of creating a duplicate.
The stderr redaction bug that could have stranded pending writes
Hardening the CLI wrapper before launch turned up a failure mode I almost missed. When a wrapped command fails, sidefx scrubs secrets out of stderr before storing a short error line in SQLite.
If a failing child command echoed a malformed URL, like an invalid port number or broken IPv6 brackets, Python's built-in URL parser raised a ValueError right inside the redaction step. Because that happened right before finalizing the journal row, an uncaught redaction error could crash the wrapper and leave the action stranded in pending.
The fix was twofold: isolate URL redaction behind a safe fallback so malformed strings can never raise, and tighten the URL scanner with a negative lookbehind so long noisy error lines always scan in linear time instead of backtracking. A logging helper should never be able to wedge the durability layer it serves.
Ground-truth receipts and a real chaos suite
Because every write lives in SQLite, session summaries no longer rely on chat memory. Running the report command opens the journal in strict read-only mode and prints confirmed, reconciled, failed, and unresolved actions in Markdown, plain text, or JSON. A bundled Claude Code Stop hook stays completely silent when no external writes occurred and warns loudly if anything is still pending or unknown.
To test crash behavior for real instead of mocking every function call, sidefx ships with a self-contained chaos test suite. It spins up a local mock GitHub HTTP server, a real bare git repository with fault-injecting receive hooks, a subprocess stdio MCP server with an fsync-backed ledger, and four concurrent OS worker processes racing on the same action ID.
Across all six chaos scenarios (pre-commit crashes, post-commit response loss, concurrent duplicate dispatch, payload mutation on reused IDs, preflight policy denials, and mixed session receipts), it passes 6 of 6 with 0 duplicate remote writes and 100% receipt accuracy (17 of 17 checks) in about 13 seconds.
Manual resolution and wedged MCP servers
Not every external API has a built-in reconciler yet. Right now automatic read-only reconciliation covers git push and GitHub issues, pull requests, and comments. When an arbitrary MCP server or custom webhook times out, sidefx refuses to guess and leaves the action unknown. You or the agent inspect the remote system read-only and record the verdict with the resolve command (either landed with a reference URL, or not landed to re-open the retry).
Some local stdio MCP servers are single-threaded and hang permanently after a timeout. sidefx provides an opt-in restart-on-timeout flag that probes the server on the next request, terminates the process group if unresponsive, and replays the MCP initialize handshake transparently. It stays off by default so slow-but-healthy serial servers can finish in-flight work and reconcile cleanly.
Run the chaos suite or wrap your next push
You can watch the six fault-injection scenarios run locally without installing anything:
uvx sidefx eval --verboseTo start journaling shell writes and configuring preflight guardrails in a repository:
uv tool install sidefx
sidefx init
sidefx wrap -- git push origin HEAD
sidefx reportDrop-in MCP proxy snippets for Claude Code, Cursor, and Codex, plus the Claude Code plugin and agent skill, live in the GitHub repository.