The Retry Button Can Spend Twice
When the answer disappears, repeating the action is a new decision.
Read the full white paper PDF · 14 pages ↓Keep retries attached to one durable logical action; an unknown outcome needs reconciliation or a verified idempotency contract, not a fresh commitment.
The most dangerous word on a failed purchase screen can be again.
Imagine an agent placing an order. The service accepts it and creates the order. The connection disappears before the response arrives. The agent sees a failed tool call; the supplier has a real commitment. A helpful assistant that starts a fresh purchase can turn a communication failure into a second order.
This is a hypothetical failure mechanism, not a reported customer incident. Conventional software can make the same mistake. Agents make it especially important to distinguish recovering knowledge of an existing action from creating another action that resembles it.
A timeout must not become permission to repeat a consequential action under a new identity. Reliable recovery needs a durable logical action, an understood idempotency contract and a way to reconcile uncertain outcomes.
A timeout is missing knowledge
HTTP semantics defines idempotency through the intended effect of repeating a request, not through identical response messages. The inspected RFC 9110 source says a client should not automatically retry a non-idempotent method unless it knows the semantics are idempotent or can detect that the original request was never applied. [1]
A connection timeout does not establish either fact. It says the caller did not obtain a timely answer. The server may have done nothing, completed the action, or reached an intermediate state.
Adding an Idempotency-Key header is useful only when the server implements an appropriate contract. The inspected IETF HTTPAPI document is a working draft, not a published RFC. It says a general client cannot assume a server will honor the key without prior knowledge, and that the resource should document its behavior, including expiration. [2]
The question is not merely whether the request contains a UUID. It is what the server recognizes as the same operation, in which scope, for how long, and under which concurrency and validation rules.
The action and the answer can part company.
A hypothetical lost-response sequence explains why a caller’s timeout does not establish that nothing happened.
Effect commits
The external operation may already exist.
Response is lost
Communication fails after the possible side effect.
Outcome unknown
Recover the original result before creating another commitment.
Illustrative mechanism, not a reported customer incident. HTTP retry semantics depend on the intended effect and the operation’s actual contract.
Keep the intention stable while attempts change
A logical action names the user's intended commitment: this order, for this account, with these terms. A delivery attempt is one effort to communicate it. Attempts can have different timestamps and transport identifiers while still belonging to the same action.
Persist the action ID and downstream key before dispatch. On restart, recover that record. Generating a fresh key after every exception can ask a perfectly functioning server to perform several distinct operations.
Hashing the entire request body is not automatically better. A changed trace timestamp can produce a new identity. Hashing too little can collapse independent purchases of the same amount. The application must define business identity deliberately.
The browser matters too. If each repeated click creates a new action ID, the backend can deduplicate every request correctly and still create two orders. The interface must distinguish resuming an unfinished action from intentionally starting another.
Bind the key to scope and payload
A tenant's key must not retrieve another tenant's result. Creating and canceling an order must not share an outcome merely because their key strings match. Scope the record to the relevant account and operation as well as the key.
Then reject changed consequential terms under an existing identity. A 2,600-unit request should not silently inherit the response to a 2,500-unit request. The HTTPAPI draft describes payload fingerprints and recommends distinct handling for changed payloads and requests still in progress. Those are draft recommendations; real APIs may expose different contracts and status codes. [2]
Powertools for AWS Lambda separates selecting an idempotency key from validating additional payload fields through payload_validation_jmespath. Its documentation and persistence implementation show why that configuration matters: identifying a duplicate and detecting changed terms are different jobs. [3][5]
The fingerprint must include the fields that change the effect, such as amount, currency and destination. Canonicalization should eliminate irrelevant differences without erasing meaningful ones. The accompanying fixture uses sorted JSON and fictional integer units, not a universal currency or schema-normalization solution.
A key needs an envelope.
Duplicate detection requires a stable logical action, the right namespace and validation of the terms that change its effect.
Scope
Tenant, provider account and operation define the namespace.
Identity
Repeated attempts keep the same persisted action and key.
Payload
Reject consequential changes under the existing identity.
Original application design. Fingerprint coverage and key scope must match the chosen service’s documented behavior.
Expiration changes the promise
Three clocks often get confused: how long the caller waits, how long a worker owns an in-progress action, and how long a service remembers a key. None alone says the external effect has become impossible.
The captured Powertools documentation describes a configurable default idempotency expiration of 3,600 seconds. After expiration, the same payload can be processed again. It also describes in-progress expiry for timed-out Lambda invocations. These are documented package behaviors, not universal rules for APIs. [3]
A local lock expiring does not reverse a remote purchase. If retries or manual recovery can outlast duplicate suppression, the application needs a durable business record or authoritative reconciliation. A larger TTL can reduce the gap; it does not create an indefinite exactly-once guarantee.
A decorator does not own the remote transaction
The inspected Powertools handler saves an in-progress record before executing a function. It can return stored output for completed work and reject overlapping execution. In the captured implementation, an exception from the wrapped function leads to an attempt to delete its idempotency record, allowing later execution. [4]
That can be appropriate. But if the function created an external order before raising an exception, the wrapper cannot infer the supplier's state. The function still needs a safe relationship with the external side effect. A library coordinating local calls cannot automatically make two systems one atomic transaction.
Reconciliation should inspect the original operation. The captured Stripe OpenAPI contract, version 2026-09-30.endive, separately describes creating, retrieving and confirming PaymentIntents, with multiple possible confirmation outcomes. It illustrates why an object identity and its workflow state matter. It does not establish every Stripe key-retention or retry guarantee, and this article makes none of those broader claims. [6]
A missing lookup result is not always proof that nothing happened. Establish what the actual provider's lookup, consistency and retention contract permits before using absence as permission to try again.
Lose the answer on purpose
The example in reference 7 simulates an application and external service using two local SQLite files. Download it and run python3 example.py. It runs assertions and writes result.json. There are no network, model, payment or provider calls. [7]
The fake service commits an effect and then loses the response. The application records unknown. After reopening the application object, ten repeated submissions leave the effect count at one. A changed amount under the same action is rejected.
Reconciliation finds the matching receipt and resolves the action to succeeded. A late submission returns that durable result, even after the fake service's response cache would have expired. Thirty concurrent submissions of another logical action produce one effect. A different tenant remains a separate scope.
A second experiment deliberately relies only on a sixty-unit cache window. The same key at time one returns the original response. At time sixty-one it creates a second effect. The key stayed the same; the promise expired. This invented service behavior is not attributed to Stripe or AWS.
The key stayed. The promise expired.
A durable application result and a deliberately expiring cache produce different outcomes in separate fixture cases.
Durable action record
Lost response, ten repeats, reconciliation and late replay.
Cache before expiry
Same key at time 1 reuses a response stored at time 0.
Cache after expiry
Same key at time 61 becomes new work after a 60-unit window.
Fictional service contract and arbitrary time units. Not Stripe or AWS behavior; no real payment, model or provider calls.
The limits matter. The fake service retains searchable authoritative receipts indefinitely. The client conservatively leaves a missing receipt unresolved. The example tests local databases and finite cases, not distributed failover or universal exactly-once delivery. Real systems must solve both duplicate prevention and eventual progress under their actual contracts.
Make recovery honest
Never retrying is not a useful product strategy. Clear idempotency contracts enable bounded automated recovery. Keep attempts attached to the same action, assign retry responsibility to a defined layer, respect retention, and use backoff where appropriate. Spacing requests reduces load; it does not make an unsafe operation idempotent.
Give unresolved work an owner and a visible state. A user should see that the result is being checked, rather than being invited to create a fresh commitment. For spending, retain any associated reservation until the outcome is understood.
Before release, test the case where the effect succeeds and the answer disappears. Restart, repeat, change a consequential field, overlap requests and cross the retention window. Count effects and inspect receipts. The first successful call proves the service can do the work. The second attempt reveals whether the application understands what it already asked for. The full white paper develops the recovery design, source boundaries and executable counterexample.
Questions worth asking.
Does a timeout mean the payment or order failed?
No. It establishes that the caller did not obtain a timely answer. The remote action might have succeeded, failed before taking effect or remained in progress. Recovery needs evidence about the original operation or a verified contract that makes repeating it safe. [1][7]
Should I generate a new idempotency key for every retry?
Not for another delivery attempt of the same logical action. Preserve the original action identity and downstream key under the actual service contract. A genuinely new operation needs a new identity; changed consequential terms under an old identity should be handled as a conflict, not silently accepted. [2][3]
Can a cached result prevent duplicates forever?
Only within the guarantees of the relevant system. The inspected Powertools documentation describes configurable expiration, after which the same payload can be processed again. The local cache-only counterexample deliberately produces a second effect after its invented window expires. It is not a claim about Stripe retention. [3][7]
Does an idempotency decorator make every external API call safe?
No. It can coordinate repeated function calls within its persistence boundary. If a function causes a remote effect and then raises, local exception handling does not establish the remote outcome. The integration still needs an appropriate downstream contract and recovery strategy. [4]
What does the downloadable example actually demonstrate?
Under an invented local service contract, one lost-response action stays at one effect through ten repeated submissions, restart, reconciliation and late replay. Thirty concurrent submissions of another action produce one effect; payload changes are rejected. It uses Python and SQLite, no real payments, and does not prove distributed exactly-once delivery or automatic progress for every unknown outcome. [7]
Sources & method.
Inspected exact official repository snapshots for RFC 9110, the HTTPAPI Idempotency-Key working draft, Powertools for AWS Lambda Python documentation and implementation, and Stripe OpenAPI version 2026-09-30.endive. The draft is not represented as a published RFC. A Python standard-library fixture uses two local SQLite files and an invented service contract to test response loss, scope, payload conflict, concurrent submission and cache expiry. No network, provider, model or payment calls were made by the fixture. Measured results do not establish any real provider’s retention, exactly-once guarantees or incident rate.
- RFC 9110: HTTP Semantics, idempotent methods IETF HTTP Working Group · 2026-11-16 · Primary standard source
Inspected section idempotent.methods in the official RFC source. Supports intended-effect definition and cautions on automatic retries of non-idempotent methods. RFC publication is June 2022; capture date shown separately. Exact inspected path: rfc9110.xml. Commit bde37f634681bd5462568b73aa722af9c9a3ef5e. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - The Idempotency-Key HTTP Header Field, working draft IETF HTTPAPI Working Group · 2026-11-16 · Primary Internet-Draft source
Inspected key uniqueness, optional fingerprint, client/server responsibilities, expiry documentation, concurrent requests and error handling. This is a mutable working draft pinned to one commit, not a published RFC or evidence that every server honors the header. Exact inspected path: draft-ietf-httpapi-idempotency-key-header.md. Commit 1ba3ab05879772d3492cb07febcd70b01a9be1df. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - Powertools for AWS Lambda Python: Idempotency AWS Powertools · 2026-11-16 · Primary library documentation
Inspected event key and payload validation configuration, concurrency, default 3600-second expiration, in-progress timeout behavior and exception handling. No deployment against AWS was performed. Exact inspected path: docs/utilities/idempotency.md. Commit 379929b3c8a79852ab4c482e9cfc53020107ebe7. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - Powertools idempotency handler implementation AWS Powertools · 2026-11-16 · Primary implementation source
Inspected save_inprogress before function execution, in-progress detection, stored-response return, handler-exception record deletion and success-response persistence. Claims refer to this captured implementation; it cannot prove a remote side effect did not occur. Exact inspected path: aws_lambda_powertools/utilities/idempotency/base.py. Commit 379929b3c8a79852ab4c482e9cfc53020107ebe7. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - Powertools idempotency persistence base implementation AWS Powertools · 2026-11-16 · Primary implementation source
Inspected configuration of event_key_jmespath and conditional enabling of payload_validation_jmespath. Used to distinguish identity selection from additional consequential-input validation. Exact inspected path: aws_lambda_powertools/utilities/idempotency/persistence/base.py. Commit 379929b3c8a79852ab4c482e9cfc53020107ebe7. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - Stripe OpenAPI contract, version 2026-09-30.endive Stripe · 2026-11-16 · Primary API specification
Inspected /v1/payment_intents creation, /v1/payment_intents/{intent} retrieval and /confirm descriptions. Used only for operation/object/state distinctions. No general Stripe idempotency retention, guaranteed key lookup, customer loss or live endpoint behavior is asserted. Exact inspected path: openapi/spec3.json. Commit a045100cf4af0acb548cb9c6f236bb117f83458f. Reference date is capture date, not original publication date. Original bytes and SHA-256 preserved in the source receipt.
Accessed copy ↗ - Reproducible local fixture: example.py Kymata Labs Research · 2026-11-16 · Original executable illustration
Python standard library only. Run python3 example.py to perform the assertions and write result.json. Local fictional scenario; no network, provider, model or payment calls. The publication reports the measured fixture result, not a production benchmark.
The full argument.
Yours to keep.
The developed analysis, evidence, counterarguments and practical framework, in one carefully designed white paper.
14 pages · 3 figures · 7 references · PDFDownload the white paper Free to read. No signup.