Your sendPayment tool sometimes times out.
The agent retries, and occasionally a customer is charged twice.
- AMake the call idempotent - accept an idempotency key so retries can’t double-charge
- BTell the agent never to retry a payment, and let the customer contact support if a charge silently fails to go through
- CAdd a longer timeout and hope it stops happening
- DLog the duplicates and refund them later
Answer: A
Make the call idempotent - accept an idempotency key so retries can’t double-charge
Why
Side-effecting tools must be safe to retry. An idempotency key makes a repeated call resolve to the same single effect, so timeouts and retries can’t duplicate work.
More on Way of the Agent
- Course programThe first three modules are free: start in the browser or the app, no card needed.
- Library: guides, skills and promptsReady prompt templates, grouped into collections.
- AI ChroniclesSourced stories from the history of AI.
- ConceptsPlain-language explainers of agent engineering.
- Learn AI agentsApps and courses for learning AI agents, compared honestly.
Real situations from building agents - with the answer and why.
Solve a new one every day on the Path