passdrill
AI & LLM Engineering · AI Agents & Tool Use · Card 020/022 hard

An agent calls a `charge_customer` tool to process a one-time payment. The HTTP request to the payment provider actually succeeds and the charge goes through, but the response is lost to a network timeout before the agent's tool-calling code sees it. Reading this as a failure, the agent's loop retries the same charge_customer call with the same arguments. If the payment provider's API accepts a caller-supplied idempotency key tied to that specific transaction, and the tool is built to reuse the same key on a retry of the same logical action, what happens on the second attempt?

  1. The payment provider processes the charge a second time regardless of the key, since idempotency keys only affect logging and have no effect on whether the underlying charge is executed again
  2. The payment provider recognizes the repeated key as the same logical request and returns the original charge's result instead of executing a second, duplicate charge, preventing the customer from being billed twice for what the agent's retry logic mistakenly treated as a fresh action
  3. The retry is blocked entirely before it reaches the payment provider, because a repeated idempotency key causes the agent's own tool-calling code to refuse to send the request at all
  4. The idempotency key causes the payment provider to automatically refund the first charge and only keep the second one, treating the first attempt as invalid
Next card → Shuffle