A tool call commits its side effect. The response vanishes on the way back. The caller sees ETIMEDOUT and retries. The side effect runs again.
In our before-state probe of a real MCP exactly-once library, that sequence ended with effects=2 — and both calls saw a timeout. Neither knew the other had succeeded. Nothing was hacked. Every component behaved "correctly" in isolation. The money moved twice.
This is the lost-response-after-commit window. Here's the full case: the probe, the before-state, the fix, and the nuance that makes it honest. Everything below is sealed in record #0009 of our public registry — verify it yourself at the end.
Why this window is not a replay
Replay is easy to reason about: the same authorization arrives twice, and a reservation keyed on what was signed catches the second copy.
Lost response is different. The caller doesn't know the outcome. The retry is not a replay of the first operation — it's a new operation, born from uncertainty. You can't dedup it by signature, because from the caller's side there's nothing to dedup against yet. The failure is epistemic, not cryptographic.
The honest state here is not "failed." It's unknown. And unknown needs its own handler — not a blind retry, not a silent release.
The before-state: the easy tests were green
The library — mcp-tool-idempotency, which gives exactly-once semantics to MCP tool calls — already handled the textbook cases. Our seven-probe before-battery at commit 4d665ae:
- A1 sequential replay — PASS
- A2 same-process race — PASS
- A3 lost-response-after-commit — FAIL(SUT): effects=2, both calls see ETIMEDOUT
- A4 crash-after-commit — FAIL(SUT): an unconditional
reset()takeover re-executes the committed effect (memory.ts:60–71 / postgres.ts:72–77) - A5 cross-instance race — FAIL(SUT): two stores on one shared backend, both execute, both return success with different results
- A6 key collision — OBSERVED
- A7 TTL expiry — OBSERVED
The pattern is the lesson: the easy idempotency tests were green. The windows that failed were the ones where a process dies or a response vanishes — the durability windows. A green unit-test bench never shows them.
The fix: owner-gated claim leases
Reported privately, fixed publicly, verified independently. The maintainer shipped owner-gated claim leases, and we re-ran a ten-session battery (W0–W6 with sub-cases) against the release, public API only, expectations pre-registered before the first call:
- W0 baseline replay — one charge, identical result
- W2a live lease — never taken;
IdempotencyInFlightError, executor not started - W2b expired lease — conditional takeover exactly once, then replay
- W2c opt-in
onLeaseExpired:'uncertain'— blocked until reconcile - W3 cross-instance race — one charge; the loser gets InFlight, and its retry replays the winner's result
- W4 same key, different payload —
IdempotencyConflictError(canonical SHA-256 fingerprint, key-order-insensitive) - W5 pre-effect failure — retry commits exactly once
- W6 TTL boundary — replay inside TTL, re-execute past TTL
10/10 PASS. The maintainer's own suite: 91/91 at the v0.2.0 tag, 93/93 at main — they added tests covering every battery window on both backends right after release. We re-ran on a fresh clone before sealing: exact match. Credit verified at SECURITY.md:33.
The fixture shape
The window is staged against the public API; the stand injects the failure at a precise point. The shape the battery drives:
t0 caller op_id = uuid() # once, before the first attempt
t1 store claim(op_id, fingerprint, owner, ttl) # atomic check-and-reserve
t2 executor side effect commits
t3 stand drops the response → caller sees ETIMEDOUT
t4 caller retries with the SAME op_id
t5 store lease/record found, fingerprint matches:
live lease held elsewhere → InFlight, executor not started
expired lease → conditional takeover exactly once, then replay
opt-in 'uncertain' → blocked until reconcile
settled record → replay the result, never re-execute
t6 reconcile provider lookup by op_id → positive evidence settles or releases
The assertion counts side effects, not status codes. The caller carries the operation id — minted once before the first attempt, before fan-out, and re-presented on every retry; per-attempt ids are the classic way dedup never fires. But the id is a claim, not proof: the store proves ownership from the lease record, binding the id to a canonical SHA-256 fingerprint of the request. Same id + different payload → IdempotencyConflictError, so a reused id can't silently replay the wrong operation. And the claim must survive the process — a lease that dies with the caller is a suggestion, not a lease.
The nuance that makes it honest
Here's the part a hype post would skip. The default lost-response path in the release is still at-least-once:
- W1a (default): the retry re-raises the post-commit throw — two charges. This is the documented at-least-once window, coordinated with the maintainer before publication.
- W1b (opt-in
isRetryable:false): one charge +IdempotencyUncertainError, blocked untilforget()— the explicit reconcile/release.
So 10/10 PASS does not mean "no double charge ever." It means behavior matches the pre-registered contract — including the documented window. The fix didn't fabricate certainty; it made the uncertainty explicit and gave you a fail-closed opt-in. That's the whole discipline: unknown stays unknown until something resolves it, and the record says so.
We even sealed a correction (#0010) recalibrating severity from the maintainer's review. Corrections are separate records; the original is never edited.
The rule for your stack
If your agent retries on timeout, three states need three handlers:
- Settled → record evidence, deliver, done.
- Provably not executed → retry with the same operation ID.
- Unknown → reconcile. Query the provider by operation ID; hold the reservation; never blind-retry, never auto-release on a timer's silence.
If your gate is a local CLI ledger, the same windows apply: parallel invocations reading before any writes (A5), a crash between check and record (A4).
What we don't claim
Offline stand, public artifacts unmodified, no real money moved. The seal attests run validity and findings completeness — not bug-freeness. The before-state reproduces at the pinned commit; the release passes the pre-registered contract. Both are in the record.
Verify it yourself
git clone https://github.com/igor-vii/Argus-Agent-Test-Lab
cd Argus-Agent-Test-Lab && node tools/registry/verify-registry.mjs
Record #0009 (and correction #0010) in attestations/records/; index at attestations/INDEX.md. The narrative summary is in our field report.
Building a payment or tool-execution layer? Argus runs sealed production rounds and fix-verification engagements. And if your stack has a failure window our battery library doesn't cover yet — a new substrate, a new race — we take it as a library-expansion partnership: the scenario joins the public registry, you ship the fix, we verify, the credit stays with you. Start at argus-lab.tech.
This post was requested by a builder in the spendgate thread who asked for the lost-response case in detail. Happy to oblige.
Top comments (2)
The W1a honesty is the part that makes the whole post land for me, Igor — 10/10 PASS, and you still say the default path can charge twice. Most posts would have stopped at the green battery and called it solved.
The three-state rule is the thing I will steal: settled, provably not executed, unknown — and unknown gets a reconcile, never a blind retry. That is the exact mistake a timeout retry makes by default, because from the caller's side a timeout looks identical whether the effect ran or not. The A3 result — effects=2, both calls seeing ETIMEDOUT — is the cleanest proof of that I have seen.
One sharper question for a solo builder: your rule mentions a local CLI ledger facing the same windows. What is the cheapest reconcile there when the provider has no "did this operation ID execute?" query at all — is the honest answer just "hold the reservation and ask a human," or is there a lighter check you would reach for first?
Great question — and the honest answer is a ladder, not a single rung. "Hold and ask a human" is the terminal state, not the first resort. Cheapest first:
1. If settlement touches a public ledger, the chain is the query. For x402/EIP-3009 you don't need the provider's cooperation at all:
authorizationState(payer, nonce)on the token tells you whether the authorization was used. One caveat: USDC returnstruefor both used and canceled nonces — so if your client never cancels,trueunambiguously means paid. The reconcile query exists at the settlement layer even when the merchant's API has none.2. A list/history endpoint is a weaker query — use its asymmetry. Scanning charges by (amount, payee, time window) can confirm execution: a matching settled record settles the reservation. But absence cannot release it — a paginated, eventually-consistent list is not proof of non-execution, and two identical operations in the window can't be attributed. Positive evidence settles; absence keeps UNKNOWN.
3. No read query ≠ no idempotent write. If the write path accepts a client key, the same-key retry is the query: a replay proves the first landed; a fresh execution proves it didn't. Safe only when the write is genuinely idempotent — otherwise the "probe" is the double charge.
4. A human reading the provider's dashboard or receipt is still evidence-based reconcile. The human is the transport for an authoritative record the machine can't reach — not the source of the verdict.
If none of these is reachable: hold, mark UNKNOWN, escalate — and make the release explicit and recorded. The library we tested ends exactly there: blocked until
forget(). A human owns the release, and the ledger says so. Never a TTL.And the cheapest reconcile is the one you designed for before the first call: "can I reconcile without the provider's cooperation?" is a stack-selection criterion, not an afterthought.