Evals 1: Why, Error Analysis, Datasets

The skill that separates teams who ship AI features that keep working from teams who ship demos. Five pages, one running example, and the whole loop: find the failures, measure them, trust the measurement, and use it to decide.

This guide assumes you've done the builder track. You wrote 15–20 promptfoo cases in Phase 3 and read the one-section overview of evals as a lifecycle. Here we go deep enough that you can own evals for any AI feature in your company, and defend the numbers in a launch review.

The five pages

PagePart of the question it answers
1 · Foundations (this page) — Why evals decide whether an AI product works to Eval datasets: golden sets, synthetic data, coverageWhat should we measure, and on which cases?
2 · Graders, judges, statistics — Evals 2: Graders: code checks, reference metrics, LLM judges, humans to Evals 2: The statistics of evals: noise, sample size, error barsHow do we score a case, can we trust the scorer, and is a difference real?
3 · RAG and agents — Evals 3: Evaluating RAG: retrieval and generation, separately to Evals 3: Evaluating agents: trajectories, tool calls, end stateWhat changes for retrieval pipelines and multi-step agents?
4 · Production — Evals 4: Online evals: production signals, A/B tests, monitoring to Evals 4: Safety and adversarial evalsHow do evals run online, in CI, and against attackers?
5 · Leading + capstone — Evals 5: Leading with evals: launch reviews, model migrations, ownership to Evals 5: Build it yourself: an eval harness for the support copilotHow do evals drive decisions in a company? Then build the harness yourself.

The running example is the support-ticket copilot from the customer support chapter. It works for a mid-size SaaS that gets about 400 tickets a day. It reads a ticket, retrieves help-center articles, calls get_order and issue_refund, and drafts a reply. The policy is the same on every page: refunds up to $50 are issued directly, refunds over $50 need a human's approval, and nothing delivered more than 30 days ago is refundable.

Why evals decide whether an AI product works

You already wrote 15–20 promptfoo cases in Phase 3 and read the one-page evals lifecycle. This guide starts where those stop. The question for the whole guide is: how do you know your AI feature got better, not just different? This section explains why that question needs its own engineering discipline, and why the discipline begins with your own data, not with a tool.

Eval — a repeatable measurement of how well an AI system does a specific job. It takes inputs, runs your system, grades the outputs, and returns a number you can compare across versions. An eval is an instrument, like a thermometer. A bad thermometer is worse than none, because you will trust it.

Why vibe checks stop working

Vibe check — you change the prompt, try five inputs by hand, and decide it "feels better". Vibe checks are useful. Anthropic's engineering team says early teams can go "surprisingly far" on manual testing, dogfooding and intuition. They stop working once the feature is live, for three reasons.

  • Non-determinism. The same input can give different outputs on different runs. Five good answers in a row may be luck, and one bad answer may be luck too. You cannot tell a real regression from noise by eye.
  • A long tail of inputs. Real users write things you never imagined: three questions in one ticket, a pasted email thread, a language you did not plan for. Five hand-picked prompts are the inputs you already think about. Production is the inputs you do not.
  • Fixes that break other things. A prompt is one shared text that controls every behavior. Editing it to fix one case moves every other case, and you cannot see the others move.

Here is the failure in the support copilot. The team ships prompt v13 to make drafts warmer. The tone check on five tickets looks great. The new prompt also says "always make the customer feel taken care of". The model reads that as permission to say "I've gone ahead and refunded you" on tickets the policy forbids refunding.

Measure (illustrative)Prompt v12Prompt v13
Tone rated "warm" by reviewer (5 tickets)3 of 55 of 5
Refund tickets, ~60 per day––
Drafts promising a refund the policy forbids2%, about 1 a day9%, about 5 a day

Nobody sees this on day one. The first sign is a finance review three weeks later. A vibe check cannot catch it because the five tickets were not refund tickets. An eval that counts policy-breaking refund promises over a fixed set of refund tickets catches it before the deploy.

An eval is a test, a metric and an experiment in one

Engineers already know three tools. An eval borrows one idea from each.

ToolWhat it gives youWhat AI breaks
TestA fixed input and a pass/fail check, run on every changeOutputs vary, so "equals expected" rarely works
MetricA number over many cases, tracked over timeA number with no link to your failures misleads
ExperimentTwo versions compared on the same dataSmall samples and noise fake a difference (Evals 2: The statistics of evals: noise, sample size, error bars)

So an eval is a set of cases (test), reduced to a pass rate (metric), used to compare two versions (experiment). All three are needed. Tests without a metric tell you one case failed but not whether things got better overall. A metric without fixed cases changes under your feet. A comparison without noise control gives you a winner that is just luck.

The three levels of evaluation

Hamel Husain's "Your AI Product Needs Evals" (2024) splits evaluation into three levels and says cost rises with each. They catch different things, so you use all three.

A three-step ladder, cheapest at the bottom. Level 1, code assertions: run on every commit, take seconds, catch hard rule breaks such as a missing tool call. Level 2, model and human graded evals: run on every prompt change or each week, take minutes for a judge and about two hours for a human to read 100 traces, catch judgment problems such as a forbidden refund promise. Level 3, A/B tests on real users: take about 47 days to detect a 2 point change at 400 tickets a day, catch what users actually do. Cost and time per run rise from Level 1 to Level 3, while how often you can run them falls.
The three levels of evaluation. Read it as: push each check down to the cheapest level that can catch it. Level 3 is slow because statistics need thousands of users, so Levels 1 and 2 are the filter in front of it.
LevelCatchesCost and speed
1. Code assertions (unit tests)Hard rules: tool called, JSON valid, no leaked ID, refund tool not called over $50 without approvalSeconds, near zero cost. Run on every commit
2. Model- and human-gradedJudgment: was the tone right, was the answer faithful to the KB, did it promise something forbiddenAbout $2 per run for 200 cases with an LLM judge. About 2 hours for a human to read 100 traces. Hours to set up
3. A/B test on real usersWhat users actually do: accept the draft, reopen the ticketDays to weeks. Needs traffic and a safe rollout

The cost of Level 3 is mostly time, set by statistics. Say the draft acceptance rate is 60% and you want to detect a 2-point drop. You need about 9,500 tickets per arm at 95% confidence and 80% power. At 400 tickets a day split 50/50, that is about 47 days. You cannot A/B test every prompt tweak. That is why Levels 1 and 2 exist: they are the cheap filter in front of the expensive test.

Rule of thumb: push every check as far down the ladder as it will go. If a code assertion can catch it, do not use a judge. If a judge can catch it, do not wait for an A/B test. Level 3 answers a different question: not "did the output follow the rules" but "do users get more value".

Eval-driven development, and where its own authors disagree

Eval-driven development — like test-driven development: write the eval first, watch it fail, then change the system until it passes. For a bug you have already seen, this is simply good practice. When the refund promise appears in production, you add the failing tickets to the eval set first. Then you fix the prompt. Now you know the fix works and you know it stays fixed.

Two respected sources give different advice on the stronger version of the idea.

  • Anthropic's agent-evals post (Jan 2026) recommends it for capability evals: write evals for things the agent cannot do yet, start at a low pass rate, and watch it climb. It also says 20–50 simple tasks drawn from real failures is a good start.
  • Hamel Husain and Shreya Shankar's FAQ answers "should I build evals before looking at data?" with "generally no": it "sounds appealing but creates more problems than it solves". Their rule is to write evaluators for errors you discover, not errors you imagine. The exception is a known hard constraint, such as "never mention competitors".

These fit together once you separate two cases. For a known constraint or a failure you have already observed, write the eval first. For a failure you only suspect, read data first; imagined failure lists are usually wrong. In the copilot, "never promise a refund the policy forbids" is a known constraint, so it gets an eval on day one. "Maybe the tone is off in some way" is a guess, so you look at tickets first.

Why generic metrics and public benchmarks mislead

Many teams buy a dashboard of ready-made scores: "helpfulness 4.2 out of 5", "hallucination score 0.12", "coherence". Husain and Shankar's FAQ is blunt: generic evaluations "waste time and create false confidence" when used as quality measures. Three reasons.

  • They do not match your failures. "Helpfulness 4.2" is an average over everything. The copilot's real failure, an out-of-policy refund promise, can sit inside a draft that scores 5 for helpfulness. A promise of money is very helpful, until finance sees it.
  • They are hard to act on. What do you change to move 4.2 to 4.4? A 1–5 scale has fuzzy middle values (is it a 3 or a 4?). Detecting a small shift needs a large sample. A pass/fail question on a named failure tells you what to fix.
  • Old reference metrics do not fit. BLEU and ROUGE count word overlap with one reference answer. A good support reply can be worded a hundred ways. Overlap with one of them says little about whether the customer is helped.

The FAQ's suggested use for generic scores is narrow: use them to find traces worth reading, not as a measure of quality.

Public benchmarks — shared test sets such as MMLU, GPQA Diamond or SWE-bench that compare general-purpose models. They help you pick a candidate model to try first. They do not tell you how a model does on your feature, for three reasons. The tasks are not your tasks (multiple-choice knowledge versus drafting a policy-correct reply from a KB and an order record). Top models cluster near the ceiling, so differences are small. And test questions leak into training data. The FAQ says a high score on GPQA Diamond or Terminal-Bench "gives you little information" on your product's quality.

The loop this guide teaches

The guide follows one loop. Analyze: read real traces and name the failures (Error analysis: read your data before you measure it). Measure: turn each important failure into a check you can run, and make sure the check is trustworthy (Eval datasets: golden sets, synthetic data, coverage to Evals 2: The statistics of evals: noise, sample size, error bars). Improve: change the prompt, retrieval, tools or model, and re-run. Then production gives you new traces, and the loop starts again.

Three boxes in a row joined by arrows. Analyze: read real traces and name the failures, section 2. Measure: turn each important failure into a trusted check, sections 3 to 6. Improve: change the prompt, retrieval, tools or model and re-run the checks. A long arrow runs from Improve back to Analyze, labeled new traces from production.
The loop: analyze, measure, improve. Read it as: the loop starts with reading data, not with a tool. Every pass through production hands you new traces, and new traces show failures your last checks did not cover.

Notice what the loop does not start with: a tool, a framework, or a metric. It starts with your data. Husain and Shankar report spending 60–80% of development time on error analysis and evaluation in the projects they have worked on. That is not a sign of waste. It is where the product's quality is actually decided.

Error analysis: read your data before you measure it

Error analysis — reading real traces, writing down what went wrong, grouping the notes into named failure types, and counting them. It is the practice Hamel Husain and Shreya Shankar teach, and their FAQ calls it "the most important activity in evals". It comes first because it tells you which evals are worth building. Without it you measure what is easy to measure instead of what is breaking.

Trace — the full record of one run: the user input, every retrieval, every tool call and result, every model call, and the final output. Without the intermediate steps you only see the symptom.

The method is borrowed from qualitative research (grounded theory). Two terms matter. Open coding — read each trace and write a free-form note about what is wrong, with no fixed categories yet. Husain compares it to journaling. Axial coding — afterwards, group similar notes into a small set of named failure types, the failure taxonomy. The FAQ calls this "the most important step". Then you count.

A funnel of five stages. 100 sampled traces: 60 random, 25 stratified, 15 flagged. 41 failing traces, each with one open-coding note about the first failure. 6 failure categories plus one other bucket, after axial coding and counting. 4 failure types become evals, using one LLM judge and three code or retrieval checks. 1 more gets a prompt fix with a cheap code guard, and the smallest category is watched until the next cycle.
From traces to a prioritized eval plan. Read it as: each step throws away volume and keeps meaning. You read 100, but you build about 4 evals, and every one points at a failure you saw with your own eyes.

Who reads: one domain expert, not a committee

The person who reads must be able to say "this answer is wrong" and be right. For the copilot, that is someone who knows the refund policy and what a good support reply looks like: a senior support lead, not the engineer who wrote the prompt. The FAQ recommends appointing a single domain expert as a benevolent dictator — the one person whose judgment sets the quality bar. They say this works for most small and mid-size companies, and that a single expert "eliminates annotation conflicts" and stops committee paralysis. Larger or multi-domain organizations may need several annotators; then you measure agreement (for example Cohen's kappa) rather than assuming it.

The engineer's job is to remove friction. Husain says to "remove all friction from the process of looking at data". That usually means a small custom trace viewer: one screen per trace, with the ticket, the retrieved articles, the tool calls and results, and the draft, rendered the way a support lead reads them, plus a notes box and a "N of 100 reviewed" counter. Generic observability UIs show JSON. A domain expert will not read JSON for two hours. The FAQ says a notebook is fine to start, and a coding assistant can build a custom viewer in an afternoon.

How to sample traces

Start with about 100 traces. The FAQ says to annotate at least the first 30 yourself and to keep going while you are still learning new things. Where the traces come from matters more than the exact count. Mix three sources.

SourceWhyCopilot example
RandomUnbiased view of what typically happens. Finds failures no signal flags. The FAQ says keep some random traces in every batch60 tickets at random from the last 14 days
StratifiedMakes sure rare but important groups appear. Divide traffic by a feature, sample each group25 tickets: refund, shipping, billing, account, bug report, in at least 4 each; long threads; non-English
FlaggedEnriches for failures. Signals: thumbs-down, heavy agent edits, reopened tickets, retries, unusual tool sequences, long traces15 drafts the agent rewrote by more than half

If you have no real traffic yet, generate synthetic inputs to start (Eval datasets: golden sets, synthetic data, coverage covers how). Real traces always replace them as soon as you have them.

import random

random.seed(7)  # fixed seed: the sample is reproducible

def sample(traces, n_random=60, n_strat=25, n_flag=15):
    """Pick ~100 traces: random + stratified + flagged."""
    pool = list(traces)
    chosen = {t["id"]: t for t in random.sample(pool, n_random)}

    by_intent = {}
    for t in pool:
        by_intent.setdefault(t["intent"], []).append(t)
    per = max(1, n_strat // len(by_intent))
    for group in by_intent.values():
        for t in random.sample(group, min(per, len(group))):
            chosen.setdefault(t["id"], t)

    flagged = [t for t in pool if t["thumbs_down"] or t["edit_ratio"] > 0.5]
    for t in random.sample(flagged, min(n_flag, len(flagged))):
        chosen.setdefault(t["id"], t)
    return list(chosen.values())

Tag each trace with the source it came from. Flagged traces are over-represented on purpose, so never use them to estimate how often a failure happens. Use random traces for rates and flagged traces for finding new failure types.

Open coding: write down the first thing that went wrong

For each trace, the expert records two things: a pass or fail verdict and a short written note (a critique) saying what went wrong. Binary verdicts, not 1–5 scores: the FAQ says binary labels "force clearer thinking and more consistent labeling", and Husain's LLM-judge post says critiques should be detailed enough to later serve as examples for a judge.

The key rule: note the first upstream failure, not every symptom. Errors in a trace cascade. If retrieval returns the wrong article, the model then writes a wrong answer, then the tone is off because it guesses. Three symptoms, one cause. Fix the cause and all three vanish. The FAQ says to focus on the first failure in each trace, since upstream errors cause downstream ones.

Trace 0412 as a chain of four boxes joined by arrows. First box, in red and marked note this: the agent never called get_order, so it had no purchase date. Next three boxes, dashed grey, are symptoms that follow: it assumed the order was in the return window, it promised a refund the policy forbids, and the customer was told it was already arranged. Fixing the first box removes all three symptoms.
Note the first failure, not every symptom. Read it as: errors cascade. Write one note for the cause at the front of the chain. Counting all four would make one bug look like four.
trace 0412  FAIL
  ticket: "Bought 6 weeks ago, broke. Refund?"  (policy: 30 days)
  note: Drafted "I've arranged your refund". Policy says 30 days.
        Never called get_order, so no purchase date. Promised anyway.

trace 0413  PASS

trace 0419  FAIL
  ticket: "Where is order 8812?"
  note: Answered "arrives Thursday" with no get_order call.
        Invented the date.

Notes should be specific and in plain words, as a person would say them to a colleague. Do not write category names yet. If you write "hallucination" on trace 3, you stop noticing that it is two different problems (invented dates from a missing tool call, and invented policy from a stale article). Keep reading until new traces stop revealing new kinds of failure. Grounded-theory researchers call that theoretical saturation. The FAQ defines it as the point where new reviews stop revealing failure modes or changing existing ones.

One more reason to write notes first: Shankar and colleagues, in "Who Validates the Validators?" (2024), found that people need criteria to grade outputs, but grading outputs also helps them define the criteria. Your standards change as you read. So you cannot write the rubric first and apply it.

Axial coding: from notes to a failure taxonomy

When you have about 30–50 notes, group them. Use short names that describe what the system did wrong, in a form someone can act on: "promised refund outside policy", not "bad refund". Aim for roughly 5–10 categories. Merge ones that are the same cause; split ones where the fix would differ. Then go back and assign every trace to a category. A trace gets one category: its first failure.

An LLM can help here. The FAQ allows an LLM to propose first-pass groupings after you have open-coded 30 or more traces, and to search the remaining traces for likely instances of the failures you described. Your review is still the check: you accept or reject its suggestions. The line they draw is that you must read the first traces yourself, and must validate the taxonomy yourself.

Count, then prioritize

Counting turns a pile of notes into a decision. Make a table with each failure type, how many of the traces it hit, and the share. Then rank by count times severity, not count alone. Ten harmless typos matter less than three leaked customer emails. Severity is a judgment call by your domain expert, so write it down.

Be honest about uncertainty. With 100 random traces, 10 failures could be a true rate anywhere from about 5.5% to 17% (95% Wilson interval). Three failures could be anywhere from 1% to 8.5%. The ranking at the top is reliable. The ranking among the small ones is not. Do not agonize over whether a category had 4 or 5 hits.

Worked example: 100 support-copilot traces

The sample: 60 random, 25 stratified, 15 flagged. The support lead reviews them in the viewer in about two hours. 59 pass. 41 fail, each with one first-upstream-failure note. Axial coding gives six categories and a small "other".

Failure type (first failure)TracesSeverityAction
1. Promises refund outside policy10 (10%)High: costs moneyEval + fix
2. Retrieves wrong or stale KB article8 (8%)MediumRetrieval eval
3. States order status without calling get_order7 (7%)High: false infoEval + fix
4. Misses escalation (legal threat, chargeback)6 (6%)High: riskEval + fix
5. Replies in English to a non-English ticket5 (5%)MediumFix, one assertion
6. Answers only the first of several questions3 (3%)LowWatch, re-check next cycle
Other, one-off2 (2%)MixedLog

Total 41. The table is the eval plan. Now decide, per row, what kind of fix and what kind of grader.

Which failures need an eval, and which just need a fix

Not every failure deserves an eval. An eval costs effort to build, run and maintain. Ask two questions in order. Can a cheap fix remove it? If the failure is a missing instruction, add the instruction and look again. Will it come back? If a future change could reintroduce it and the cost is real, add an eval as a guard. The FAQ's rule for the grader: first check whether code can test the condition; use an LLM judge only when the failure needs human judgment.

FailureFix firstGrader
Refund promise outside policyPrompt rule + pass purchase date; issue_refund already gated over $50LLM judge, binary, rubric from the policy (the wording is fuzzy). Code check backs it up: no refund promise when get_order shows over 30 days
Wrong or stale KB articleFix chunking or index freshnessCode: recall@k against labeled article ids (Evals 3: Evaluating RAG: retrieval and generation, separately)
Status without get_orderPrompt: "never state order facts without a tool result"Code on the trajectory: tool call present before any order claim (Evals 3: Evaluating agents: trajectories, tool calls, end state)
Missed escalationAdd escalation rule and examplesCode on the escalate flag over labeled tickets; judge only for subtle cases
Wrong languageOne prompt line: "reply in the ticket's language"Code: language-detect assertion. No judge needed
Only first question answeredWait. 3 of 100 is within noiseNone yet

Count the result: of six categories, only one needs an LLM judge, and that one has a code backstop. Two are pure code. One is retrieval. One is a one-line prompt fix plus a cheap guard. Most failures do not need an LLM judge. Teams that skip error analysis usually reach for judges first, because "LLM-as-judge" sounds like the general answer.

Add the traces from each category into the eval set. The 10 refund-promise traces, with the support lead's verdicts, become the first cases for that eval. This is the "20–50 tasks from real failures" Anthropic describes. Build the dataset properly in Eval datasets: golden sets, synthetic data, coverage; validate the judge in Evals 2: Trusting your judge: validating LLM-as-judge.

How often to repeat

Error analysis is not a one-time project. The FAQ's guidance: re-run it after big changes (new feature, prompt overhaul, model switch, major bug fix); aim for at least 100 fresh traces each review cycle; typical cycles run 2–4 weeks; and between cycles read 10–20 traces a week, focusing on outliers. Always run it after an incident or when a metric drifts. When you have just changed something big, 20–50 traces and 30 minutes can be enough for a first look.

Use fresh traces each time, not the same 100. The eval set will pass the failures you already fixed. Only new traces show what you have not found yet. Then update the taxonomy: some categories shrink to zero (retire their evals to a regression suite), and new ones appear.

Traps

Next, Eval datasets: golden sets, synthetic data, coverage turns these categories into datasets you can run on every change.

Eval datasets: golden sets, synthetic data, coverage

An eval is only as good as the cases in it. If the set holds 50 easy questions that your team made up in an afternoon, a score of 94% tells you the feature handles easy questions. It tells you nothing about the ticket that makes your support copilot refund the wrong order.

This section is about three decisions: where cases come from, what each case contains, and how you split them into sets that do different jobs. The next question, how many cases you need before a score means anything, is in Evals 2: The statistics of evals: noise, sample size, error bars.

Some terms first.

  • Eval case — one test: an input, the context it runs in, and what a good result looks like.
  • Eval set (or dataset) — a list of cases that you run together and score as one number per metric.
  • Golden set — a set whose expected answers were checked by a person you trust. "Golden" means trusted, not perfect.
  • Slice — the subset of cases that share a tag, such as all intent=refund cases.

Where cases come from

There are four sources. They differ in realism, cost and blind spots.

SourceStrengthWeakness
Production tracesReal wording, real mess, real failuresNeeds privacy handling; rare cases are rare
Hand-written edge casesYou control exactly what is testedOnly covers what you imagined
Synthetic (LLM-made)Cheap; fills gaps in coverageBland and repetitive unless structured
Red-team / adversarialFinds abuse paths (see Evals 4: Safety and adversarial evals)Skewed toward attacks, not normal use

Rank them in this order. Production traces first. In Error analysis: read your data before you measure it you read real traces and named the failure modes. Each named failure mode, with two or three real examples, is a case you did not have to invent. That is the best case you can get, because a user already hit it.

Then hand-written cases for things production has not shown you yet, such as a policy that starts next month. Then synthetic data to fill the holes in coverage. If you have 100 or more real, representative traces, you need little synthetic data. Husain's evals FAQ says the same: use synthetic data when you have too little real data, and run it through the real system before you trust it.

What a test case contains

A case is more than a question. The agent has state: the customer's orders, the KB version, the date. If you leave state out, the same input gives a different right answer next month.

  • Input — what the user sent (the ticket text, plus any earlier messages).
  • Context / state — everything the system reads besides the input: a frozen order record, the KB snapshot, the current date, the customer plan.
  • Expectation — what "good" means. Either a reference answer, a rubric (a list of yes/no criteria), or a checkable end state.
  • Tags — labels you will slice by: intent, risk level, difficulty, language.
  • Source — where it came from (trace id, hand-written, synthetic) and when it was added.
id: refund-0142
source: {type: production, trace: tr_8f3a, added: 2026-09-14}
tags: {intent: refund, risk: high, difficulty: hard, lang: en}
input:
  ticket: |
    I was charged twice for order 88213 and I want both
    refunded. Also my invoice has the wrong address.
state:
  orders: {"88213": {total: 64.00, charges: 2, status: delivered}}
  today: 2026-09-20
expect:
  must_call: [get_order]
  must_not_call: [issue_refund]     # $64 > $50: needs approval
  end_state: {refund_pending_approval: true}
  rubric:
    - Mentions both issues (double charge, address)
    - Does not promise the refund is done
    - Cites the refund policy article

Notice the expectation is mostly checks, not a model answer. The order was $64, so the copilot must not refund directly, because refunds over $50 need a human. A reference answer for this ticket would be one of a hundred valid replies. The checks are the part that must hold.

Reference answers versus reference-free criteria

There are two ways to say what good looks like.

  • Reference answer — a written correct answer. You compare the model output to it. Works when there is one right answer: "What is the refund window?" → "30 days".
  • Reference-free criteria — rules that any good answer must satisfy, with no model answer: "does not promise a refund", "cites a KB article", "under 150 words".

Open-ended output (a drafted reply) rarely has one right answer, so criteria are the better default. Use reference answers for facts and for tool arguments. How each is graded is in Evals 2: Graders: code checks, reference metrics, LLM judges, humans.

Synthetic data by dimensions

The tempting way: tell an LLM "write 100 test questions for a support bot". You get 100 polite, well-formed, similar questions. Many are near duplicates. They read like an LLM wrote them, because one did. Real tickets are angry, short, misspelled, and vague.

The fix is to add structure before the LLM writes anything. This is the approach Husain and Shankar teach:

  1. Pick dimensions — the axes along which your inputs vary and your system could fail. Take them from the failure modes you found in Error analysis: read your data before you measure it.
  2. Make tuples — one value from each dimension, such as (angry customer, refund, double charge, ambiguous order). Sample from the grid, or write the likely ones by hand.
  3. Have a person check the tuples — drop impossible or silly combinations.
  4. Turn each tuple into an input in a second, separate LLM call: "write the exact message this customer would send".

Splitting steps 2 and 4 matters. When one prompt both picks the scenario and writes the text, the LLM repeats its favourite scenarios. When you choose the scenarios, it only has to write.

DimensionValues (support copilot)Why it is an axis
Personanew user, admin, angry, non-native speakerTone changes parsing
Intentrefund, order status, how-to, cancel, bug reportPicks tools and KB area
Scenarioclear, two issues in one, missing info, out of policyWhere agents break
Riskrefund ≤ $50, refund > $50, account changeWhere mistakes cost money

This grid is 4 × 5 × 4 × 3 = 240 combinations. You will not run all of them. Sample 60 to 100, weighted toward risky and common combinations. Each case gets its tuple as tags for free.

Four sources feed one pool of tagged cases: production traces found in error analysis, hand-written edge cases, synthetic cases generated from dimension tuples, and adversarial cases from red-teaming. Every case carries tags and a source field. The pool is split into four sets: a small regression set that runs in CI on every change, a larger release set run before launches, a held-out set that nobody tunes on, and an adversarial set covered in section 11. Production bugs flow back into the pool.
From raw sources to the sets that do different jobs. Read it as: sources are mixed, but the sets are not. Each set has one job and one rule about who may look at it. The tags let you slice any set by category.

Coverage and stratification

Coverage — how much of the space of real inputs your set touches. Stratification — making sure each category has enough cases to say something about it.

Tag every case when you add it. Then report the score per slice, not only overall. An overall 90% can hide 55% on "refund > $50", the slice that matters most. A uniform random sample of production would put few cases there, since high-value refunds are rare. So you oversample them on purpose.

Two rules for the support copilot set:

Because you oversample, the overall score no longer predicts the production pass rate. If you need that number, weight each slice by its share of real traffic (the support queue is, say, 38% order status, 22% how-to, 14% refund). Report both: the weighted score for forecasting, the slice scores for debugging.

Separate sets with different jobs

One big set used for everything does all jobs badly. Split by purpose.

SetSizeJob and rule
Regression~50-100Runs in CI on every change. Fast, cheap, mostly deterministic checks. Every fixed bug lands here.
Releasehundreds+Run before a launch or model switch. Stratified, covers all slices. Slow and costly is fine.
Held-out~100-200Nobody tunes prompts on it. You look at its score rarely, to check whether tuning on the other sets generalised.
AdversarialvariesAttacks and abuse; scored separately (Evals 4: Safety and adversarial evals).

The regression set must be small so engineers run it without thinking. If it takes 40 minutes, people skip it. How to wire it into CI is in Evals 4: Evals in CI/CD and as a shared platform.

Versioning and keeping the set alive

Treat the dataset like code. Keep it in the repo or a versioned store. Give each release a version (support-v14). Record the dataset version next to every score. Without that, "we went from 82% to 86%" may only mean the cases changed.

Rules that prevent most confusion:

  • Never edit a case silently. Change it in a new version, with a note.
  • Compare two systems only on the same dataset version.
  • When you add hard cases, the score drops. Say so in the change note, and re-run the previous system on the new version for a fair baseline.

A set that never changes goes stale. The product, the KB and the users all drift. Make "add the case" part of closing a bug: when a customer complaint or an incident traces to a copilot error, the fix is not done until the failing ticket is a regression case. Once a month, sample 50 recent production tickets and check whether the set still looks like them (the loop in Evals 4: Online evals: production signals, A/B tests, monitoring).

Contamination and overfitting to your own set

There are two ways your score becomes a lie.

  • Overfitting to the eval set — you read failures, edit the prompt until those cases pass, repeat. After ten rounds the prompt contains the answer to each case. The score rises, and real quality does not. The held-out set exists to catch this: if the tuned set gains 8 points and the held-out set gains 1, you overfit.
  • Contamination — eval cases leaking into something the model learns from or reads. Public benchmarks get into training data. In your own system, it happens when eval cases are pasted into few-shot examples, or when you fine-tune on tickets that include the eval tickets.

Guard: keep an ID list of eval cases, and check that no training data, few-shot example or KB article matches it. Keep the held-out set out of the repo's prompt-tuning workflow (a separate file, read by the release job only). Anyone who tunes against the held-out set turns it into a second tuning set.

Personal data in eval data

Production traces contain names, emails, order numbers and addresses. Copying them into an eval repo creates a second copy of personal data that has no deletion process and many readers. This is a compliance problem, and customers can have a right to deletion.

  • Scrub or replace personal data before a trace becomes a case: swap real names, emails and ids for fake but consistent ones (the same fake name every time it appears in one case).
  • Keep the link back to the original trace id, not its text. Then a deletion request can find and remove the case.
  • Check the replacement did not break the case. "Refund order 88213 to jane@x.com" must still match the order in the frozen state.

Worked example: the support-copilot dataset spec

Putting it together for the support-ticket copilot. About 400 tickets arrive per day. After error analysis you have six named failure modes.

SetCasesBuilt from
Regression802-3 real examples per failure mode (≈15), plus the hardest from each intent and every fixed bug
Release400150 production, 150 synthetic from the grid, 100 hand-written policy edge cases
Held-out120Random production sample, labelled once by two support leads, then locked
Adversarial60Injection in ticket text, social-engineering for refunds

The sizes follow from the statistics in Evals 2: The statistics of evals: noise, sample size, error bars. At 80 cases a pass rate has a 95% interval of about ±8 points, which is fine to catch big breakage in CI but not to compare two prompts. At 400 the interval is about ±4 points. For comparing versions you use the paired method of Evals 2: Paired comparisons: same questions, both versions, which needs fewer.

Check yourself

Question 1

Your team ships a prompt that makes copilot drafts warmer. Five hand-checked tickets all look better, yet two weeks later finance reports more out-of-policy refund promises. Name the three reasons the vibe check could not see this, and say what you would have run on the prompt change instead.

Show answer

Non-determinism (a few runs cannot separate a real change from luck), the long tail (the five tickets were not refund tickets), and cross-behavior side effects (one shared prompt controls every behavior, so a tone edit moved refund behavior). Run a fixed set of refund tickets through both prompt versions and compare the rate of forbidden promises, ideally as a code check on the trajectory plus a validated judge for the wording. Judge the change on behaviors you did not mean to touch.

Question 2

Draft acceptance is 60%. A PM wants to A/B test every prompt tweak for a 2-point improvement at 400 tickets a day. Estimate how long one test takes, and say which cheaper levels should gate it.

Show answer

Variance of a 60% rate is 0.24. Sample per arm is about 2 × (1.96 + 0.84)² × 0.24 / 0.02² ≈ 9,400 (the exact two-proportion formula, with 0.2436 for the 58% arm, gives about 9,500). At 200 tickets per arm per day that is about 47 days. So A/B tests are for big decisions only. Code assertions on every commit and a judge-graded offline set per change filter out most bad candidates first, and the A/B test confirms user value on the few that survive.

Question 3

A vendor dashboard shows "helpfulness 4.4/5" and "hallucination 0.03" on your copilot, and a new model tops MMLU. Your lead wants to switch models. What would you ask for before agreeing, and what is the one use of the generic scores that is fair?

Show answer

Ask for a product eval on your own failure types (policy-breaking refund promises, skipped tool calls, missed escalations) run on both models over the same fixed cases, with uncertainty. Generic scores average over failures that may not be yours, and a refund promise can score high on helpfulness. MMLU compares general models and says little about your feature. The fair use of a generic score is to surface traces worth reading, not to measure quality.

Question 4

Anthropic recommends eval-driven development, while Husain and Shankar's FAQ answers "generally no" to building evals before looking at data. Using the copilot, give one case where you would write the eval first and one where you would not.

Show answer

Write first for a known constraint or a failure you have already observed: "never promise a refund outside the 30-day policy" is a rule, and the failing tickets go in before the fix. Do not write first for suspected failures, such as "maybe the tone is off". Imagined failure lists are mostly wrong, so read traces and write evaluators for errors you discover. The two positions agree once you separate known from imagined.

Question 5

In trace 0412 the agent skipped get_order, assumed the order was in the return window, promised a refund, and told the customer it was arranged. Your annotator wrote four notes. How many failure categories should this trace add to the count, and what goes wrong if you count all four?

Show answer

One: "state or action taken without calling get_order", the first upstream failure. The other three are symptoms of it. Counting all four inflates totals, spreads one cause across several categories so none looks big enough to prioritize, and sends you to fix symptoms (a refund-wording judge) when one prompt line or a tool-call check removes them all.

Question 6

After reading 100 traces you have: refund promises 10, wrong KB article 8, no get_order call 7, missed escalation 6, wrong language 5, only first question answered 3. Which would you give an LLM judge, which code checks, which just a fix, and what do you say about the last row?

Show answer

Refund promises get a judge for the fuzzy wording, with a code backstop on the order date. Wrong KB article gets a retrieval check (recall against labeled article ids). No get_order and missed escalation get code checks on the trajectory and flags. Wrong language gets a one-line prompt fix plus a language-detect assertion. The last row, 3 of 100, has a 95% interval of about 1% to 8.5%, so it is within noise of its neighbors. Watch it and re-check on fresh traces next cycle instead of building an eval.

Question 7

Your synthetic set of 300 copilot tickets scores 96%, but production spot-checks score 81%. Name two likely causes and the cheapest test for each.

Show answer

(1) The synthetic tickets are cleaner and more complete than real ones: show 20 mixed real/synthetic tickets to a support agent and see if they can spot the fakes; fix by adding noise and using real tickets as style examples. (2) The prompt was tuned on the same cases (overfitting) or the tuples cover easy scenarios only: score the held-out set, and compare slice coverage against the failure modes from error analysis. If held-out is also near 96%, the problem is realism, not overfitting.

Question 8

A case says: expected reply = "Refunds are accepted within 30 days." Policy changes to 45 days. What happens to your eval, and how should the case have been written?

Show answer

Correct new replies now fail against the stale reference, so scores fall for the wrong reason, and an old wrong reply would pass. Write the expectation as a criterion that points at the live KB ("states the refund window given in the cited article") or tie the reference to a KB version in the case state. Reference answers suit facts that never change.

Question 9

A team's release dashboard shows 82% last month and 86% this month. List three things to check before saying the product improved.

Show answer

(1) Same dataset version? Cases may have been removed, or hard ones deleted. (2) Same grader/judge version and prompt? (3) Interval: with a few hundred cases ±4 means the two overlap. Also: is the comparison paired, and did the held-out set move too? If only the tuned set moved, it is overfitting.

Sources

Next

You know what to measure and which cases to measure it on. Next, page 2 covers how to score each case (code checks, reference metrics, LLM judges, humans), how to prove your LLM judge agrees with your expert, and how to tell a real improvement from noise.