Why 'Completed' Doesn't Mean Done: Verifying Order Creation After Timeouts & Retries
This article explains why an AI agent's 'completed' message can hide duplicate purchase orders after API timeouts, detailing how to verify actual creation status, implement idempotent retries with stable request IDs, distinguish cancellation from revocation, and test failure scenarios using concrete examples like REQ01 and PO8601.
A purchasing manager approves 60 bearings for warehouse #1. The agent calls the creation API, waits, and receives a timeout with a retry message. The second call returns a purchase order number and the agent announces "completed." However, the purchasing clerk finds two identical orders in the original system — the first request actually succeeded but its receipt was lost in transit.
Returned a PO Number — First Verify What Was Created
An interface returning "success" may only mean the request was received or a draft was saved. If business agreement requires formal submission, a draft does not satisfy that step. During integration, clarify the exact meaning of each return value; do not translate all of them as "purchase completed."
Continuing with the example: warehouse #1, product SKU6204, 60 units, supplier SUP01. The goal is a document in the original purchasing system whose key fields — product, warehouse, quantity, unit, supplier, and pricing basis — match the approval and whose state meets the agreed requirement.
After receiving a PO number, read that document to verify. If the trusted receipt from the original system already provides sufficient information, verification can rely on the interface contract without an extra query. The PO number must correspond to this specific request; finding a random order for 60 units does not prove the agent created it.
Assume verification finds PO8601. Inform the clerk of its actual state and the verification result. This does not prove the supplier has accepted the order, nor that the 60 bearings have arrived at the warehouse.
The clerk needs a verified document; a simple "success" response is not enough.
The PO number must match this request; details and state must match the approval and agreement. When the trusted receipt contains enough information, an extra query is not mandatory.
Timeout Only Means No Result Was Received
Between request sending, service acceptance, creation, and receipt return, any step can fail. The caller sees only a timeout and cannot know how far the target system progressed.
The agent must distinguish at least three cases: the document was created and verified; the original system explicitly rejected and confirmed no creation; or the state is still unknown. The third case should show "pending verification" and tell the clerk: "Request sent, creation unconfirmed, investigation in progress — do not submit again."
A single query that finds nothing does not prove non-creation. The queried replica may be stale, or the original request may still be queued. Check the interface contract: what does an empty result mean? Will the original request continue processing? Do not create another order just because a query returned nothing.
A previous article "Agent Errors Need More Than Retries: Unknown Side Effects, Idempotency, and Reconciliation" discussed this. Applied here, the key is to first acknowledge the original request and determine whether it generated a document. URL: https://mp.weixin.qq.com/s?__biz=MzY4ODQxNzY2NQ==&mid=2247484867&idx=1&sn=f144c44facdfb87c83ad6496e0107f60&scene=21#wechat_redirect
Timeout describes the caller not receiving a result; it does not determine whether the target system created the order. The diagram shows only one possible path.
Resending the Same Request — How to Avoid Duplicate Orders
Label this creation request REQ01. Before the first send, the calling program saves the ID, parameter version, and approval basis; later it records send attempts and receipts. Even after a restart, the program must recover this request — never let the model generate a new ID on the fly.
If the interface supports duplicate detection by this ID, and the first attempt already created PO8601, a subsequent REQ01 should return the original result or a query entry per the contract, not create a new order. This is what "idempotency" means here: repeated delivery of the same request does not cause duplicate execution.
The AWS Builders' Library article on idempotent APIs describes stable request IDs, server-side duplicate detection, and parameter conflict checking. URL: https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ When integrating with a purchasing system, still ask: does the actual creation program recognize this ID? How does it handle a duplicate request?
Also check a subtle failure: the document is saved but the deduplication record is not. On retry, the program may treat it as a first attempt. How the two are reliably saved together, or how their correspondence is recovered after a fault, requires guarantees from the creation side; the agent merely logging "called" does not solve this.
The scope of the request ID — which account, which operation type — and the retention period for deduplication records must be documented. While still within the agreed scope and retry window, reuse REQ01 and the original parameters. Switching to a new ID or resending after the retention period expires risks creating another order.
If the same REQ01 first specifies 60 units but later changes to 100, that is not a normal retry. The interface should reject parameter conflicts per the contract; if the business truly needs a quantity change, first verify the original request, then follow the change and re-approval process.
Idempotency for a single request does not prevent two purchasers from submitting two legitimate requests for the same need. That duplicate business scenario requires separate business checks.
Request, parameters, and creation-side guarantees together enable retry to recognize the same result; current permissions and valid approval must still be checked.
Handle According to What You Actually Find
What Was Found: Document matches this request; content and state meet agreement. Next Action: Record as created and verified; hand to clerk for follow-up. Additional Notes: Retain mapping of request, approval, and document.
What Was Found: Trusted rejection confirming no creation. Next Action: Correct per reason or terminate. Additional Notes: When parameters change, check if re-approval is needed.
What Was Found: Only confirmed entry into queue. Next Action: Track the original request. Additional Notes: Do not issue another creation request.
What Was Found: Timeout, but interface guarantees same request won't create duplicates. Next Action: Continue querying per contract, or retry with original ID and parameters. Additional Notes: Retries that may trigger creation must still verify current permissions and approval.
What Was Found: Cannot reliably verify, and cannot guarantee retry won't duplicate. Next Action: Pause automatic submission; assign a responsible person to investigate. Additional Notes: Still mark as pending verification — do not record as "not created".
What Was Found: Document created but details mismatch. Next Action: Stop further processing; correct per original process. Additional Notes: Verify if modification or revocation is allowed.
How often to query, how long to auto-query, and who takes over after the deadline must be agreed in advance to prevent the tool and upper workflow from endlessly retrying independently.
Exhausting retry attempts only means automatic attempts stop; it does not prove the purchase order was not created.
If approval is withdrawn or permissions change, first halt retries that might still create. Previously sent requests must still be verified by authorized services or personnel; do not treat "no longer allowed to create" as proof that nothing happened earlier. Even if a later retry is rejected, that only means this attempt was not permitted — it cannot prove the first attempt didn't create.
Late-arriving messages must also be distinguished. If creation was already verified and a timeout message from an earlier call arrives later, do not flip the result to failure. If the original system later formally revokes the document, update the current state. Judgment order depends on the original system's record versions, event sequence, or a fresh query — not on which message reaches the agent last.
The ontology should clearly express the relationships among request, approval, and document to support traceability. When to query, whether to retry, and how to update progress after receiving a message are still executed by the processing program according to these agreements.
Progress updates follow trusted business evidence; when result is unknown, continue querying the original request. Old timeout messages do not overwrite verified results; formal revocation by the original system still updates current state.
Canceling a Task Is Not Revoking a Document
When a clerk clicks cancel, the original system may continue processing an already received request. The application should first stop new submissions and creation retries, then verify previously sent requests. If a document was already generated and business requires revocation, handle it separately per the original system's allowed methods.
Revocation requires appropriate permissions and approval, and must check whether the document's current state allows revocation. If the supplier has already accepted or the document triggered downstream processing, direct return may not be possible. Microsoft's Compensating Transaction pattern also notes such operations depend on business conditions, may fail, and may require manual intervention. URL: https://learn.microsoft.com/en-us/azure/architecture/patterns/compensating-transaction A sent revocation request whose result is unconfirmed must not be displayed as "revoked."
The initial duplicate-order situation cannot be resolved by simply deleting one. First verify which request generated each document and whether they have flowed downstream, then hand to authorized personnel per the original process. Handover must include the original request, approval, receipts, query records, and outstanding questions so the next person knows where to continue.
Cancellation restricts future actions; modification or revocation of an already created document follows the original process with verification. Unconfirmed revocation must not be shown as revoked.
Deliberately Drop a Receipt and Verify Again
In an approved test environment, first create an order normally and verify its number, details, and state. Then deliberately drop the success receipt or delay query visibility to see if the agent creates a duplicate.
Also test: same request arriving simultaneously, restart during processing, reusing the ID but changing quantity, and deduplication window expiring while the result is still unclear. Checkpoints are: can it recognize the original order? Does it create duplicates? Are parameter conflicts rejected? When verification fails, does it stop automatic submission and escalate to a human?
Cancellation with the original request still processing, approval withdrawn before the request yields a result, and old timeout messages arriving after a success result should all be test cases. When a document is created and verified but only the notification failed, simply resend the notification.
Tests must examine both the agent's messages and the target system's actual document count, details, and state. Displaying "no duplicates" while two orders exist is still a failure.
Recovery tests check both the agent's text and what actually happened in the target system; the diagram lists items to record, not passed test results.
Summary
The extra 60-unit purchase order at the beginning arose because the first result was never clarified, and the agent retried without confirming whether a retry could avoid duplicate creation.
The agent should tell the clerk which document was created and what was verified; if still unclear, explain who is investigating. The clerk can then track the order or wait for the result without guessing what "completed" means.
These checks target a single creation action. Whether the entire ontology pilot is sufficient, and how model, data, and business outcomes should be validated together, will be discussed in the next article.
References
AWS Builders' Library, Making retries safe with idempotent APIs . Used to illustrate request identifiers, server-side duplicate detection, and parameter conflict design; does not imply the target purchasing system supports these capabilities. URL: https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/
Microsoft Learn, Compensating Transaction pattern . Used to illustrate that compensation depends on business conditions, may fail, and requires handling; the purchasing verification and exception handling table was designed by the author. URL: https://learn.microsoft.com/en-us/azure/architecture/patterns/compensating-transaction
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
