AI Agents
Why AI Agents Fail: Common Failure Modes and Design Patterns
An agent fails at its boundaries: the request, the model's decisions, tool execution, reading results, controlling the run, side effects, and what it reports. The failures from this series, sorted by boundary, then measured: 543 recorded conversations replayed through the guards earlier articles recommended, to see what each would have stopped, what correct work it would have stopped too, and which failures pass every one.
On this page · 12 sections
A customer asks the support assistant: “Which of my invoices can still be refunded?”
The assistant in this run is a manager agent with two specialists. It passes the question to the billing specialist word for word. The specialist’s tools take an invoice id, and it doesn’t have one. So it makes three up:
get_refund_status {"invoice_id": "invoice_id1"} -> No invoice invoice_id1 was found
get_refund_status {"invoice_id": "invoice_id2"} -> No invoice invoice_id2 was found
get_refund_status {"invoice_id": "invoice_id3"} -> No invoice invoice_id3 was found
Then it reports back to the manager: “It appears that no invoices were found for the customer with the ID owner@customer.example.” The manager has no records of its own, so it believes it, and tells the customer: “I couldn’t find any invoices for your account.”
The customer has four invoices.
It’s tempting to file that under “the model got it wrong” and reach for a bigger model or a sterner prompt. But look at where it went wrong. A request with no id met a tool that needed one. A made-up value went into a tool call. Three failed lookups came back as errors. The specialist turned “the lookups failed” into “there are no invoices”. The manager turned a colleague’s sentence into a fact about the customer’s account. That’s five places, and only the first two are about the model’s judgment. The rest are about what crossed from one part of the system to the next, and what nothing checked on the way.
This article closes the agents phase of the series. It takes the failures the earlier experiments recorded, sorts them by the boundary where they happened, and maps each boundary to the engineering patterns that can prevent, detect, or contain what goes wrong there. Then it tests those patterns: the guards the earlier articles recommended, replayed against 543 conversations those experiments actually recorded, to see what each one would have stopped, what correct work it would have stopped too, and which failures would have passed every one of them.
Try to Understand It This Way
Think about how a hospital ward gives medication.
A doctor writes the prescription. A pharmacist checks it before it’s dispensed. At the bedside, a nurse checks the patient’s wristband against the chart before giving the dose. Each check sits at a specific handover, where a specific mistake is known to happen: the wrong patient, the wrong drug, the wrong dose, the wrong time. None of them works by asking the doctor to be more careful. Each one compares what’s about to happen with a record, at the moment before it becomes something that can’t be taken back. And when something doesn’t fit, the nurse doesn’t improvise. They stop and call someone.
Two things about that system are worth noticing. The checks are placed at handovers, not spread evenly everywhere. And they don’t catch everything: a correct prescription for the wrong diagnosis passes every one of them, because none of them knows what’s wrong with the patient.
An agent needs the same kind of design, with the same limits. The model makes decisions: which tool, with which arguments, what the result means, whether it’s done, what to say. Information crosses handovers: from the customer into the agent, from a tool into the model, from one agent to another, from the model to the customer. The application can’t make the model more careful. It can put a check at each handover, against records it owns, before a decision becomes an action or a claim.
The useful question isn’t “how do I make the model stop making mistakes?” It’s “where did this go wrong, and what could code have checked there?”
An Agent Has Failure Boundaries
“What Is an AI Agent? (opens in a new tab)” defined an agent as a system in which the model can choose actions, observe their results, and use those results to decide what to do next, within boundaries the application enforces. Each part of that sentence is a place where something can go wrong.
| Boundary | What crosses it | What goes wrong there |
|---|---|---|
| 1. Request | the user’s goal into the agent | ambiguous or incomplete goals, guessed intent |
| 2. Decision | the model’s choice into a tool call | wrong tool, malformed or invented arguments |
| 3. Execution | the call into an external system | errors, outages, “nothing found” vs “failed” |
| 4. Observation | a result into the model’s reading | misreading, instructions in data, stale memory |
| 5. Control | the loop into the next step | stopping early, repeating, running too long |
| 6. Side effect | an action into the world | unasked, wrong, or duplicated actions |
| 7. Reporting | the agent to a user or another agent | claims the record doesn’t support |
A failure usually crosses more than one. The opening conversation started at the decision boundary (an invented id), passed through execution (three errors), and did its damage at reporting, twice (specialist to manager, manager to customer). That’s why it helps to name boundaries rather than collect bugs: a bug list tells you what went wrong once, and a boundary tells you where to put the check that will catch the next one.
There are other ways to cut this. “Why Do Multi-Agent LLM Systems Fail?” (Cemri et al.) built a taxonomy of 14 failure modes in 3 categories from more than 1,600 annotated traces of seven multi-agent frameworks. Microsoft’s AI Red Team publishes a security-focused taxonomy of agent failure modes, updated to version 2.0 in June 2026. The boundaries here are organised around one question, where a check in code can go, because that’s what an engineer can act on.
Why the obvious fixes don’t close a boundary
Each of the usual fixes was tried somewhere in this series, and each one changed a rate without closing a boundary.
- A better prompt. In “Function Calling and Tool Use in LLMs (opens in a new tab)”, a prompt that said to act only when asked cut unasked actions from 9 to 1 in 32 conversations. The one that remained sent an email nobody asked for.
- A repair loop. In “LangGraph in Practice: A Text-to-SQL Agent You Can Measure (opens in a new tab)”, a loop that showed the model its own SQL errors and asked it to try again ran on four questions and fixed none of them. Most wrong answers came from queries that ran without an error, which a loop driven by errors never sees. (That’s the model retrying, not the application retrying a failed call; retries owned by code come up under execution, below.)
- More agents. In “Single-Agent vs Multi-Agent Systems: What Does Another Agent Add? (opens in a new tab)”, the manager with two specialists, the design in the opening, had 4 successes of 36 against the single agent’s 12.
- More thinking. In “Planning, Reasoning, and Execution in AI Agents: Who Decides the Steps, and When? (opens in a new tab)”, a plan revised after every batch of results used 16.6 times the fixed workflow’s input tokens and had fewer successes (4 of 27 against 9).
None of these means prompts, retries, agents, or planning are useless. It means each one acts on the model’s tendencies, and a boundary is closed by something that holds whatever the model does. Those measurements came from small local models (3B parameters) on synthetic data; a stronger model moves the rates. It doesn’t move the boundaries.
The Seven Boundaries
For each boundary: what the failure looks like in this series’ recordings, why it happens, how you’d notice it, the pattern that addresses it, and what that pattern costs. Where a pattern was later tested in the replay, the section says so; the numbers come after.
1. The request: an ambiguous goal
The customer’s message doesn’t fully say what they want, and the agent fills the gap instead of asking.
In “Human-in-the-Loop AI Agents: When Should an Agent Stop and Ask? (opens in a new tab)”, a customer wrote “I want my money back for both October charges”, and the agent requested $25 on one invoice: half of what was asked, which also happened to fit the policy a support agent may approve. In “Building AI Agents With State and Workflows (opens in a new tab)”, a customer complained about November, and the agent refunded October’s duplicate charge in all three runs: a real duplicate, on an invoice nobody had asked about.
Why. The model fills the gap with the most plausible reading, and nothing in the loop separates “the customer said this” from “the model assumed this”. Detect it by comparing each action’s target with the request: a target the request doesn’t name is a guess.
Pattern: make asking a valid outcome. A clarifying question or a handoff counts as success, not failure. For a request that starts an action, extract the target (which month, which invoice) and confirm it before acting. Trade-off: every question is friction. And a route built for unclear requests can go unused: in “Agentic Workflows: When Should an LLM Control the Flow? (opens in a new tab)”, it was never chosen in 12 open-ended conversations.
2. The decision: wrong tool, invented arguments
The model picks a tool that can’t answer, or the right tool with a value it doesn’t have.
This was the most consistent failure in the series. In the function-calling demo, the refund tool’s description said “for example INV-1234”, and llama3.2:3b used INV-1234 in four conversations for a customer whose invoices are numbered differently. In “Tools, Function Calling, and the Foundation of AI Agents (opens in a new tab)”, it passed INV-0000, copied from the example in its own tool description, in five conversations. The planning experiment found placeholders: most_recent_Pro_invoice_id, REPLACE_WITH_INVOICE_ID. The opening’s invoice_id1 is the same thing. Wrong tools happen too: in the agentic-workflows experiment, asked “Something looks off with my October bill”, the agent never called get_payments in any of three runs, the only tool that could show the duplicate charge.
Why. The question describes something (“my most recent invoice”), the tool wants an identifier, and the model fills the gap with something shaped like one. An example value in a description is the most convenient thing shaped like one. Tool choice is made from names and descriptions, before any result exists; Anthropic’s guide to writing tools for agents puts it plainly: “When tools overlap in function or have a vague purpose, agents can get confused about which ones to use.”
Detect it by checking every id argument against where it could legitimately have come from. A schema check isn’t enough: it catches a missing argument or a wrong type, and INV-0000 is a perfectly valid string.
Pattern: explicit tool contracts, argument provenance, and narrow tools. Validate the shape of every call (the schema). Then, for every id the model supplies, check that it appeared in the user’s message, in context the application itself provided, or in an earlier successful tool result. Don’t let the model fill what the session already knows: the signed-in customer comes from authentication, never from an argument. Remove example values from descriptions. Trade-off: a provenance check rejects an id the user typed in a different format, and it says nothing about whether the id is the right one, or even the user’s own. Tested in the replay.
3. Execution: what came back from the outside
The call is fine; the system it calls isn’t, or its answer is easy to misread.
In the planning experiment, the refund-status service was down for one task, and another route to the same information existed; no design rerouted. In the state-and-workflows experiment, the payment service returned a retryable error once; the agent loop made one request, didn’t retry, and told the customer “I will retry later”, which nothing did. And in the opening, three “not found” errors became “no invoices”.
Why. When a result doesn’t state its status, the model has to infer it from prose, and a temporary outage reads like a refusal, “the lookup failed” like “nothing matched”. The recorded models also tended to repeat themselves: of 227 tool calls in the replayed recordings that returned an error, the same agent’s next call was the identical call 57 times (25%). Detect it by giving every result a status the model doesn’t have to infer: data, nothing found, failed and retryable, failed for good.
Pattern: structured results, defined failure states, and retries owned by code. The application retries a retryable error, with a limit and backoff. A failure the agent can’t work around becomes a defined outcome (“the billing system is unavailable; a person will follow up”), not a sentence the model improvises. Retrying is the subject of the Production AI article “Retries, Timeouts, and Failure Handling in AI Systems”. Trade-off: every tool needs a result contract, and someone to maintain it.
4. Observation: right facts, wrong reading
The right result reaches the model, and the answer is still wrong.
This is the failure that surprises people most, because the trace looks healthy: right tool, valid arguments, correct result. The tool-design experiment compared toolsets. Toolset B added each invoice’s refund deadline next to today’s date to what toolset A returned. With qwen2.5:3b, the facts each question needed reached the model in 24 of 30 conversations under B, against 7 under A, and successes went from 6 under A to 5 under B: more facts, no more correct answers. One reply under B:
For the invoice INV-1001, the refund deadline is on or before October 28, 2026.
Since the current date is November 12, 2026, the refund deadline has not passed yet.
Two other versions of the same boundary. Text in a result can carry instructions: the function-calling demo planted a help-center ticket telling “the AI assistant” to refund another customer’s invoice, and one reply then told the customer “I have already gone ahead and issued the refund”, after a conversation whose only tool call was a search. And memory can be read instead of the records: in “Memory in AI Agents: What Does an Agent Actually Need to Remember? (opens in a new tab)”, designs whose memory said a refund was pending never called the payment list in six runs, and so never saw that it had gone through.
Why. A model reads results as text. It does arithmetic and date comparisons unreliably, nothing in the text marks which parts are data and which are instructions, and a fact it already “knows” from memory looks as good as one it just looked up.
Detect it with checks on the reply against the results: every number and id in the reply appears in a tool result. As “Building Reliable LLM Pipelines (opens in a new tab)” measured, that tests where a value came from, not whether the sentence around it is true.
Pattern: move decisions with one right answer into tools; treat results as data; look up what can change. When the step after retrieval is a comparison, a sum, or a date check, do it in code and return the verdict. In the tool-design experiment, toolset C added a refund-status tool that returned “refundable today: false” with its reason. On the eight multi-fact questions (24 conversations), qwen2.5:3b’s successes went from 3 under toolset A, and 2 under B, to 10 under C. Keep authority in code (ownership, recipients) so an injected instruction has nothing to use, and avoid giving one agent what Simon Willison calls “the lethal trifecta”: “Access to your private data”, “Exposure to untrusted content”, and “The ability to externally communicate”. Treat memory as a reason to check, not as an answer. Trade-off: every decision moved into a tool is a decision you now own, test, and keep in step with the policy. None of the replayed guards checks this boundary, and the replay shows what that costs.
5. Control: when to stop
The run ends too early, or doesn’t end.
Too early: in the tool-design experiment, six replies described the right next step and stopped there (“Let’s check the next oldest invoice.”). In the function-calling demo, qwen2.5:3b returned an empty reply in 15 of 32 conversations with one prompt, and the loop’s rule, no tool call means done, treated each one as an answer. Too long: the planning experiment’s replanning design repeated the same call with the same arguments 106 times in 27 conversations. And the LangGraph experiment measured what a framework’s backstop allows: with the graph’s own repair cap removed and a model that never fixes its query, LangGraph’s default recursion limit stopped the run after 5,004 model calls.
Why. In the loop, “done” is whatever the model says it is. Nothing compares the reply with the task, and nothing notices that a step was already taken.
Detect it with counters and comparisons: calls per run, identical calls, empty or text-only replies, and, for task types you know, whether the evidence the answer needs was ever retrieved.
Pattern: bounded execution, and a definition of done that code can check. Cap model calls, tool calls, tokens, and time per run, and give “hit the limit” its own outcome. Notice exact repeats of calls that already succeeded. Check the final reply before it’s sent: not empty, not a tool call written as text, and backed by the evidence the task needs. Anthropic’s guide on building agents notes that “it’s also common to include stopping conditions (such as a maximum number of iterations) to maintain control.” Trade-off: a limit that stops a loop also stops a long, legitimate investigation, and what happens when a guard fires is a design decision of its own. Both tested in the replay.
6. Side effects: actions that can’t be taken back
The agent does something nobody asked for, does the wrong thing, or does the right thing twice.
With a basic prompt in the function-calling demo, llama3.2:3b requested an action nobody asked for in 9 of 32 conversations, and 5 of them executed: “Do you send invoices by email?” sent an email. Every one passed the application’s rules, because rules decide what’s allowed, and can’t decide whether the user asked. In the state-and-workflows experiment, the agent loop made seven wrong refunds in six conversations; after a crash, a resumed run re-sent a refund it had already made.
Why. At this boundary the model’s output stops being text and becomes money, email, or data. Every earlier boundary’s failure arrives here with consequences.
Detect it in the ledger, not the transcript: what was executed, against what policy.
Pattern: deterministic rules in code, least privilege, idempotency, and approval. Put the rules that protect money or data in code, checked against the records at the moment of the action. Make actions as narrow as the job (email_customer(subject, body), not send_email(to, ...)). OWASP calls the opposite “Excessive Agency” and traces it to “excessive functionality”, “excessive permissions”, and “excessive autonomy”. Give every action an idempotency key, so a repeat has, in the Amazon Builders’ Library’s words, “no additional side effects” (the state-and-workflows demo built this). Send what code can’t decide to a person (the human-in-the-loop demo built that). Trade-off: rules in code can only check what the data determines. Tested in the replay.
7. Reporting: claims the record doesn’t support
What the agent tells the user, or another agent, isn’t what happened.
Between agents, the opening is the example: a failed lookup became an empty result, and an empty result became a fact. In the multi-agent experiment, the reviewer was asked for “APPROVE or a replacement reply” in free text; eleven of its rewrites were notes to the drafter, sent to the customer as written, and once it replied _APPROVE, which the customer received. Toward the customer: in the human-in-the-loop experiment, a customer who had only asked a question was told “You should receive your refund today.” In the state-and-workflows experiment, six of the agent loop’s 18 replies announced a step that never happened.
Why. The reply is written by the model, and the model writes plausible text. Nothing ties a sentence about an action to the record of that action.
Detect it by comparing claims with the log, and by typing what agents send each other so code can tell “found nothing” from “couldn’t look”.
Pattern: build confirmations from the log; type the messages between agents. “Your refund was issued” is shown when the execution record says so, as text the application writes, not text the model writes. A message between agents is an interface: a schema, a status, and a defined fallback when it doesn’t validate. Trade-off: typed handoffs lose some of the flexibility that made a second agent attractive. Both tested in the replay.
The Experiment: Replaying Recorded Decisions
Each pattern above was recommended by one of the earlier articles, usually after its experiment showed the failure. None of them measured what the pattern would have done across all of the recordings: what it would have caught, and what it would have broken.
The companion demo, 08-failure-modes, does that without calling a model. The agent demos 01 to 07 saved every conversation: each tool call the model asked for, its arguments, whether it ran, what it returned, and the reply the customer got, with a hand label for every reply. The demo reads those recordings and applies the guards to the model’s actual decisions, in the order they were made, using only what the application would have known at that moment.
What a replay can’t tell you. A replay can say where a guard would have fired and how a run that stops there ends. It cannot say how the model would have recovered if it had been told about the block: that would need a new run. In this experiment, a guard that fires ends the run (the call doesn’t execute, or the reply isn’t sent), and a stopped run is counted as stopped, not as fixed.
What was replayed. 543 conversations with 989 tool calls, from the tool-design, agentic-workflows, multi-agent, memory, planning, and state-and-workflows experiments: every design in which a model chose the tool calls. Designs where code made the calls (the fixed workflows, the state machine) were left out, because they already are the pattern. The human-in-the-loop recordings (24 conversations) were kept separate as a cross-check: their agent ran with hard checks in the loop, so the guards can be compared with real checks on the same calls.
The guards, one or more per boundary that code can check:
| Guard | Boundary | Fires when |
|---|---|---|
budget |
control | the run asks for its 9th tool call |
provenance |
decision | an id isn’t in the request, the app’s context, or an earlier successful result |
id_format |
decision | an id doesn’t look like INV-dddd or PAY-dddd (a cheaper variant) |
repeat |
control | the same agent repeats a call that already succeeded |
refund_policy |
side effect | a refund isn’t of an uncorrected duplicate charge, or is the run’s second |
handoff_evidence |
reporting | a specialist replies after none of its own lookups succeeded |
empty_reply, tool_call_text |
reporting | the reply is empty, or is a tool call written as text |
unbacked_claim |
reporting | the reply claims a completed refund or change, and no write ran |
no_evidence |
reporting | the reply was written with no successful result and no app context |
Every demo already had a schema check that sent errors back to the model, so it isn’t re-implemented: the recording shows what the model did next. There is no guard for the request boundary or the observation boundary, because neither can be checked from the data alone. That gap shows up in the results.
Frozen first. The protocol, the guard code, the guard order, the scoring rules, and the hashes of all 73 input files were frozen at 2026-11-24 08:03:03 UTC, before the guards ran on any of the 543. The guards were developed only on the small unlabelled check runs the earlier demos made before their measured runs. This isn’t a blind test: the guards encode lessons the earlier articles drew from these same recordings. The freeze prevents tuning them to the results after seeing them.
Three kinds of evidence, kept apart throughout:
| Kind | Source | Example |
|---|---|---|
| objective | data files and recorded fields | INV-0000 doesn’t exist; a repeat’s result was byte-identical; a refund broke the frozen rule |
| hand | the earlier articles’ labels, unchanged | this reply is correct, incorrect, or no answer |
| replay | this demo’s guard verdicts | provenance would have fired on call 2 |
Setup and reproducibility
- Recordings replayed:
01-tool-design(qwen2.5:3bandllama3.2:3b, toolsets A, B, C),02-agentic-workflows(agent A),03-multi-agent(S, M, R),04-agent-memory(N, T, S, K),05-planning(L, P, R),06-state-and-workflows(L). Recorded with Ollama 0.40.16 (01 to 04) and 0.40.17 (05, 06);qwen2.5:3bdigest357c53fb659c,llama3.2:3bdigesta80c4f17acd5. Cross-check:07-human-in-the-loop, proposal phase. - Excluded:
- 02’s W and H and 05’s W: their calls were made by code.
- 06’s S: the state machine, whose calls are made by code.
- 06’s crash runs: two processes per conversation.
- 07’s branches: they follow scripted reviewer decisions.
- Replay: Python 3.12.13, standard library only, no model, no network.
python replay.py --set testchecks the freeze and writes every verdict;python report.py --set testprints every table. The whole pipeline takes about half a second, and re-running it gives byte-identical results files. - Labels: “correct” is each reply’s hand answer label from its original article. For the state-and-workflows experiment it is that article’s frozen success rule (a correct refund action and a reply consistent with the ledger).
- Budget: K = 8 tool calls, chosen before the run as the largest per-conversation budget any replayed design had used.
- One deviation, recorded in
FROZEN.json. The first cross-check report crashed: for the two paused calls, the human-in-the-loop recording keeps its hard-check results on the call record, and the loader dropped that field. The fix touched reporting only. Both results files were regenerated and compared with the first run: byte-identical. - Tests: 24 unit tests on hand-written conversations check that each guard does what the protocol says.
What the Replay Showed
First, each guard on its own, against the ground truth that fits it. Then all of them together.
Invented ids: provenance catches what a schema can’t
Unit: id arguments. Truth: objective (the id exists in the account data, or doesn’t).
id status provenance fired id_format fired
doesn't exist 52 of 53 (98%) 45 of 53 (85%)
the customer's own 0 of 202 (0%) 0 of 202 (0%)
51 of the 53 invented ids were on calls the schema check had already passed: INV-0000, invoice_id1, most_recent_Pro_invoice_id, REPLACE_WITH_INVOICE_ID, INV-5006 (a payment number dressed as an invoice id). The schema check saw a string where a string belonged.
The two variants miss different things. The format check misses well-formed inventions like INV-0000. Provenance missed one, August, passed as an invoice id: the word appears in an invoice description (“Pro plan, August 2026”), and the check matches whole words, not typed ids. Together they caught all 53 (a post-hoc observation, not part of the frozen protocol). Neither fired on any of the 202 real ids.
Repeats and budgets: what you do when a guard fires matters
The repeat guard fired on 97 of 989 calls, 75 of them in the planning experiment’s replanning design. All 97 got a result byte-identical to the earlier call’s (objective): no repeat brought new information.
The budget of 8 tool calls would have been reached in 19 conversations: 3 correct, 9 incorrect, 7 with no answer (hand labels). The sweep shows the usual shape: at 4 calls it would have stopped 5 correct conversations, at 12 it would have stopped 1.
The refund policy in code: data rules can’t see intent
The state-and-workflows agent loop made 7 wrong refunds and 5 right ones (objective, the article’s frozen rule). The policy guard checks what the data decides: the payment is the customer’s, a succeeded charge, not refunded, on an invoice still charged twice, and the first refund in the conversation.
refund (executed) guard fired
wrong 3 of 7
right 0 of 5
The 3 it caught were the ones the data rules out: two refunds of a duplicate that had already been corrected, and a second refund on an invoice that was only charged once. The 4 it missed were all the same call: PAY-5005, a real duplicate charge on the October invoice, refunded for a customer who had asked about November or September. The data says the charge is refundable. Only the request says it’s the wrong one, and the guard doesn’t read the request.
Typed handoffs: catching “the lookup failed” before it becomes “nothing exists”
Unit: specialist replies in the multi-agent manager design. Truth: hand labels from the multi-agent article, per fact passed on.
reply labelled lookup_failed no_lookup passes
no fact present 32 2 9
carried evidence 0 0 14
The guard flagged 34 of the 43 labelled replies that passed on nothing, including the opening’s, and none of the 14 that carried evidence. The 9 it missed came from a specialist that did find the facts and then didn’t pass them on: the lookup succeeded and the report still failed. Every manager conversation with a flagged handoff ended without a correct answer (5 incorrect, 13 no answer, of 18).
Reply checks: patterns catch the obvious and miss the rest
unbacked_claim looks for completed claims (“I have issued”, “your refund has been processed”) with no executed write. Against the hand labels:
- It caught 1 of the 6 replies the planning article labelled as fabricated actions. The other 5 were announcements (“I will now remove the extra seats from your plan”), which the frozen check deliberately doesn’t cover.
- It missed both of the human-in-the-loop experiment’s false claims: “You should receive your refund today”, and a reply saying the September invoice “has already been refunded”.
- Its 2 false alarms in 93 replies include one stating a true past refund: “The refund was processed on November 5, 2026 (PAY-5008).”
no_evidence fired on 3 correct replies, a refund-window question answered without a lookup, alongside 14 incorrect ones and 54 with no answer.
All guards together
In order, first fire ends the run. Unit: conversations. Truth: hand labels.
label stopped by a guard passed every guard
correct (or a success) 11 of 156 (7%) 145 of 156
incorrect (or failure) 56 of 290 (19%) 234 of 290 (81%)
no answer 58 of 97 (60%) 39 of 97
That last column of the second row is the most important number in this article. Four in five wrong answers pass every guard. Their calls were valid, their ids were real, nothing repeated, and the model then misread the result or answered a different question. The guards are built for request shapes they can check, and most of these failures happened at the observation boundary, where none of them looks.
The 11 correct conversations a guard would have stopped:
- 6 by the repeat guard: the run ended on a harmless repeat and lost the answer that followed it.
- 3 by
no_evidence. - 1 by provenance: the planning experiment’s replanner used a placeholder id, the call failed, and the next plan fetched the real ids and answered correctly.
- 1 by the refund policy: in the recording, the payment service refused that same call, and the agent then told the customer the truth. Failing closed threw that recovery away.
In the state-and-workflows recordings, the agent loop made 7 wrong refunds in 6 conversations. Under the replay, 3 of those 7 refunds never execute, but only 2 of the 6 conversations end without a wrong refund. In the third, the guard fires on the conversation’s second refund call, after its first wrong refund had already gone through; the wrong refund that would have come next never runs. A guard that fires late contains a failure. It doesn’t undo an earlier side effect.
The cross-check: provenance isn’t ownership
The human-in-the-loop agent ran with hard checks in the loop (owned, valid amount, money left to refund). On the same 9 refund calls:
calls
both stop it (invented invoice ids) 4
hard check stops it, provenance passes 3 INV-2042: the customer typed it,
and it belongs to someone else
provenance stops it, hard check passes 0
both pass (the two that paused for review) 2
They agree on invented ids and disagree exactly where they should. Provenance asks “where did this value come from?” and the answer, “the customer typed it”, is legitimate. Ownership asks “is it theirs?”. You need both questions, and neither one tells you whether the two requests that reached a reviewer were the right ones. Neither was, which is why that experiment had a reviewer.
After the guard fires (post-hoc)
The frozen replay ends the run when any guard fires. For the repeat guard, there’s an obvious alternative: hand the model the earlier result again. Because all 97 repeated calls returned byte-identical results, serving the earlier result would give the model the same tool-result input it received in the recording. This analysis therefore reuses the recorded continuation, under the assumption that the same model input and inference settings produce the same continuation, as the repeat runs of the state-and-workflows and human-in-the-loop demos showed in their setups. It is not a new model run. That makes this the one place where a replay can say, under a stated assumption, what happens after a guard fires.
It was checked after the frozen run:
- correct conversations stopped fall from 11 to 8;
- wrong ones stopped fall from 56 to 40;
- 97 tool executions are saved;
- no model calls are saved: the model still asks, and still reads the answer.
“Detect a repeat” and “stop a repeat” are different patterns, with different costs.
The Guards, in Code
Most of these patterns are a few lines between the model and the tools. This is the provenance check, simplified from the demo’s guards.py (same logic, shorter names):
import re
TOKEN = re.compile(r"[A-Za-z0-9_-]+")
def known_values(conv, earlier_calls):
"""Where a legitimate id can come from: the request, the app's own
context (such as memory), and results of earlier calls that succeeded."""
text = [conv["request"], conv["context"]]
text += [c["result_text"] for c in earlier_calls
if c["kind"] == "data" and c["executed"]] # error results never count
return set(TOKEN.findall("\n".join(text)))
def provenance(conv, call, earlier_calls):
known = known_values(conv, earlier_calls)
for arg in ("invoice_id", "payment_id"):
value = (call["args"] or {}).get(arg)
if isinstance(value, str) and value.strip() not in known:
return f"provenance: {arg}={value!r} has no source"
return None # the call may run
Three details matter more than they look, and each one came from a recorded failure:
- Only successful results count as sources. An error message repeats the invalid value back (“No invoice invoice_id1 was found”). Counted as a source, it would make the next attempt with the same invented id look legitimate.
- Values are compared as whole words. A substring check would accept
INV-1becauseINV-1001contains it. But whole words aren’t types: that’s howAugustgot through. - The application’s own context is a source; the tool’s description isn’t. The memory experiment put real ids in the prompt as memory.
INV-0000came from a description.
The refund policy is the same idea at the side-effect boundary: an ordered list of rules over the ledger, each with its own reason, checked before the call runs.
exists the payment is this customer's
is_charge it's a charge, not a refund
succeeded the charge went through
not_refunded nothing in the ledger refunds it
is_extra_charge its invoice still has two succeeded charges not covered by refunds
one_per_conv no refund was executed earlier in this conversation
What it doesn’t have is a rule for “is this the charge the customer asked about?” That’s the request boundary, and it needs either an explicit, confirmed target or a person.
What Breaks
The guards have failure modes of their own, and the replay measured some of them.
Checks that stop good work. Ending the run on a repeat lost 6 correct conversations that went on to answer correctly. A no-evidence check stopped 3 correct answers. A policy check stopped a call the payment service would have refused anyway (it did, in the recording), and in doing so threw away the recovery that followed. Count what a guard stops as well as what it catches; a guard you never measure against correct runs will quietly make the agent worse.
Checks that look at form, not meaning. Provenance proves an id has a source, not that it’s the right id or the customer’s own. The claim check proves a sentence matches a pattern, and a false claim has many sentences: “You should receive your refund today” matches none of them, and a true sentence about last month’s refund matches one.
Limits that turn slow successes into failures. A budget that stops a runaway loop also stops a long investigation. Pick it from the paths you’ve seen, and give “hit the limit” its own outcome, so it’s counted rather than hidden. And a framework’s own limit is a backstop, not a budget: 5,004 model calls is a limit in the same sense that a fuse is a thermostat.
Guards that fire after the damage. A side-effect guard that runs on the second refund contains the failure; the first refund still happened. The earlier the boundary, the cheaper the check.
The failures no guard here can see. 234 of 290 wrong answers passed everything. Reading results correctly, and knowing what the customer meant, aren’t problems a request check can solve. They need decisions moved into tools, verification of the answer itself, or a person. And these counts come from two small models on fictional data, three seeds per question at most. τ-bench (Yao et al., ICLR 2025) proposed pass^k to measure “the reliability of agent behavior over multiple trials”, because even strong agents fail differently on the same task from run to run. The distribution of failures in your system is something only your system’s runs can tell you. How to build an evaluation that finds the ones you didn’t anticipate is the subject of the Production AI articles “Evaluating LLM Applications: What Should You Measure?” and “LLM Evaluation: From Manual Testing to Automated Evaluation”.
When These Patterns Are Worth It
Not every agent needs every guard. Choose by consequence, then by what the replay says each guard costs.
- The agent only reads. The worst outcome is a wrong answer, and most wrong answers here happened at the observation boundary, which request guards don’t see. Start with decisions in tools and reply checks. A budget matters more for cost than for correctness. A repeat guard costs little if it serves the earlier result instead of ending the run (the post-hoc check above).
- The agent can act. Put damage limits before answer quality: rules in code, narrow actions, idempotency keys, a person for what code can’t decide. They hold whatever the model does. Expect them to miss the action that is allowed but unwanted.
- Agents talk to each other. Type the messages before tuning the prompts.
- The agent reads text a third party wrote. Assume some of it is instructions, and decide which legs of the lethal trifecta it really needs.
When it’s too much:
- A provenance check on ids that users type in many formats blocks more than it catches.
- A typed handoff between agents that don’t need to be separate is better solved by removing one.
- A rule duplicated in a guard and in the downstream service needs one owner, or the two drift.
Add a guard when a recorded failure shows its boundary, and measure what it stops.
What to Take Away
- An agent fails at boundaries. The request, the model’s decisions, tool execution, reading results, controlling the run, side effects, and reporting. Find the boundary before reaching for a fix.
- A stronger model, more retries, a better prompt, or another agent changes a rate. A check in code at a boundary changes what is possible, and only for the shapes of failure it can see.
- Provenance catches invented ids that schemas pass. In the replay, 52 of 53, with no false alarms on 202 real ids. It doesn’t know whether an id is the customer’s.
- Most wrong answers pass every guard. 234 of 290 here. Misreading a correct result, and acting on a guessed intent, need decisions in tools, verification, or a person.
- What happens after a guard fires is part of the design. In the frozen replay, ending the run on a harmless repeat lost 6 correct answers. A post-hoc check shows that serving the earlier result instead would have stopped 8 correct conversations in all, not 11.
- The log is the truth; the reply is a claim. Build confirmations from what executed, and type what agents tell each other.
Think About These Use Cases
-
An agent that books travel: It searches flights, holds a seat, and charges a card. For each step, which boundary worries you most? What would a guard at the charge check, and what would it miss?
-
A coding agent in a repository: It reads files, edits them, and runs tests until they pass. What does “stopping early” look like here? What would code check before accepting “done”, and what correct work would that check stop?
-
An email triage agent: It reads incoming mail and can forward, label, and reply. Which leg of the lethal trifecta would you remove first, and what would the agent lose?
-
A research agent with three subagents: Each returns a summary to a lead agent. Design the message a subagent sends back. How does it say “found nothing” differently from “couldn’t search”?
-
Your own agent’s last fifty traces: Sort the failures by boundary. Then write one guard for the most frequent boundary and replay the traces through it. How many failures does it catch, how many good runs does it stop, and how many failures pass it?
If you want to talk one of these through, take it to GPT along with this article. Ask GPT ↗️
Related Sources
- 08-failure-modes: The companion demo: the frozen protocol, the guards, the replay of 543 recorded conversations from demos 01 to 06, the cross-check against 07, every report, and the tests. No model needed.
- Cemri et al.: Why Do Multi-Agent LLM Systems Fail? (arXiv, v3 October 2025): MAST, a taxonomy of 14 failure modes in 3 categories (system design issues, inter-agent misalignment, task verification), with a dataset of more than 1,600 annotated traces from seven multi-agent frameworks.
- Microsoft AI Red Team: Updating the taxonomy of failure modes in agentic AI systems (June 2026): Version 2.0 of a security-focused failure taxonomy for agents, including memory poisoning, agentic supply-chain compromise, and tool-description poisoning, with a link to the whitepaper.
- Yao et al.: τ-bench (ICLR 2025): A benchmark of tool-using customer-service agents, and the pass^k metric for how consistently an agent succeeds across repeated trials. Its repository now points to a newer version of the benchmark.
- Anthropic: Building effective agents (December 2024): Compounding errors, stopping conditions, and ground truth from the environment at each step. The page notes that much of the tooling it describes has changed since publication.
- Anthropic: Writing effective tools for AI agents (September 2025): Overlapping tools, returning only high-signal information, and error responses that give the agent specific, actionable guidance.
- OWASP LLM06:2025 Excessive Agency: Excessive functionality, permissions, and autonomy, and the mitigations: minimal extensions and permissions, authorization in downstream systems, human approval, and rate limiting to limit damage. The 2026 edition of the list numbers it LLM03:2026.
- Simon Willison: The lethal trifecta for AI agents (June 2025): Private data, untrusted content, and external communication, and why the combination turns prompt injection into data theft.
- Amazon Builders’ Library: Making retries safe with idempotent APIs: How an API recognizes a repeated request, so that a retried action has no additional side effects.
What’s Next?
Every pattern in this article is a piece of the system around the model: a check, a limit, a record, a typed message. That’s where the agents phase ends and the next one begins. Once an agent, or any LLM feature, is something people depend on, the questions grow past the agent itself: inputs nobody tested, quality someone has to define and keep, costs that arrive with every request, and failures that have to be seen before a customer reports them.
In the next article, we’ll look at “What Changes When an AI Prototype Goes to Production? (opens in a new tab)”: the requirements and operations that change when a demo becomes something people depend on.