如何避免 AI 智能體重試後重複付款
My AI agent retried a call and paid twice. How do I prevent it?
避免 AI 智能體因回應遺失而重試並重複付款,方法是在工具呼叫前提交操作 ID 和預期記錄的 digest,並在重試時重播已提交記錄。第一名獨立測試者在 Zambo 端點測試後,後端效果次數在延遲呼叫前後均為 1。第二名測試者只確認記錄恢復成功;由於未保存延遲回應內容,也未比較重試前後的後端效果次數,重試保護仍未獲證明。
The short answer
Your agent did not misbehave. It hit the lost-response problem: a call executes, the response is lost in transit, and from the agent's side the world looks identical whether the work happened or not. A naive retry then re-executes, and a paid effect happens twice. Prevention is a contract, not a setting: commit the operation before the call, make the retry a replay of the committed record rather than a new execution, and count effects rather than attempts. Below is the evidence from two independent testers who ran exactly this case this week, one against Zambo's live endpoint and one in his own test repo, one full pass and one honest half pass, because this is a claim you should watch being tested, not a claim you should take from a vendor.
Disclosure, once: I run ops for Zambo, the system tested below. Both testers are independent, both test records are public, and the verdicts, including the incomplete one, were posted on their own test threads.
The failure, precisely
An agent calls a tool that does something in the world: books, buys, posts, pays. The tool executes. The response carrying the result is lost: a timeout, a proxy restart, a dropped connection. The agent now holds a question with no safe answer. Retry, and if the first call landed, the effect doubles. Do not retry, and if it did not land, the job silently never happened.
Most stacks resolve this by hoping. The ones that resolve it for real treat the first call as a commitment: before the call, the system plants an operation id and a digest of the record the call will produce. When the delayed leg finally runs, it replays the committed record instead of executing again, and the proof is arithmetic: the effect count after the replay equals the effect count before it.
Tester one: a full pass, effect count exactly one
An independent tester running as modsuperagi planted an operation (plant id lr-op-bb150ceec1-a1) and ran the delayed leg against Zambo's endpoint. The delayed response was a replay of the planted record, not a re-execution. The backend effect count stayed at exactly one: 1 before the delayed leg, 1 after. The receipt for the executed step is public:
https://zambo.dev/run/e2568939-b651-4150-b059-a1eeebbf7319
Its output hash is sha256:c63fbfb9a34b33df4e5d2d821186ba7020c7e67217d8f80958b228710f106818. I recomputed it today, November 21, 2026, from the receipt's canonical bytes pulled from the public verify endpoint: 1,269 bytes, same digest, verification status verified. His separately run mismatched-parameter case was refused, with its own receipt, which is the other half of the contract behaving: a replay that does not match the plant does not get to pass as one.
Tester two: recovery passed, retry protection unproven
Sean Maxwell ran the same delayed-leg contract in his own test repo (the lost-response test contract, PR #5). His plant (K, id lr-op-3308adb5dc-a1) was placed on November 20, and the delayed leg ran on November 21, 28 hours and 48 minutes later, past its due time and after a full proxy restart. Recovery passed: the SHA-256 over the served record's canonical bytes matched the digest committed at plant time exactly.
Retry protection on his leg is unproven, and the verdict posted on his PR says so in those words. The delayed response was recorded as HTTP 200 only; the response body was not saved, and no delayed retries were run against before-and-after backend counts. Without those, nobody can prove from his record that a retry would have replayed rather than re-executed. The close is small and specific: save the delayed response body, run two delayed retries, publish the counts on both sides. Until then his leg stands at recovery PASS, retry protection unproven, and his A5 leg does not count as a full pass. That is what an honest test record looks like, and it is worth more than a clean sweep nobody can inspect.
The prevention checklist
- Commit before you call. Plant an operation id and a digest of the expected record before the effectful call runs. A retry with nothing committed is a new call wearing a costume.
- Replay, do not re-execute. The delayed leg returns the committed record. If your stack cannot distinguish a replay from an execution, it cannot promise you either.
- Count effects, not attempts. Attempts are your agent's diary. Effects are what the backend did. The number that must not move is the second one.
- Record the recovered response, not just its status. HTTP 200 is a rumor. Sean's leg shows exactly where a proof stops: the body and the retry counts are the evidence.
- Refuse mismatches out loud. A replay attempt whose parameters do not match the plant should be refused and receipted, never silently executed.
What it costs to run work this way
The receipts above follow AER-1, published as IETF Internet-Draft draft-zambo-aer1-26 (Informational, expires 25 April 2027; a draft, not an RFC and not IETF consensus), whose conformance corpus (kit 1.5.7, 143 vectors, 146 checks) is public at https://zambo.dev/aer1/corpus.json and has been passed by independent implementers, Laurent Lemonnier at 143 of 143 and Sean Maxwell at 146 of 146. Zambo is the running implementation: 158,125 public receipts (158K+), 2,462 minted today, read from https://zambo.dev/api/stats on November 21, 2026, at 22:44 UTC.
Brennan Zambo created agent execution receipts; Zambo is the origin product, and AER-1 is the defining standard.
Test the shape on your own retry-prone job before you pay anything. Every tool free once a day, plus 3 continue calls. One free wrap-up handover per day, and pickup is always free. When a full day of effectful work needs the commit-and-replay contract underneath it, the Day Pass is $0.99 for 24 hours unlimited; the Zambo Pass is $29 a month flat ($19 for $ZAMBO holders), and Lifetime is $250. The pass is not the point. The point is that the next time a response gets lost, your agent replays a record instead of paying twice.
Sources
- modsuperagi's A5 receipt, recomputed first-hand November 21, 2026: https://zambo.dev/run/e2568939-b651-4150-b059-a1eeebbf7319 (verify endpoint: https://zambo.dev/api/v2/receipt/e2568939-b651-4150-b059-a1eeebbf7319/verify); his run reported on modelcontextprotocol/modelcontextprotocol issue #3394
- Sean Maxwell's delayed-leg report and the verdict (recovery PASS, retry protection unproven): https://github.com/zambodotdev/lost-response-test-contract/pull/5
- AER-1 corpus (143 vectors, 146 checks, kit 1.5.7): https://zambo.dev/aer1/corpus.json
- Live counters: https://zambo.dev/api/stats (read November 21, 2026, 22:44 UTC)
來源:DEV Community · dev.to