Your AI Workflow Needs an Idempotency Boundary
Tool-using agents make retries feel natural. The model sees an ambiguous tool result and tries again. That is reasonable for a search query and dangerous for a payment, account creation, or irreversible change.
A retry after timeout cannot tell whether the first attempt was committed. The correct boundary lives in the tool service, not in a prompt telling the model to be careful.
For commands with side effects, the caller supplies a stable operation ID. The tool validates the command, claims that ID atomically, and returns the stored outcome on repeat requests. The agent can retry the exact same operation without performing it twice. A changed request body with the same ID must fail explicitly.
Agent --> tool call + operation ID
|
atomic lookup
/ \
new existing
| |
execute return result
|
persist result
There is another subtlety: the agent may generate a different operation ID on each retry. The orchestration layer should assign the identity for a logical business action and reuse it across tool attempts. Otherwise every retry is unique by construction.
Idempotency is not an AI-specific pattern. What changed is that model-driven workflows make repeated and uncertain calls much more common. The old distributed-systems rules still apply.
Top comments (0)