Tool design · 2026-08-26

Your sendPayment tool sometimes times out.

The agent retries, and occasionally a customer is charged twice.

  1. AMake the call idempotent - accept an idempotency key so retries can’t double-charge
  2. BTell the agent never to retry a payment, and let the customer contact support if a charge silently fails to go through
  3. CAdd a longer timeout and hope it stops happening
  4. 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 this topic

More on Way of the Agent

Real situations from building agents - with the answer and why.

Solve a new one every day on the Path