cd /news/ai-agents/6-agent-failure-modes-we-keep-hittin… · home › topics › ai-agents › article
[ARTICLE · art-177523] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

6 Agent Failure Modes We Keep Hitting in Production (and How We Handle Them)

An engineering team described distilling six named agent failure modes — spin, blowup, thrash, drift, stall and burn — from production incidents and encoding them into the engine's type system as RunFailureKind, giving detection, verdicts, recovery, audit trails and tests a shared vocabulary. The team reported that a synchronous call once froze an agent's event loop for four and a half hours while dashboards showed the task as running, and argued that existing post-hoc failure taxonomies such as MAST do not answer the present-tense question of which failure mode is occurring and whether to intervene. Their handling approach prompts the model with evidence first and escalates to a human stop only if the pattern recurs.

recommendation

Encode named failure modes as typed enums so detection, recovery and tests share one definition, and prompt the agent with the evidence before stopping it.

more in playbook: Designing agent systems
by read16 min views7 publishedNov 28, 2026

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.

Principle: identify the failure mode first, then handle it.

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?

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.

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, and 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.

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:

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.

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.

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.

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.

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.

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.

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.

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. Misaligned metric: what the rule wanted to govern and what the instrument actually measured were not the same thing. Worse, it manufactured the illusion that someone was on guard duty — context risk sat on a gauge that could never fire, and when things went wrong you'd assume this layer had been watching. A fake guard costs an extra round of diagnosis compared to no guard at all.

The fix. Delete the rule. What it wanted to govern already has proper owners: the wrap-up mode watches the context fill ratio (0.85 by default) and pushes the agent to state conclusions before the end; the budget channel owns hard caps on totals. Each covers its stretch. Side note: truncating history to "save context" is a road we refuse to take — splicing the middle of the history wrecks the prompt cache, and the money you save comes back doubled on the next bill.

Lesson. When writing a criterion, ask first: does this metric measure the thing I am judging? The easiest mistake is being fooled by the metric's name — growth rate is not pressure; ratio is not state.

The false positive. There was also a "no progress" rule (no_progress): no new tool calls and no substantive output for a while → judged as no progress. Two problems. First, ownership collision: the run loop has its own idling handling — it counts noops and stops at a line — and this rule judged the same thing, so one stall got booked twice. Second, the false-positive surface: it fired on small sample windows, and the normal quiet stretch around a compile — no tool calls while output arrives — got judged as no progress. Fifteen seconds of compiling is not a stall; it is a wait.

Why it was wrong. The harm of duplicate criteria is not just redundancy. Every verdict injects a recovery hint into context and writes a line into recovery history; two criteria watching the same thing book one incident as two, and the escalation ladder accelerates on its own inflated counts — the "third time, escalate; no improvement, stop" ladder runs its whole course against a normal wait and executes clear_recent_turns. The more duplicated the rules, the faster the escalation, the sooner the wrongful kill.

The fix. Delete the rule. Idling belongs to the run loop: it counts noops and stops itself; when things are genuinely worth reporting, it sends an external signal to the guard, which consumes signals instead of re-judging. The guard's rule table keeps only the three anomalies that truly belong to it: spinning, wall-hitting, thrashing.

Lesson. Every criterion needs a single owner. Where criteria overlap, the escalation ladder will be skewed by inflated counts — this is not code hygiene, it is an accelerator for wrongful kills.

The false positive. Criteria consume runtime metrics — consecutive same-error counts, window sample sizes — but the producers live in other hands: an implementation not upgraded, a field not reported, and the criterion starves. The nastiest failure mode is not an error, it is silent idling: the criterion runs, never fires, and you believe the guard is on duty when it has gone blind. There is also a temptation: when a field is missing, quietly fall back to the old criterion — which is exactly inviting the bad criterion we just fired back into service.

Why it was wrong. Silent failure dresses "no guard" up as "the guard found nothing", and diagnosis is off-track from step one. Falling back is worse: Pits 1 and 2 had just retired those criteria; pulling them back on a missing field reopens the road to wrongful kills — the fix equals no fix.

The fix. In the contract, key fields are marked optional, and the behavior is pinned down: when a field is missing, the criterion does not arm, and it raises a one-time alert (once, queryable) — never a silent fallback. Better a miss than a kill: the price of a miss is finding out late; the price of a kill is murdering a healthy task and destroying the scene. Pit 2 is right there.

Lesson. A criterion is only as reliable as itself times its data supply. When designing a criterion, design "what happens when data is missing" as part of it — don't leave it to chance.

What the five pits share: the old criteria all judged surface statistics (counts, rates, growth), while failure modes are defined in behavioral semantics (did it change methods? is there progress? or is the same thing repeating?). Statistics can be a signal; they cannot be a criterion.

First, the complete mechanical part — what happens after a verdict — shared by all six modes.

A checkpoint verdict has exactly three outcomes: continue (nothing happened), recover (nudge it and let it run), stop (don't). Recovery is not editing the model's code; it injects a suggestion into context and lets the model correct itself — every "hint" mentioned above is this move. The real design is the escalation ladder: repeated recoveries of the same failure type escalate the action from the third time on (clear the last few turns, come at it from a different angle), and if there is still no improvement, stop — and a stop always carries a reason written for humans. This ladder is the direct product of Pit 2: recovery actions sound gentle but can bite harder than stopping, so we reviewed every rung of the ladder for damage potential individually.

Beyond the mechanics, six design principles for building a detection layer that doesn't go wrong easily:

const provider = new ChaosProvider(realProvider, {
  rules: [
    { type: 'rate-limit', after: 4, retryAfterMs: 2000 }, // rate-limit from call 4
    { type: 'empty-response', after: 10 },                // empty response from call 10
  ],
});

No need to argue about criteria: change a rule, run the injection, watch the tests go red or green.

While writing this, we argued internally about one question and it is still open: once an agent's failures are properly named and handled, what form should that "medical history" take in its memory? Keep too much and it gets dragged down by its own history — we have genuinely seen runs slowed by records of old false verdicts; keep nothing and it may fall into the same pit twice. Which memory layer the history belongs in, and at what confidence — we have no answer yet.

If you build failure detection for your own agents, I'd love to hear how you'd handle this part.

Full implementation lives in the Octopi-agent repository: https://github.com/JK-Ai-Era/octopi

Disclosure: this post was written with AI assistance from real incident records and engineering notes, and reviewed and edited by the author. The failures, numbers, and code are real.

── more in #ai-agents 4 stories · sorted by recency
── more on @mast 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/6-agent-failure-mode…] indexed:0 read:16min 2026-11-28 · —