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:

  1. Log full traces: every turn, tool call, tool result, retrieved document, model and prompt version.
  2. Sample many production conversations, stratified by intent, outcome and whether a human took over.
  3. One domain expert notes the first upstream error in each. No predefined categories.
  4. Group the notes into failure categories. An LLM may propose groups; the expert finalizes them.
  5. Count per category. Fix in order of count × severity.
  6. Stop sampling when new conversations add no new category. Repeat after every model or prompt change and on a fixed schedule.
  7. 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.

#FailureEvidenceFix (levers)Detection
F1States a policy or fact that is falseMoffatt v. Air Canada (2024): company held liable for a bereavement-fare rule its chatbot inventedC1, P3, G2Questions with known answers from the source docs; each claim checked against its cited passage
F2Takes an action the business rules forbid (refund, exception, discount)τ-bench airline and retail domains test exactly thisG1, P4Compare end-state database to expected state, not the transcript
F3Same request, different outcome across runsτ-bench airline: Claude 3.5 Sonnet 0.46 at pass^1, 0.225 at pass^4 (leaderboard)W1, G1pass^k with k ≥ N per case
F4Assumes early in a conversation and does not recoverLaban et al. 2025: 39% average drop multi-turn vs single-turn; recaps and lower temperature did not fix itP2, C3Cases with the request split across turns; history seeded, final turn scored
F5Reverses a correct answer when the user pushes backSharma et al. 2023: sycophancy across five assistants, driven by preference trainingG1, P1Follow each correct answer with a challenge turn; measure flip rate
F6Follows instructions planted in user input or tool outputOWASP LLM01; lethal trifecta: private data + untrusted content + outbound channelG3, G4, G6Injection corpus placed in user turns and in tool results; any unauthorized tool call fails the case
F7Calls the wrong tool or passes wrong argumentsTool use examples raised complex-parameter accuracy 72% → 90% (Anthropic)T1, T2, T3Tool name and arguments scored separately from the final reply
F8Acts beyond its authority without confirmationOWASP LLM06 Excessive AgencyG4, G5Cases with irreversible or high-value actions; pass only if confirmation preceded the call
F9Does more than the request needed, using broad inherited permissions (the user’s, or a shared service account)OWASP LLM06: excessive permissions and excessive functionalityG4, G5Cases where the toolset allows more than the request needs; every action and side effect must trace to the request, or the case fails
F10Refuses or deflects a legitimate requestA refuse-everything agent passes safety testsP1, P2Legitimate-request cases next to every safety case; refusal rate tracked
F11Escalates to a human too late, too early, or without context—H1Cases labeled must-escalate / must-not; precision and recall; handoff summary scored
F12Quality falls as the conversation gets longChroma context rot: 18 models degrade as input growsC1, C2, C3Scores bucketed by conversation length and token count
F13Subagent misreads its task, drops handoff info, or stops earlyMAST: 14 failure modes; spec, inter-agent misalignment, verificationM1, M2, W4Trace-level judge on the MAST categories
F14Wrong tone, off-brand, or off-topic—P1, G6Rubric judge calibrated to human labels
F15Too slow or too expensive per conversationMulti-agent ≈ 15× chat tokens (Anthropic)T3, T4, O3, O4p95 latency and tokens per conversation, per case, with a budget threshold
F16Repeats an action with real effects after a crash, timeout or retry (second refund, duplicate email)—G7Kill or retry the run mid-case, then count side effects; more than one per requested action fails
F17Reports a multi-step request done when steps are missing—W5, G2Check 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.

IDLeverWhat to doEvidence
P1Worked examplesShow the reasoning for representative and edge-case customer requests, including allowed requests that look risky—
P2Permission to ask or abstainState that the agent asks a clarifying question when a required detail is missing and says “I don’t know” when sources are silent—
P3Quote, then answerAgent quotes the source passage, answers from it, and retracts any claim it cannot cite—
P4Think step before actingThink 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)
T1Tool designOne 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 callAnthropic
T2Tool use examples1–5 example calls in the tool definition, covering ambiguous parametersComplex-parameter accuracy 72% → 90% (Anthropic)
T3Tool searchLoad tool definitions on demand instead of all up front85% fewer tokens; Opus 4 MCP accuracy 49% → 74% (same source). Cannot be combined with T2
T4Code execution over toolsAgent writes code that calls tools and filters results before they enter context150,000 → 2,000 tokens in one example (Anthropic); programmatic tool calling 37% fewer tokens
C1Just-in-time contextKeep the system prompt to the smallest high-signal set; retrieve policy, account and product data per turnAnthropic
C2CompactionSummarize old turns and clear stale tool results when the session growsSame source
C3Structured stateHold 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 handoffsSame 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).

IDLeverUse whenCost or risk
W1Fixed path (prompt chaining)The intent has a known sequence: verify identity → look up order → apply rule → replyBreaks on requests outside the path; needs W2 in front
W2Intent routingIntents need different prompts, tools or policiesMisroutes become a new failure; score the router alone
W3Parallel votingA high-stakes classification (eligibility, fraud flag) where disagreement should blockN× cost per call
W4Evaluator-optimizerA separate model call grades the draft against a rubric and returns it for revisionEvaluator shares the generator’s blind spots if both use the same model and prompt
W5One item at a timeA request has several parts: work them as a list, in order, and check each one done before starting the nextSlower than parallel work; needs a check per item (G2)
M1Orchestrator + subagentsWork 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)
M2Subagent briefEvery delegation states: objective, output format, tools and sources, task boundariesSame 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.

IDLeverWhat to doEvidence
G1Policy enforced in toolsThe tool checks eligibility, limits and required fields and rejects violations with the reason; the model cannot talk its way past it—
G2External verifier with retryValidate 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 successRepeated sampling: SWE-bench Lite 15.9% → 56% at 250 samples, coverage with a verifier (Brown et al. 2024)
G3Untrusted content as dataTool 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 onceWillison; no known complete defense (OWASP)
G4Least privilegePer-customer, per-session credentials; each tool scoped to the minimum read and write it needsOWASP LLM06
G5Confirmation gateIrreversible or above-threshold actions require explicit customer confirmation, or staff approval, before the call executesSame source
G6Small-model screenA fast classifier with structured output screens user input and tool results before the main model acts, and the reply before it is sent—
G7Checkpoint and safe retrySave state after each completed step and resume from it; every action with real effects carries a request ID so a repeated call is ignored—
H1Human escalationTriggers: 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.

IDLeverUse whenLimit
O1Automated prompt optimizationPrompt is stable in structure and a scored dataset exists (DSPy with GEPA; planned in ADR-0016)Overfits a small or narrow dataset
O2Fine-tuningFixed output format or style, narrow classification, or cost and latency on a high-volume stepDoes not add knowledge; retrieval (C1) does. Corporate model fine-tuning availability limited.
O3DistillationA large model’s outputs on a narrow task train a small model to match itSmall model fails outside the training distribution; keep the large model as fallback
O4Model cascadeRoute each turn by difficulty: small model first, escalate to a larger one when a verifier or confidence check failsNeeds 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.

FailureFix
Single-run comparisons: noise blocks good changes or passes bad ones≥ 5 replicates; compare score distributions
LLM judge disagrees with humansCalibrate 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 answerPass the answer as delimited data, never as instructions
Judge refusal counted as a failMark unscored; retry once
Case label, pass condition or severity is wrongTwo domain experts sign off each case
Near-duplicate cases inflate countsDeduplicate by underlying intent or attack, not wording
Stub tools drift from the real APIsContract-test stubs against live schemas
Real student data in test casesSynthetic name pool; tripwire fails the run on any real record
Broken or placeholder dataset rowsValidate the dataset schema at load
Scorer bug passes bad outputRead a sample of graded transcripts every run
Prompt, rubric or dataset changed silentlyVersion and hash every artifact per run
Results shift because fixtures changeFixed seeds; fixtures committed to the repo
Run cost exceeds budgetHard spend cap per run
Suite saturated: everything passesAdd harder cases from section 1 findings
Offline passes, production failsScore sampled live traffic with the same graders

Sources

Longer version: https://omarclaflin.com/agent-evaluation-playbook-full-version-notes/

Posted in

One response to “Agent Improvement Playbook”