Give one intended action one stable request key, and make repeated attempts return the recorded result for that key. If the first attempt may have succeeded but its reply was lost, check the saved state before sending a fresh action. A retry is not a new business instruction.
This article helps an operations owner specify an automation that creates internal work items. It is not production payment code or a guarantee of “exactly once” execution across every connected service. The seven attempts below are fictional; the ledger is a worked specification to discuss and test with the implementer.
A timeout leaves an unanswered question
Imagine an assistant prepares a maintenance description and the workflow asks a task system to create a record. The connection times out. You do not yet know whether the task system created the record. Sending the same text again with a new identity could create another item.
AWS’s Builders’ Library explains this uncertainty and the use of caller-provided request identifiers for idempotent operations. It also discusses atomic recording, late requests and the problem of reusing a request identifier with different parameters. S1 Actual behaviour depends on the destination API’s contract; the following controls must be implemented and tested, not merely written into an AI prompt.
Define what makes this action the same action
For the fictional workflow, the intended action is “create a work item from source record D17, revision 1, in workspace OPS”. The workflow assigns key K1 before the first attempt and retains the approved payload fingerprint F1. K1 and F1 are short teaching labels, not recommended production key or hashing formats.
Use the same key and unchanged approved payload for a retry. A later approved revision is a new action with its own key. Similar text alone does not establish identical intent: two people can legitimately request similar work. Equally, an AI rewriting the description on each retry must not silently transform one action into a different payload.
| Attempt and intent | Key / payload | Recorded outcome |
|---|---|---|
| 1: D17 revision 1 | K1 / F1 | Create W101 |
| 2: retry attempt 1 | K1 / F1 | Return W101; no new item |
| 3: D18 revision 1 | K2 / F2 | Create W102 |
| 4: delayed retry of D17 | K1 / F1 | Return W101; no new item |
| 5: changed D18 payload | K2 / F3 | Conflict; no change |
| 6: approved D17 revision 2 | K3 / F4 | Create W103 |
| 7: retry attempt 6 | K3 / F4 | Return W103; no new item |
Seven attempts produce three new work items, three replayed results and one rejected conflict. The conflict is not automatically repaired by generating another key: someone must first decide whether the changed payload is an authorised new action. Otherwise the recovery logic would defeat the duplicate protection.
Make the ledger and the action agree
The implementer must address two requests arriving together. A separate “does this key exist?” check followed by an unprotected create can allow both callers through. For a local database operation, recording the unique key, action and result needs an atomic design. AWS describes this all-or-nothing requirement for its idempotency example. S1 A spreadsheet log added after creation does not establish the same property.
The business record should retain the key’s scope, source identity and revision, approved payload reference, processing status, destination record ID, and last outcome. Keep access and retention proportionate to the data. A payload fingerprint is a consistency aid, not permission to store confidential content carelessly.
Treat uncertain and expired cases differently
If a destination action and your local ledger cannot be committed together, there can still be a gap between them. Use the destination’s supported idempotency mechanism where available, and reconcile by its retained request or record ID. If neither a reliable query nor an idempotency contract is available, hold the case for investigation instead of claiming that blind retries are safe.
Check how long the destination retains keys, whether keys are scoped per account or operation, how in-progress requests behave, and what happens after expiry. S1 Do not assume a key lasts forever or that a timed-out request failed. Email, payment and other external side effects require their own reviewed design; a local work-item ledger does not control them automatically.
Before enabling retries, test a normal replay, simultaneous attempts, a changed payload, a delayed response and a retry after the documented retention window. Save observed destination IDs. Accept the workflow only when the real results match the agreed behaviour; this fictional ledger supplies expected outcomes, not evidence that your integration has passed.
Prepared with AI-assisted research and drafting. Reviewed by: QSE Advisory experts.
Sources
This article is general information. Verify current requirements and seek qualified advice for your specific circumstances.
Reviewed by QSE Advisory experts
Every article is researched, sourced and checked before publishing.
Editorial standards →