When Retrying a Failed Tool Call Helps an AI Agent — and When It Just Wastes Steps
This comparison looks at retry vs replan AI agent behavior after a tool call fails, to see which recovery policy actually works and when.
A simulated agent that blindly retries a failed tool call recovers 92.37% of tasks when the failure is transient, but only 21.60% when the failure is persistent — statistically indistinguishable from not retrying at all (21.65%). Switching to a different action after one failed attempt recovers roughly 83% of tasks in either failure regime.
A common default in agent frameworks is to retry a failed tool call automatically. LangChain’s ToolRetryMiddleware ships with retries on by default for every tool: two retry attempts after the initial call, exponential backoff starting at one second and capping at sixty, with jitter enabled. That default treats a failed tool call the way an HTTP client treats a dropped request — worth trying again. So I built a minimal simulated agent and tested whether retrying the same action actually recovers a failed tool call, and whether the answer depends on what kind of failure it’s retrying against.
Concept
Tool-call failures in an agent loop come in at least two shapes. A transient failure is independent of the attempt: a rate limit, a timeout, a flaky network hop. Try again and you get a fresh, independent draw — it might succeed this time even though nothing about your request changed. A persistent failure is a property of the request against the current world state: a calendar slot that’s already booked, a record that’s been deleted, a payload that fails the same validation check every time. Retrying the identical action against a persistent failure asks the same question and gets the same answer, no matter how many times you ask.
The two failure types call for different responses. A transient failure is fixed by waiting and trying the same thing again. A persistent failure is only fixed by doing something different — picking an alternative slot, re-reading the current state, escalating to a human. This matters well beyond chatbots: it’s the same fork a retrieval pipeline hits when a lookup comes back empty. When building a RAG agent, a failed retrieval call can either be retried as-is or escalated into a reformulated query, and which one is correct depends entirely on whether the retriever failed for a reason that retrying fixes.
Hypothesis (falsifiable): a policy that blindly retries the exact same tool call up to several times will substantially raise task success under transient, per-attempt failures, but will produce no measurable improvement over not retrying at all under persistent, per-task failures, because the outcome of a persistent failure doesn’t depend on the attempt number. A policy that instead tries one alternative action after a failure will recover a large share of persistent failures too — and will do so while wasting fewer steps than blind retrying wastes trying the same doomed action repeatedly.
Experiment
I simulated a minimal agent task: a sequence of 3 tool-call steps that must all succeed for the task to count as complete, under a fixed step budget. Each step can fail, and I modeled two separate failure regimes:
- Transient regime: every attempt at a step independently fails with probability p = 0.4. Retrying draws a fresh, independent outcome each time.
- Persistent regime: each step is “broken” for the whole task with probability q = 0.4, decided once. A broken step fails on every attempt, forever; an unbroken step succeeds on the first try, every time.
Against each regime I ran three policies: no-retry (one attempt, then abort), blind-retry (up to 3 retries of the identical action, 4 attempts total), and replan (one attempt, then on failure try a different action with an assumed 0.85 success probability — standing in for “query a different endpoint” or “pick a different slot”). Everything is seeded NumPy, vectorized across 200,000 trials per cell, and runs in well under a second with no network calls or model downloads. The core of the simulation (persistent regime, trimmed):
Q_PERSISTENT = 0.4 # P(a step is permanently broken for this task)
R = 3 # blind-retry attempts after the first try
P_ALT = 0.85 # assumed success prob. of a replanned action
def run_persistent(policy):
total_success = np.ones(N, dtype=bool)
steps_used = np.zeros(N, dtype=int)
alive = np.ones(N, dtype=bool)
for s in range(S):
broken = rng.random(N) < Q_PERSISTENT # fixed for this step/task
if policy == "no_retry":
step_ok = ~broken
used = np.ones(N, dtype=int)
elif policy == "blind_retry":
# retrying the SAME action against a persistent fault
# never changes the outcome
step_ok = ~broken
used = np.where(broken, 1 + R, 1) # wastes every retry
elif policy == "replan":
replan_try = rng.random(N) >= (1 - P_ALT)
step_ok = (~broken) | (broken & replan_try)
used = np.where(broken, 2, 1)
steps_used += alive.astype(int) * used
total_success &= np.where(alive, step_ok, True)
alive = alive & step_ok
return total_success, steps_used
The transient-regime function is structurally identical, except each attempt draws a fresh Bernoulli outcome instead of checking a fixed “broken” flag. Full script, including the TSR and recovery-cost accounting: run once, seeded, and printed directly — no numbers below were hand-edited.
Results
Task Success Rate (TSR) is the fraction of the 200,000 simulated tasks that completed all 3 steps within budget. Recovery cost is the mean number of steps spent beyond the 3-step “happy path,” averaged across all tasks (including ones that never hit a failure):
| Regime | Policy | TSR | Mean steps used | Recovery cost |
|---|---|---|---|---|
| Transient | no-retry | 21.56% | 1.961 | 0.000 |
| Transient | blind-retry | 92.37% | 4.746 | 1.746 |
| Transient | replan | 82.91% | 3.951 | 1.010 |
| Persistent | no-retry | 21.65% | 1.962 | 0.000 |
| Persistent | blind-retry | 21.60% | 4.312 | 1.312 |
| Persistent | replan | 83.11% | 3.956 | 1.015 |
Three things stand out in the raw output. First, blind retry is a large win under the transient regime: +70.82 percentage points of TSR over no-retry (21.56% → 92.37%). Second, under the persistent regime that same blind-retry policy produces a lift of −0.05 percentage points — noise around zero, not an improvement — while still spending an extra 1.312 steps per task on average, all of it wasted on retries that could not have succeeded. Third, replanning recovers persistent failures almost exactly as well as it recovers transient ones (83.11% vs. 82.91%, both roughly a 61-point lift over no-retry) and does it at a lower recovery cost than blind-retry pays for a result that doesn’t work at all in the persistent case.
With N = 200,000 per cell, the standard error on a proportion near 0.2–0.9 is at most about 0.11 percentage points, so the near-zero persistent-regime lift for blind retry is not sampling noise — it is the expected result of retrying an action whose outcome doesn’t depend on the attempt number.
Explanation
These numbers are a direct, mechanical consequence of how the two regimes were defined — under the transient regime, failing all 4 attempts requires 0.44 = 2.56% bad luck per step, so most tasks recover; under the persistent regime a broken step is broken on attempt 1 exactly as much as attempt 4, so blind retry buys nothing. The interesting part isn’t that the simulation confirms its own setup — it’s that this setup is a reasonable simplification of what published work on real tool-using agents reports.
Tian Pan’s 2026 analysis “Replan, Don’t Retry: Why Most Agent Errors Aren’t Transient” draws the same transient/persistent split and argues the retry-with-backoff default most agent frameworks ship is borrowed from stateless HTTP clients, where it’s appropriate, and misapplied to stateful planning loops, where a failure usually means the world changed rather than that the request was dropped. The piece cites an informal 200-task ReAct evaluation in which over 90% of a naive agent’s retries targeted tool names that didn’t exist — a request that could never succeed no matter how many times it was retried, which is the same zero-benefit pattern this simulation produces for the persistent regime, just caused by a different kind of unrecoverable request.
A more rigorous version of the same question comes from Zhu et al., “When Tools Fail: Benchmarking Dynamic Replanning and Anomaly Recovery in LLM Agents” (ToolMaze, 2026), which injects transient and permanent tool faults into 400 multi-step tasks across nine LLM agents, including GPT-5.5 and Claude Sonnet 4.6. They report an average Perturbation Recovery Rate around 81% for transient explicit faults, dropping to about 38% for permanent explicit faults — and under 20% once the permanent fault is also “implicit” (a structurally valid but wrong tool result, rather than an outright error). They also find that larger models get modestly better at completing tasks overall but do not get meaningfully better at recovering from permanent faults specifically, concluding replanning is a distinct capability that scaling parameters doesn’t buy. The qualitative shape — retry-style recovery working well for transient faults and badly for permanent ones — lines up with what this toy simulation shows; the exact percentages don’t need to match, since a scripted Bernoulli model and an LLM agent reasoning over a 270-tool benchmark are different systems being asked a structurally similar question.
Against that backdrop, LangChain’s ToolRetryMiddleware reference documentation states its defaults plainly: max_retries=2, applied to all tools unless scoped down, with exponential backoff (factor 2.0, 1.0s initial delay, 60s cap) and jitter on. The documentation doesn’t say when retrying is or isn’t appropriate — it’s an opt-in-by-default mechanism, not a judgment about failure type. That’s a reasonable general-purpose default for the transient case this simulation modeled, and exactly the setting Tian Pan’s piece and the ToolMaze results both suggest it quietly fails on: a validation error, a stale resource ID, or a changed precondition will fail identically on attempt 1 and attempt 3, and the agent will have spent a backoff-delayed retry budget finding that out instead of trying something else.
What This Result Does Not Prove
- It doesn’t model a real tool-using environment. Three sequential, independent Bernoulli steps is a drastic simplification of something like ToolMaze’s 270 tools and branching task DAGs, where failures can cascade or interact across steps.
- The 0.85 replan success rate is an assumption, not a measurement. I picked it to represent “an alternative action usually works”; real agents, per the ToolMaze results, are often much worse than that at finding and correctly executing an alternative path, especially under implicit failures.
- The simulation doesn’t test failure detection. It assumes the agent already knows which policy to apply; it says nothing about whether a model can tell a transient failure from a persistent one from the error message or tool output alone, which is the harder problem the cited sources both focus on.
- All failures here are explicit (a clear pass/fail signal). ToolMaze’s most damaging category — implicit failures, where a tool returns a plausible but wrong result — isn’t represented at all, and that’s reported as the regime where recovery is worst.
- The parameters (p = q = 0.4, 3 retries, 3 steps) were chosen to produce a clean illustrative separation, not fit to any measured production failure-rate distribution.
Resources
- Tian Pan, “Replan, Don’t Retry: Why Most Agent Errors Aren’t Transient” — the transient/persistent, infrastructural/semantic error taxonomy this experiment borrows.
- Zhu et al., “When Tools Fail: Benchmarking Dynamic Replanning and Anomaly Recovery in LLM Agents” (arXiv:2606.05806) — the ToolMaze benchmark and its Perturbation Recovery Rate results across nine LLM agents.
- LangChain
ToolRetryMiddlewarereference documentation — the default retry/backoff/jitter settings cited above. - “Your ReAct Agent Is Wasting 90% of Its Retries” — the informal 200-task simulation behind the 90%-of-retries-on-hallucinated-tools figure cited above.
- NumPy
Generatordocumentation — the seeded RNG API used for this simulation.
Related Reading
- Building Your First RAG Agent: From Documents to Grounded AI — the agent this post’s retry/replan question would actually need to be wired into.
- Honest Write-Up: Why “Just Retrieve More Chunks” Doesn’t Scale in RAG — a companion case of a cheap default (retrieve more) that looks safe until you measure what it actually trades away.
- Z-Score Thresholds vs. Isolation Forest: What Each Catches in Expense Fraud — a similar two-method comparison, there for anomaly detection rather than failure recovery.
