AI · Agents · Engineering · Idempotency

Your Agent Retried a Timed-Out Tool Call. It Just Charged the Customer Twice.

20 November 2026 · Devectra

The failure mode nobody notices until it's expensive

An agent calls a tool to send a confirmation email. The request goes out, the network stalls, and the agent's runtime times out waiting for a response. From the agent's point of view, the call failed, so it retries. The email goes out a second time. Or it's not an email — it's a charge, a ticket creation, a row inserted into a billing table, a Slack message to a client. The pattern is the same: a tool call that has a real-world side effect gets retried, and the side effect happens twice.

This isn't a hypothetical edge case. It's the default behavior of almost every agent framework in production right now, because almost none of them guarantee that a tool call executes exactly once. They guarantee it executes at least once — which is a very different promise, and one most people don't notice they've accepted.

Why a timeout doesn't tell you what you think it tells you

When a tool call times out, the only thing you actually know is that a response didn't arrive in time. You don't know whether the underlying action never started, failed partway through, or completed successfully and the response was lost on the way back. All three look identical from the caller's side. An agent that retries on timeout is making a bet that it was in the first state. When it's actually in the third, the retry duplicates a side effect that already happened.

This is a known problem in distributed systems — it's why payment APIs like Stripe's have shipped idempotency keys for over a decade. What's different with agents is that the retry decision now sits behind a layer of model reasoning instead of a fixed piece of infrastructure code. The model doesn't "see" a timeout and reach for an idempotency key; it sees a failed step and decides, in natural language, to try again. Sometimes it rephrases the call slightly on retry — different wording, reordered arguments, a slightly different summary passed to the tool — which breaks the simplest fix (hashing the exact request and refusing to repeat an identical one) before you've even deployed it.

It also compounds across layers

Retries don't happen once. The model's own inference step can retry a malformed response. The agent loop can retry a failed tool call. The underlying SDK can retry a failed HTTP request. The orchestration framework running the whole thing can retry a failed step in its graph. Stack three retry layers that don't know about each other and a single transient network blip can turn into three duplicate side effects, not one. Checkpointing — the thing most orchestration frameworks actually ship — makes this worse in a specific way: resuming from a checkpoint after a crash can re-trigger every tool call and model request between the checkpoint and the crash, including ones that already completed.

The gap in what frameworks actually ship

Search the documentation for the current generation of agent frameworks — LangGraph, the OpenAI Agents SDK, CrewAI, Google's ADK, Microsoft's AutoGen — and you'll find retry logic for model requests: rate limits, transient API errors, malformed outputs. You will not find built-in idempotency-key management or a deduplication store for tool calls that write to external systems. That part is left to whoever builds the tool. It's a real enough gap that practitioners have started posting about it in public forums after shipping an agent that double-fired a side-effecting tool in production — CrewAI's own community forum has threads specifically about retries double-firing side-effecting tools inside a crew.

None of this means the frameworks are badly designed. Idempotency is inherently a property of the tool's contract with the system it's writing to, not something a generic orchestration layer can safely bolt on without knowing what the tool actually does. But it does mean the guarantee doesn't exist by default, and most teams don't find that out until a customer gets double-charged or double-emailed and asks why.

Where the fix actually belongs

The practitioner consensus that's formed around this problem — not a framework feature, but a pattern teams build themselves — looks like this:

  • Classify every tool as read-only or side-effecting. Read-only tools can retry freely; nothing changes if you call them twice. Side-effecting tools can't.
  • Generate one idempotency key per logical business intent, not per retry attempt. The key should come from something stable — an order ID, a request ID tied to the triggering event — so that every retry of the same intent collides on the same key, and a genuinely new intent gets a new one.
  • Keep a ledger. Before the first attempt, persist the key. Execute the tool once, store its result against that key, and on any later call with the same key, return the stored result instead of executing again.
  • Put the retry owner at the tool boundary, not in the agent loop. The agent loop is the worst place to own retry logic, because it's also the layer most likely to vary the exact request on a second attempt. One component, close to the side effect, should decide whether a call is a duplicate — not three stacked layers each retrying independently.

What this means if you're buying, not building

If you're evaluating a vendor's AI agent and it writes anywhere that matters — your CRM, your billing system, your inbox, your database — ask directly whether its tool calls are idempotent and how duplicate side effects are caught. A vendor who has actually built this will have a specific answer: a key scheme, a dedupe store, a list of which tools are classified as side-effecting. A vendor who hasn't thought about it will give you a vague answer about "robust error handling," which is a different thing and doesn't cover this failure mode at all.

Takeaway: an agent that retries safely isn't the same as an agent that retries idempotently. If any tool call in your pipeline sends money, sends a message, or writes a record, assume the network will fail mid-call eventually — and make sure something, somewhere, is checking a key before it lets the retry through.

Have a system like this in mind?

Get a scoped plan ↗