Tool retry idempotency: recover safely after a timeout
A tool timeout does not prove that an action failed to execute. Use stable idempotency keys, downstream API contracts, and result reconciliation to recover without duplicating tickets or messages.

Tool retry idempotency starts with separating no response from no execution
Tool retry idempotency means that repeated attempts to carry out the same business intent produce no additional effects. After a tool call times out, first distinguish between confirmed non-execution, completion, and an unknown outcome. Then decide whether to retry under the downstream API's idempotency contract. Telling a model not to repeat an action, or simply marking an HTTP timeout as a failure, cannot replace that decision.
Consider an assistant calling a tool to create a support ticket. The server saves the ticket, but the connection drops while the response is being returned. The assistant sees only a timeout; another call could create a second ticket. This is an illustrative example devised for this article, not our test result or an incident report about a particular product.
Microsoft's Retry pattern explicitly warns that a service may have processed a request without returning its response. Retrying a non-idempotent operation can therefore cause additional side effects. Asking how far the business operation progressed is more useful than immediately increasing the retry count.
If the problem concerns excessive request frequency or RPM and TPM limits, start with the AI API 429 troubleshooting guide. This article addresses a different layer: how to recover without duplicating a write when the request may already have executed.
An idempotency key should identify one intent, not a set of identical parameters
An idempotency key lets the receiving service recognize attempts to carry out the same business request. The initial request, retries after a timeout, and attempts resumed after process recovery should use the original key. If the user actually wants another ticket with identical contents, that is a new intent and needs a new identifier.
That is why identical parameters alone are insufficient for deduplication. The AWS Builders' Library uses the example of creating identical cloud instances: the same parameters might indicate a retry, or a user who really wants two instances. AWS uses a caller-provided request identifier to express this distinction.
An application can generate an operation identifier when the user's intent is confirmed, then store the target, action type, a summary of key parameters, and the external result identifier. The execution system should manage this identifier. Do not let the model choose a fresh key on every retry, and do not collapse all actions under a single conversation identifier. One conversation can contain several legitimate creation requests.
The server must actually recognize the key. Merely recording it in logs, or adding a request header unsupported by the downstream service, does not provide deduplication. At minimum, the receiver needs to distinguish an initial request, a retry of the same request, and a request using the same key with different parameters. The last case should produce a conflict under the API contract, rather than silently becoming a new write.
After a timeout, recover according to three possible outcomes
The following recovery order is synthesized from official documentation. Exact response codes and state names depend on the target service.
- Confirmed non-execution. For example, reliable evidence shows that local validation rejected the request before dispatch. Fix the cause first. If the failure is transient and the operation allows retries, try again within the retry budget. A vague connection error alone does not prove that the request never arrived.
- Completed. Find the ticket, message, or resource associated with the operation identifier, save the original result, and continue. The repair needed here is to the local task record; it is not another creation attempt.
- Unknown outcome. The request might still be processing, or a query might not yet reflect its latest state. First use the target system's status lookup, idempotent replay, or reconciliation mechanism. Without an appropriate guarantee, leave this write pending reconciliation and avoid submitting it again.
A failed lookup is particularly easy to misinterpret. A query that does not find a resource could reflect a read delay or an original request that has not yet finished. Only a service contract, request status, or other reliable evidence that excludes these possibilities can establish that the original action had no effect. Queries also need a time limit; recovery should not poll indefinitely.
Temporal's Activity documentation describes a similar boundary: work may finish, but the worker can crash before reporting completion, allowing the Activity to execute again. A workflow system recording one completion does not mean that the external business action ran only once. Callers still need to design idempotent business operations.
What should you check when an API claims idempotency support?
Do not apply one API's rules to every tool. Before integration, document the following points in the tool specification and execution-layer configuration.
- Scope. Which endpoints, methods, and parameters support idempotency? Google Cloud Storage's retry strategy classifies operations as always idempotent, conditionally idempotent, or non-idempotent. Some updates require a version or precondition. An operation being called an update is not sufficient reason to retry it automatically.
- Key lifetime. How long is the key retained, and what happens if it is reused after expiry? As of 2026-11-02, the Stripe API documentation states that API v1 idempotency keys can be removed after they are at least 24 hours old. Reusing a key after it has been removed creates a new request. This is not a permanent deduplication guarantee.
- Failure-response semantics. Stripe API v1 saves the status code and response body once endpoint execution begins, including 500 errors. Retrying with the same key may return the original error. The documentation specifies different recovery behavior for API v2. Changing to a new key is not a general troubleshooting method: it could trigger the business action again.
- Concurrency and changed parameters. How does the service handle simultaneous requests with the same key? Will it reject changed parameters under that key? A local check followed by execution still has a race in which two requests can pass the check together. You need actual constraints at the receiver, not merely an ordering of client-side checks.
- Protection boundaries. Does protection survive a process restart, a switch between instances, or a lost response after a downstream call? Records in local memory cannot automatically protect another machine, or replace the downstream service's business contract.
Structured outputs can help a model supply fields correctly, but do not automatically make a creation operation idempotent. The guide to structured outputs and tool calling explains their complementary roles: format constraints govern the shape of parameters, while the execution system governs business effects.
How can you test for duplicate execution before release?
One successful response on the normal path does not establish reliable retries. The following checklist is synthesized for this article. Run it in a controlled test environment or against a mock service; do not inject faults involving real recipients or real bills.
- Send repeated requests with the same key and parameters. Confirm that only one intended business effect occurs and that attempts can be linked to the original result.
- Send requests with the same key and different parameters. Confirm that conflicts are rejected under the contract rather than silently creating a second resource.
- Send concurrent requests with the same key. Confirm that protection works under concurrency, not only for sequential calls.
- Drop the connection after the business operation commits but before its response returns. Check that recovery reuses the original result or enters reconciliation, rather than blindly replaying the action.
- Simulate a delayed query result. Confirm that one not-found response does not immediately trigger a new creation attempt.
- Restart the process or switch instances and check that the records remain available. Also verify behavior after the retention period expires.
Check whether the SDK, tool adapter, and agent each perform retries. Google's documentation lists unnecessarily layered retries as an anti-pattern; Microsoft also recommends managing retries at the layer with the full context. Configure retry count, total duration, and delay together, rather than letting each layer assume it is merely trying a few more times.
At minimum, records should connect the business operation, each attempt, the final resource, and the recovery decision. Avoid sensitive information in keys, and do not log credentials or complete private requests. Troubleshooting requires traceability, not retention of every piece of raw data.
Where should automation stop if the downstream service lacks idempotency?
First check whether existing resource identifiers, version conditions, or business uniqueness constraints can make the operation safe to repeat. If none are available and the write outcome cannot be established, hold only the operation that risks duplication for reconciliation or manual review. Unrelated read-only queries do not need to stop as well.
Breaking a large tool into smaller, verifiable steps can also help. Save the resource identifier after creation, then resume only the relevant step if later formatting, field updates, or reads fail. Temporal notes that failure in a later step of a multi-step Activity can cause the whole Activity to run again. Appropriate decomposition can narrow the retry scope, but cannot eliminate a lost write response within an individual step.
The acceptance criterion is how many business effects one intent produces, rather than whether the model eventually reports success. Connect the business identifier, idempotency contract, and recovery path for unknown outcomes before enabling automatic agent retries. That provides a defined reliability boundary.
Further reading
This article reorganizes official contracts from different platforms into a recovery decision process and acceptance checklist for agent tools. It is not a single implementation guide for one service, and no live API experiments were performed.