6 Agent Failure Modes We Keep Hitting in Production (and How We Handle Them)
One of our agents was chugging along for four and a half hours. When we finally looked closely, it turned out it had done absolutely nothing.
It wasn't thinking, and it wasn't waiting on model quota - a synchronous call had frozen the engine's event loop. The monitoring dashboard looked healthy, the task status still said "running", but time inside that process had stopped.
In the postmortem the worst part wasn't the lost 4.5 hours. It was that when it mattered, nobody could say what was happening: the logs only said "still running".
This is a common embarrassment in agent engineering: a failure happens, but there is no failure definition and no playbook. Most talk about agent failure today is post-hoc attribution - replaying traces after a batch finishes and classifying why each run died.
Academic work exists: MAST organizes multi-agent failures into 3 families and 14 modes; ICML 2026 had a paper proposing reliability metrics for agents. Valuable work, all of it. But it's a report written after the fact.
For an agent running right now, the questions that matter are present tense: which failure mode is this, and should I intervene or leave it alone?
From production we distilled 6 failure modes and gave them names: spin, blowup, thrash, drift, stall, burn. The names went into the engine's type system (RunFailureKind), and suddenly detection, verdicts, recovery, audit trails, and tests all had something to hang on.
Below: each mode in turn, then the pits we fell into along the way - every detection criterion we have is a scar - and finally the handling philosophy that came out.
The 6 failure modes
Principle: identify the failure mode first, then handle it.
spin: repeating with no progress
Same tool, same arguments, same result, over and over. The criterion is all three identical, 5 calls in a row.
Why so strict: in coding tasks, calling the same tool repeatedly is normal - tweak a line, run the type checker, tweak again - arguments differ every time, and that's progress, not spinning.
Handling comes in two steps. The first step isn't stopping - it's showing the evidence: inject a note into context ("your call arguments and results have not changed in 5 calls; this approach cannot make progress - change approach or report the blocker"). Spinning is usually unconscious, and models often snap out of it the moment they see the evidence.
Second step is escalation: if the new approach also fails and the same pattern recurs, the escalation ladder takes over (mechanism under "How we handle it"), ending in a stop that hands off to a human.
The question handed over is concrete: are the task premises flawed - a misleading tool response, or a goal unreachable to begin with?
blowup: running into the same wall
Same error over and over: same tool, same arguments, same error content. The criterion is 3 in a row, where "same error" is a fingerprint match - a hash over tool name, arguments, and error text, with volatile fields like timing stripped out, or the same error would look new every single time.
The distinction from plain "consecutive failures" is the entire point of this mode: failures with different errors are exploration; the same error repeating is a retry that changed nothing. So there is also a high backstop - 8 consecutive failures with varying errors trips it too, because that usually means the tool or the environment is broken wholesale.
Handling has the same shape as spin: prompt first, escalate after. Ask the model to read the error fully, check its assumptions, switch tools or switch approaches.
But the two kinds of wall have different exits. A repeating error is a method problem, so the hint targets method. Eight straight failures is an environment problem - a human should go fix the environment instead of letting the agent toil in the rubble.
thrash: burning effort with nothing to show
Failures that bought zero progress. Three conditions must hold at once:
- tool failure rate above 50%
- the failure-rate window has at least 5 samples
- the last 3 turns contain no successful tool call and no substantive output
Why all three - there is a full story in Pit 2 below. Short version: a high failure rate is not by itself abnormal. In coding, red tests are part of the work. Only "high failure rate plus zero progress" together means thrashing.
Handling here is a turn: swap "keep trying" for "stop and ask". The recovery hint requires the agent to locate the root cause of the failures, or to report the blocker to the user outright. The correct exit for this mode is asking for help, not perseverance - it has just proven that more of the same grinds in place.
drift: walking away from the goal
Every step looks reasonable on its own; string them together and it is no longer the same job. The typical case: a long task gets halfway, an interjection pulls attention, and the next ten actions work on something else entirely.
For drift our strategy centers on prevention, not capture. Drifting happens when the goal leaves the room: the longer the context and the more interruptions, the easier the original task gets washed out.
So the engine has a task system that pins the goal in front of the agent:
- Work starts with a task. Every execution opens a goal; complex ones split into steps - one level only, no task trees. The task list hangs on the session and survives restarts.
- Goal visible every turn. At the start of each run, open tasks are injected into context: just the goal plus one progress line ("step 2/5: checking for circular deps"), not the whole plan dumped into the system prompt. The injection states facts and tool obligations; it never commands the model to "continue".
- Single writer. Only the main LLM can edit the task list, because it sees the full conversation; the UI is read-only. No more "the panel says done while the reply is still working".
- Explicit closure. When all steps are done the goal is not auto-completed - closing is explicit. Steps done can still mean the conclusion and the deliverable are missing.
- Guard both directions. One easily missed behavioral rule: when a message is unrelated to the task, prioritize the current message; resume the task only when the topic comes back. Drift has two shapes - forgetting the goal, and clinging to a stale one. Both count.
There is a backstop at the detection layer: an LLM review layer reads run summaries every N checkpoints and soft-judges whether the task has drifted. To be honest, this is the least explainable of the six - the verdict comes from "a model looked at it", not from a rule.
So our improvement direction is not fancier detection but sturdier prevention: keep the goal present every turn and there is far less room to drift.
When drift is actually flagged, handling pulls the task anchor back into context (reinstate goal plus the progress line), and repeated drift stops and hands off to a human. But really, drift handling lives in those five prevention points - the verdict is only the backstop. The best handling for this mode is making it not happen.
stall: frozen solid
The runtime itself stops responding. The opening story is the canonical case: the event loop stuck on a synchronous call, the agent's "body" stopped, and its "brain" - the model - never knew.
Detection lives in a separate thread, the loop-watchdog: heartbeat monitoring, and if silence exceeds the threshold (stallThresholdMs) it declares a freeze and records how long it lasted. It must run on another thread, and the reason is blunt: a frozen loop cannot detect itself.
The watchdog cannot rescue the frozen loop; its handling is alarm and record. Raise an alert, log the freeze window and duration, and once the process is back, mark that "amnesia window" so a postmortem can see what the period actually held.
The real handling is human-side: when the alert fires, go find what synchronous heavy lifting landed in the event loop - big files, sync IO, sync network calls - and move it out.
burn: burning through the budget
Resource consumption exceeded budget - usually tokens or cost goes first. This one comes from another incident: 31 turns burned 2 million tokens, and under the cutoff rules of the time a single pass axed over 1.5 million. The user saw none of it.
Budgets now run on an independent channel, structurally separate from the guard: the accounting side only reports numbers and never terminates anything; the guard side does the killing. The reason is simple - let the accountant hold the knife and the books will never balance.
Handling is hard action: wall-clock, turn count, and tool-call count each carry hard caps; hitting a line stops the run, no negotiation. But the stop always carries a human-readable reason ("task has run N turns and hit the safety cap; to continue, optimize the task and start fresh").
A sibling mechanism watches context: when it is nearly full - 0.85 by default - it does not hard-stop. It lets the agent spit out its conclusion first, then wraps up. The right way to burn through is to leave a deliverable behind.
Recap: each detector owns what it can observe
The six detectors do not live in one table - they are layered by ownership: spin, blowup, and thrash come from the verdict rule table at checkpoints; stall runs in the dedicated watchdog thread; burn hangs on the budget channel; drift is prevented by the task system with the LLM review layer as backstop.
Each layer watches only what it can actually observe, and that is deliberate - the pit section below explains why the detection layer should stay thin.
The pits: every criterion was repaired, not designed
Names are easy; criteria are hard. The five pits below are in discovery order. The first two each caused a real wrongful kill - and those two incidents are exactly why we rewrote the criteria.
Pit 1: counting failures - red-green debugging judged as an error loop
The false positive. The early criterion for blowup read: "3 errors in a row → error loop". Now watch a real debugging session: run test A, red; fix; run test B, red; fix; run test C, red. Three failures, zero successes, and a different error every time - that is textbook red-fix-green debugging. That is what an agent working looks like.
The old criterion counted how many times things failed, but getting stuck shows up as the same error repeating. The task kept getting interrupted by recovery hints and was eventually stopped. From the user's side the agent simply quit, and the log said "error loop detected".
Why it was wrong. It treated correlation as a criterion: failure count correlates with being stuck but is not being stuck. A real criterion has to track behavioral semantics - did the retry change anything?
The fix. Give failures a fingerprint (tool name + arguments + error content), and require the same error 3 times in a row to call it a wall. Consecutive failures with different errors count as exploration. The backstop moved to 8 consecutive failures across the board.
Bonus find. While rewriting the criterion we found the counter's comment said "counts model errors + tool errors", but the implementation only counted tool errors. The comment and the code were lying about each other, and we had studied the criterion against the comment for half a day. The habit that came out of it: always read a criterion against its implementation.
Pit 2: watching the failure rate - red tests judged as thrashing, then the body was destroyed
The false positive. The early thrash criterion read: "tool failure rate above 50% → thrash". For a coding agent this is almost guaranteed to misfire: write the failing test first, implement against the errors - failing calls and successful edits alternate, and the failure rate is naturally high.
Worse than the false positive was the kill chain. A thrash verdict triggers recovery; two recoveries of the same type escalate the action to clear_recent_turns - wiping what the agent had just finished out of context; three in a row stop the run outright. Wiping context is harder to diagnose than stopping: a stop at least leaves the corpse and the trajectory to review. After the wipe, you cannot even tell what it had just accomplished. One wrong criterion, amplified by the recovery escalation ladder, became an undiagnosable incident.
The fix. Three conditions together now make thrash: failure rate above 50%, sample size at least 5, and no successful tool call or substantive output in the last 3 turns. The core addition is hasProgress - only failures that bought zero progress count as thrashing.
Bonus find (window semantics). The failure rate covers the last 10 tool calls. Inside that window, "failure rate above 50%" and "no two consecutive failures" cannot coexist mathematically - 6 failures and 4 successes necessarily contain consecutive failures, which blowup's criterion would intercept first. Which means the only scenario where thrash can still trigger on its own is small samples - 2 failures out of 3, 67% rate - exactly the rhythm debugging happens at. The old criterion, in the one scenario it was built for, kept catching innocent agents. So the minimum sample size is not tuning; it plugs a logic hole: a rate is a ratio, and two calls that both failed are "100%" - that is not evidence.
Pit 3: the misaligned metric
The false positive. The criterion meant to catch "context bloat" used token growth rate: the last 5 turns' token increase divided by the current total. The trouble is the "divided by the current total" part. Two real long tasks rolled their context up to 10x and 2x - bloat as plain as day - but the growth was spread over the whole run; the last 5 turns were 8% and 3% of the total, readings of 0.08 and 0.03 against a 0.5 threshold. It would never trip.
The reverse case: a fresh task reads one big file, the small denominator inflates the ratio, and a normal operation gets flagged as bloat. What it needed to judge was how big things are now (inventory); what it measured was how fast they grew recently (flow). Two different things.
Why it was wrong. Misali
Comments
No comments yet. Start the discussion.