passdrill
AI & LLM Engineering · Building with LLM APIs · Card 009/012 medium

An LLM-powered agent has a tool that charges a customer's payment method, and the agent's HTTP call to your backend times out after the charge has actually already been processed. The agent's retry logic then calls the same tool again with the same arguments. What design choice prevents this from resulting in a duplicate charge?

  1. Having the tool accept a unique idempotency key per logical operation, so the backend can recognize a retried call with the same key and return the original result instead of processing the charge a second time
  2. Increasing the model's `max_tokens` limit, so the agent has enough space to reason more carefully about whether a retry is safe before calling the tool again
  3. Lowering the model's `temperature` to 0, so the agent always generates the exact same tool call arguments and therefore never issues an unintended duplicate request
  4. Disabling the agent's ability to call tools more than once per conversation, so any repeated call is rejected outright regardless of what happened to the first one
Next card → Shuffle