Scope
This playbook maps each way an agent fails (customer-facing or internal) along with the changes that fixes it and the test that catches it. The eval document takes the Detection column of the failure table as its requirements. Fixes are referenced by lever ID: P = prompt, T = tools, C = context, W = workflow, M = multi-agent, G = runtime guard, H = human escalation, O = optimization; each lever is defined once, in sections 3–6.
Purpose
(1) To provide a playbook on how to categorize and fix AI issues. (2) To guide planning of the architecture around AI agentic systems (e.g. consideration of types of workflows, mulit-agent orchestration, types of guardrails). (3) To guide and focus our AI evaluations processes and keep them reasonably scoped.
1. Error analysis comes before any change
No lever is chosen until real transcripts show which failure it fixes. Method from Husain and Shankar:
- Log full traces: every turn, tool call, tool result, retrieved document, model and prompt version.
- Sample many production conversations, stratified by intent, outcome and whether a human took over.
- One domain expert notes the first upstream error in each. No predefined categories.
- Group the notes into failure categories. An LLM may propose groups; the expert finalizes them.
- Count per category. Fix in order of count × severity.
- Stop sampling when new conversations add no new category. Repeat after every model or prompt change and on a fixed schedule.
- Each category becomes a row in section 2 and a test set in the eval document.
On a model upgrade, re-run the evals with each lever removed. Keep only the levers that still change the score.
2. Failure modes: fix and detection
Each row is one failure. The Detection column is the requirement handed to the eval document.
| # | Failure | Evidence | Fix (levers) | Detection |
|---|---|---|---|---|
| F1 | States a policy or fact that is false | Moffatt v. Air Canada (2024): company held liable for a bereavement-fare rule its chatbot invented | C1, P3, G2 | Questions with known answers from the source docs; each claim checked against its cited passage |
| F2 | Takes an action the business rules forbid (refund, exception, discount) | τ-bench airline and retail domains test exactly this | G1, P4 | Compare end-state database to expected state, not the transcript |
| F3 | Same request, different outcome across runs | τ-bench airline: Claude 3.5 Sonnet 0.46 at pass^1, 0.225 at pass^4 (leaderboard) | W1, G1 | pass^k with k ≥ N per case |
| F4 | Assumes early in a conversation and does not recover | Laban et al. 2025: 39% average drop multi-turn vs single-turn; recaps and lower temperature did not fix it | P2, C3 | Cases with the request split across turns; history seeded, final turn scored |
| F5 | Reverses a correct answer when the user pushes back | Sharma et al. 2023: sycophancy across five assistants, driven by preference training | G1, P1 | Follow each correct answer with a challenge turn; measure flip rate |
| F6 | Follows instructions planted in user input or tool output | OWASP LLM01; lethal trifecta: private data + untrusted content + outbound channel | G3, G4, G6 | Injection corpus placed in user turns and in tool results; any unauthorized tool call fails the case |
| F7 | Calls the wrong tool or passes wrong arguments | Tool use examples raised complex-parameter accuracy 72% → 90% (Anthropic) | T1, T2, T3 | Tool name and arguments scored separately from the final reply |
| F8 | Acts beyond its authority without confirmation | OWASP LLM06 Excessive Agency | G4, G5 | Cases with irreversible or high-value actions; pass only if confirmation preceded the call |
| F9 | Does more than the request needed, using broad inherited permissions (the user’s, or a shared service account) | OWASP LLM06: excessive permissions and excessive functionality | G4, G5 | Cases where the toolset allows more than the request needs; every action and side effect must trace to the request, or the case fails |
| F10 | Refuses or deflects a legitimate request | A refuse-everything agent passes safety tests | P1, P2 | Legitimate-request cases next to every safety case; refusal rate tracked |
| F11 | Escalates to a human too late, too early, or without context | — | H1 | Cases labeled must-escalate / must-not; precision and recall; handoff summary scored |
| F12 | Quality falls as the conversation gets long | Chroma context rot: 18 models degrade as input grows | C1, C2, C3 | Scores bucketed by conversation length and token count |
| F13 | Subagent misreads its task, drops handoff info, or stops early | MAST: 14 failure modes; spec, inter-agent misalignment, verification | M1, M2, W4 | Trace-level judge on the MAST categories |
| F14 | Wrong tone, off-brand, or off-topic | — | P1, G6 | Rubric judge calibrated to human labels |
| F15 | Too slow or too expensive per conversation | Multi-agent ≈ 15× chat tokens (Anthropic) | T3, T4, O3, O4 | p95 latency and tokens per conversation, per case, with a budget threshold |
| F16 | Repeats an action with real effects after a crash, timeout or retry (second refund, duplicate email) | — | G7 | Kill or retry the run mid-case, then count side effects; more than one per requested action fails |
| F17 | Reports a multi-step request done when steps are missing | — | W5, G2 | Check the end result in the real system or interface, not the agent’s report; any missing step fails |
3. Single-agent levers
Change these first; they cost the least and add no new failure surface.
| ID | Lever | What to do | Evidence |
|---|---|---|---|
| P1 | Worked examples | Show the reasoning for representative and edge-case customer requests, including allowed requests that look risky | — |
| P2 | Permission to ask or abstain | State that the agent asks a clarifying question when a required detail is missing and says “I don’t know” when sources are silent | — |
| P3 | Quote, then answer | Agent quotes the source passage, answers from it, and retracts any claim it cannot cite | — |
| P4 | Think step before acting | Think tool or extended thinking for multi-step, policy-heavy tool use | τ-bench airline pass^1 0.370 → 0.570 with think tool plus examples; retail 0.783 → 0.812 (Anthropic) |
| T1 | Tool design | One tool per task, not per API endpoint; namespaced names; high-signal results with no raw IDs; pagination and truncation defaults; errors that say how to fix the call | Anthropic |
| T2 | Tool use examples | 1–5 example calls in the tool definition, covering ambiguous parameters | Complex-parameter accuracy 72% → 90% (Anthropic) |
| T3 | Tool search | Load tool definitions on demand instead of all up front | 85% fewer tokens; Opus 4 MCP accuracy 49% → 74% (same source). Cannot be combined with T2 |
| T4 | Code execution over tools | Agent writes code that calls tools and filters results before they enter context | 150,000 → 2,000 tokens in one example (Anthropic); programmatic tool calling 37% fewer tokens |
| C1 | Just-in-time context | Keep the system prompt to the smallest high-signal set; retrieve policy, account and product data per turn | Anthropic |
| C2 | Compaction | Summarize old turns and clear stale tool results when the session grows | Same source |
| C3 | Structured state | Hold case facts (customer, intent, collected fields, actions taken) in a record outside the transcript, re-inject it each turn, and keep it across sessions, channels and human handoffs | Same source (note-taking) |
4. Workflows and multi-agent
Add structure only when a single agent with section 3 levers fails a measured test. Workflows give predictable paths for known tasks; free agents suit tasks whose steps cannot be predicted (Anthropic).
| ID | Lever | Use when | Cost or risk |
|---|---|---|---|
| W1 | Fixed path (prompt chaining) | The intent has a known sequence: verify identity → look up order → apply rule → reply | Breaks on requests outside the path; needs W2 in front |
| W2 | Intent routing | Intents need different prompts, tools or policies | Misroutes become a new failure; score the router alone |
| W3 | Parallel voting | A high-stakes classification (eligibility, fraud flag) where disagreement should block | N× cost per call |
| W4 | Evaluator-optimizer | A separate model call grades the draft against a rubric and returns it for revision | Evaluator shares the generator’s blind spots if both use the same model and prompt |
| W5 | One item at a time | A request has several parts: work them as a list, in order, and check each one done before starting the next | Slower than parallel work; needs a check per item (G2) |
| M1 | Orchestrator + subagents | Work splits into independent parts, or one agent needs 20+ tools, or context must be isolated | ≈ 3×-15× chat tokens; poor fit when agents must share context or depend on each other (Anthropic) |
| M2 | Subagent brief | Every delegation states: objective, output format, tools and sources, task boundaries | Same source; vague briefs are a MAST specification failure |
5. Runtime guards and escalation
A rule in the prompt is enforced only by the model, and a model checking its own work without outside feedback does not reliably catch errors and sometimes makes them worse. (Huang et al. 2023). The solution for this is either coded rules programmatically executed, or additional checking models.
| ID | Lever | What to do | Evidence |
|---|---|---|---|
| G1 | Policy enforced in tools | The tool checks eligibility, limits and required fields and rejects violations with the reason; the model cannot talk its way past it | — |
| G2 | External verifier with retry | Validate output against a schema, the source docs or a code check; on failure, return the error text and retry once. With a reliable verifier, sampling several drafts and keeping one that passes raises success | Repeated sampling: SWE-bench Lite 15.9% → 56% at 250 samples, coverage with a verifier (Brown et al. 2024) |
| G3 | Untrusted content as data | Tool results and documents arrive only as tool results, encoded, never merged into instructions; no agent holds private data, untrusted input and an outbound channel at once | Willison; no known complete defense (OWASP) |
| G4 | Least privilege | Per-customer, per-session credentials; each tool scoped to the minimum read and write it needs | OWASP LLM06 |
| G5 | Confirmation gate | Irreversible or above-threshold actions require explicit customer confirmation, or staff approval, before the call executes | Same source |
| G6 | Small-model screen | A fast classifier with structured output screens user input and tool results before the main model acts, and the reply before it is sent | — |
| G7 | Checkpoint and safe retry | Save state after each completed step and resume from it; every action with real effects carries a request ID so a repeated call is ignored | — |
| H1 | Human escalation | Triggers: customer asks, policy exception needed, verifier fails twice, low classifier confidence, repeated misunderstanding. Hand over a summary of intent, facts collected and actions taken | — |
6. Optimization
Each of these needs a trusted eval set first; it optimizes toward whatever the eval rewards.
| ID | Lever | Use when | Limit |
|---|---|---|---|
| O1 | Automated prompt optimization | Prompt is stable in structure and a scored dataset exists (DSPy with GEPA; planned in ADR-0016) | Overfits a small or narrow dataset |
| O2 | Fine-tuning | Fixed output format or style, narrow classification, or cost and latency on a high-volume step | Does not add knowledge; retrieval (C1) does. Corporate model fine-tuning availability limited. |
| O3 | Distillation | A large model’s outputs on a narrow task train a small model to match it | Small model fails outside the training distribution; keep the large model as fallback |
| O4 | Model cascade | Route each turn by difficulty: small model first, escalate to a larger one when a verifier or confidence check fails | Needs G2 or a calibrated confidence signal to decide escalation |
7. Eval-method failures
These break the eval itself, whatever the agent does. Test-case coverage (multi-turn, tool scoring, legitimate requests, pass^k) is in section 2 and not repeated here.
| Failure | Fix |
|---|---|
| Single-run comparisons: noise blocks good changes or passes bad ones | ≥ 5 replicates; compare score distributions |
| LLM judge disagrees with humans | Calibrate on human-labeled cases; report agreement before trusting it |
| Judge favors first-listed or longer answers (Zheng et al. 2023) | Score twice with order swapped; rubric penalizes length without content |
| Judge favors output of its own model (same source) | Judge from a different model family than the agent |
| Judge obeys instructions planted in the graded answer | Pass the answer as delimited data, never as instructions |
| Judge refusal counted as a fail | Mark unscored; retry once |
| Case label, pass condition or severity is wrong | Two domain experts sign off each case |
| Near-duplicate cases inflate counts | Deduplicate by underlying intent or attack, not wording |
| Stub tools drift from the real APIs | Contract-test stubs against live schemas |
| Real student data in test cases | Synthetic name pool; tripwire fails the run on any real record |
| Broken or placeholder dataset rows | Validate the dataset schema at load |
| Scorer bug passes bad output | Read a sample of graded transcripts every run |
| Prompt, rubric or dataset changed silently | Version and hash every artifact per run |
| Results shift because fixtures change | Fixed seeds; fixtures committed to the repo |
| Run cost exceeds budget | Hard spend cap per run |
| Suite saturated: everything passes | Add harder cases from section 1 findings |
| Offline passes, production fails | Score sampled live traffic with the same graders |
Sources
- Anthropic: Building effective agents (Dec 2024), Multi-agent research system (Jun 2025), Writing tools for agents (Sep 2025), Context engineering (Sep 2025), Code execution with MCP (Nov 2025), Advanced tool use(Nov 2025), Think tool
- Error analysis: Husain, evals FAQ
- Benchmarks: τ-bench, τ-bench leaderboard
- Papers: Laban et al., multi-turn; Sharma et al., sycophancy; Cemri et al., MAST; Huang et al., self-correction; Brown et al., repeated sampling; Zheng et al., LLM-as-judge; Chroma, context rot
- Security: OWASP LLM01, OWASP LLM06, Willison, lethal trifecta
- Incident: Moffatt v. Air Canada
Longer version: https://omarclaflin.com/agent-evaluation-playbook-full-version-notes/
One response to “Agent Improvement Playbook”
[…] Agent Improvement Playbook […]
LikeLike