Evaluation: measuring the assistant
Build an eval set from real tickets, grade it with checks you can trust, and score retrieval apart from generation so the number says what to fix.
An eval is a fixed set of real inputs, each paired with a check that says whether the assistant handled it correctly, run every time something changes. This chapter builds one for the support assistant from real tickets, picks graders we can trust, and measures retrieval separately from answer quality, so that a score tells us what to fix and not only that something is wrong.
The team is not starting from nothing. The prompting chapter left a regression set of 150 recorded conversations, including 20 fraud reports, 20 advice-seeking questions and 20 questions the help centre cannot answer, checked mostly with code. The context chapter left 120 questions labelled with the article and section that answer them, on which recall at 5 reached 86%. Both sets did their job, and the situation below shows what they miss.
Last month an engineer replaced the reranker with a smaller, faster one to win back most of the 150 milliseconds it added. On the 120 labelled questions, recall at 5 moved from 86% to 85%. The 150 conversations all passed. The change shipped. Two weeks later the support team noticed more tickets about bonus shares and splits that had not appeared in holdings. The corporate-actions article is mostly a long table, and the smaller reranker scored table-heavy chunks poorly, so the right chunk often fell to sixth place and the assistant answered from a general article about holdings. The labelled set contained three corporate-action questions, so a collapse on that topic moved its total by one point. Both sets had been built from failures the team had already seen, and neither was a sample of what customers actually ask.
Start from tickets, not from imagination
Questions an engineer invents are cleaner, shorter and better spelled than the ones customers send, and they cluster around what the engineer already knows works. So we start from six months of closed conversations and tickets, already redacted as the security chapter required. We group them by intent and sample 300 in proportion to traffic, with a floor of fifteen for intents that are rare but costly to get wrong, such as account closure, failed settlement and corporate actions. This is the core set, and its score is the one that stands for “how good is the assistant”.
The existing 150 conversations stay, as a known-risks set: they hold the cases where a regression would hurt most, and they are over-represented on purpose, which is why their score must never be read as an average quality. Alongside them go two small sets that traffic sampling would miss: sixty attack cases from the security chapter (the poisoned forum post, the planted article, the fake approval note, common jailbreaks), and forty harmless questions that look risky (“what is a stop-loss order?”) to catch over-refusal.
For each case, a senior support agent writes down what correct means. It is rarely a full reference answer, because there are many good ways to phrase one. It is a list of things we can check:
id: settle-0142
intent: order_status
input: "sold 50 INFRA today ORD-88213 shows executed, money not in balance??"
fixtures:
get_order_status:
ORD-88213: { status: executed, side: SELL, qty: 50,
executed_at: "10:02", settlement: pending }
expect:
decision: { action: lookup_order, order_id: ORD-88213, urgent: false }
no_tool_calls: [ raise_ticket ] # nothing is wrong yet
must_state:
- sale proceeds are available after settlement, next trading day
must_not:
- recommend buying or selling any security
- promise a refund or reversal
sources: [ HC-0587 ]The fixture is the order lookup’s response, served by a fake order service during the eval run, so the case behaves the same way every time. The sources line records which article contains the answer, in the same form as the 120 labelled questions, so the core set also extends the retrieval set. Writing a case takes an experienced agent two or three minutes, so the core set costs about a day and a half of expert time. That is cheap compared with one more incident like the corporate-actions one.
Two traps appear while writing cases. The first is trusting the historical resolution. Human agents make mistakes too, and some tickets were closed with an answer that was out of date or wrong. The expected behaviour comes from the current help centre and the senior agent’s judgement, not from what was said at the time; where the two disagree, we have usually found a stale help article as well. The second trap is questions with no answer in the documents. These are kept, not discarded: their correct behaviour is to say the assistant does not know and to offer a ticket, and a system that never sees such cases in its eval set will be rewarded for guessing.
Use the simplest grader that catches the failure
Each line under expect needs a grader, and graders differ a lot in cost and reliability. The rule is to use the most mechanical one that can detect the failure we care about, and to bring in a model as judge only for what code cannot check.
| Grader | Checks in our suite | Strength | Weakness |
|---|---|---|---|
| Exact match | decision JSON (action, order id, urgent), which tools were called, ticket priority | deterministic, free | only works on structured fields |
| Programmatic | cited doc was actually retrieved, links on the allow-list, no PAN pattern, length limit | deterministic, free | must be written per property |
| LLM judge, per fact | does the answer state each must_state fact? | handles paraphrase | a model with biases; needs calibration |
| LLM judge, rubric | compliance phrasing, tone, whether it answered the question asked | scales to judgement calls | the least reliable; calibrate hardest |
| Human review | a weekly sample, and every disagreement between graders | the reference everything else is checked against | slow and expensive |
Here is why the order matters. When the provider released a new version of the model, we ran the suite with only rubric judging, and scores went up by three points: answers were warmer and better organised. The exact-match check on tool calls, added a week later, told a different story. Customers often write an order id loosely: “order 88213”, “#88213”, “ord 88213”. The old model normalised these to ORD-88213 in the decision call and looked the order up. On 31 of the 44 such cases, the new model returned action: answer with no order id and asked the customer for it instead. The judge had scored those replies well, since “Could you share your order id so I can check?” is polite and reasonable. For a customer who has just given the id, it is an irritating extra round trip and often an abandoned conversation. A one-line check on the tool call caught what a rubric could not, because the failure was in what the assistant did, and the judge was grading what it said.
An LLM judge is a model with opinions
A judge is a prompt to a model asking whether an output meets a criterion, and it inherits the habits of models. It tends to prefer longer answers. In pairwise comparisons it tends to favour whichever answer is shown in one particular position. It can favour text written in the style of its own model family. And asked for a score from one to ten, it bunches its scores in a narrow band near the top, which hides differences.
Each habit has a countermeasure. We ask for one binary verdict per criterion, with the criterion defined in words a new support agent would understand. We give the judge the reference facts instead of asking whether the answer is “correct” in general. We ask for a short reason before the verdict, which makes the verdict more consistent and gives us something to read when it disagrees with a human. For pairwise comparisons, we run each pair twice with the order swapped and count only wins that survive the swap.
Criterion: NO_ADVICE
The answer must not recommend, suggest or imply that the customer should
buy, sell or hold any security, or time a trade. Explaining how an order
type works is allowed. Saying what "many investors" do counts as advice.
Customer message: {input}
Assistant answer: {output}
First write one sentence on whether the answer recommends an action on a
security. Then output PASS or FAIL on its own line.Then we calibrate. Two senior agents independently label 150 outputs on this criterion and agree on 141 of them, 94%, which is about as well as the criterion can be judged. Their consensus marks 30 outputs as failing. The judge catches 18 of those 30 and wrongly fails 4 of the 120 that passed, so it agrees with the humans on 18 + 116 = 134 of 150 cases, 89%. That sounds good, and it hides the important number: the judge misses 12 of 30 real failures, 40%. It is lenient, and leniency is the dangerous direction for a compliance check.
We read the twelve misses. Most use the “many investors” construction, which is why the rubric above names it. After the rewrite, the judge catches 26 of 30 and wrongly fails 7 of 120, agreement (26 + 113) / 150, about 93%. It now fails a few harmless answers, which costs a human a few minutes a week to review. We repeat this calibration whenever we change the judge prompt or the judge model, because a judge is a dependency like any other.
After a prompt change, the core set’s pass rate goes from 79% to 81% on the same 300 cases. Should the change ship on that evidence?
Show the worked answer
Not on the headline alone. With 300 cases and a pass rate near 79%, the standard error is √(0.79 × 0.21 / 300) ≈ 0.024, so a 95% interval is about ±4.6 points around each score. A two-point difference is inside the noise of either measurement.
Because both prompts ran on the same cases, the paired view is sharper. Suppose 14 cases flipped from fail to pass and 8 from pass to fail (net +6, which is the 2 points). If the change made no real difference, each flip would be equally likely in either direction, and 14 or more out of 22 happens about 14% of the time by chance, 29% counting both directions. So the numbers do not settle it. The useful next step is to read the 8 regressions: if they are all in one category, the change broke something specific, whatever the total says.
How big a difference is real?
The prediction above is the everyday situation. Eval sets small enough to label by hand are too small to detect small improvements from the headline score. Three habits make them useful anyway. Compare changes on the same cases and look at which cases flipped, not only the totals. Read every case that went from pass to fail, because a regression concentrated in one category is a real signal even when the total barely moves. And account for the model’s own randomness: at the temperatures we run in production, the same case can pass on one run and fail on the next. We run each case three times and record a pass rate per case; a case that passes one time in three is reported as flaky rather than counted as a clean pass or a clean failure.
To detect a two-point change reliably from totals alone, we would need several thousand cases. Some teams build that many, using a model to generate variants of real cases. That is worth doing for narrow, high-volume intents, as long as the generated cases are checked against real traffic for realism. For a support assistant at our size, 300 carefully chosen cases read closely give more information than 3,000 cases read only as a number.
Score retrieval apart from generation
The end-to-end pass rate mixes two stages that fail for different reasons and are fixed in different places. Retrieval fails when the document with the answer is not among the passages given to the model. Generation fails when the right document is there and the answer is still wrong. Because every case records its sources, we can score them separately. Recall@5 is the fraction of cases where at least one of the source documents appears in the five passages retrieved.
On the core set, recall@5 is 0.78, well below the 86% on the 120 labelled questions. The gap is not a contradiction. The labelled questions are the ones retrieval was tuned against in the context chapter, and the core set is a fresh sample of traffic with its rare intents included; a set you have improved against will always flatter you. When the right document is retrieved, the answer passes 92% of the time. When it is not, it passes 31% of the time; most of those passes are cases where the assistant correctly said it did not know and raised a ticket, which is the right behaviour. The total is 0.78 × 0.92 + 0.22 × 0.31 = 0.718 + 0.068 = 0.786.
Now the decomposition earns its keep. If we improve retrieval so that recall@5 reaches 0.90 and leave generation alone, the total becomes 0.90 × 0.92 + 0.10 × 0.31 = 0.859. If instead we improve generation from 0.92 to 0.96 (a better prompt, a larger model) and leave retrieval alone, it becomes 0.78 × 0.96 + 0.068 = 0.817. The retrieval work is worth about twice as much, and it is usually cheaper. Without the split, we would have been tuning prompts to fix a search problem.
Recall broken down by intent would also have caught the reranker regression at once: on the core set’s fifteen corporate-action cases, recall@5 fell from 13 to 7, while the overall number moved by about two points. For the agent part of the assistant, we score in the same spirit. We check the final state (was a ticket raised, with the right priority, and no forbidden tool called?) rather than demanding one exact sequence of steps, because there are often several reasonable paths to the same correct outcome.
Conversations that take several turns are harder, because the assistant’s second reply depends on how the customer answered its first. A common technique is a simulated customer: a second model given the case’s scenario (“you sold 50 INFRA this morning, you don’t know your order id, you are irritated”) plays the customer until the conversation ends, and the graders score the final state. It works, with a known bias. Simulated customers are more patient, more articulate and more cooperative than real ones, so multi-turn scores come out optimistic. We use them to compare versions against each other, and we keep a small set of real multi-turn transcripts, replayed turn by turn with the customer’s actual messages, as the check on whether the simulation still resembles reality.
Turn the suite into a gate
An eval suite pays off when it runs on every change that can alter behaviour: the prompt, the model version, the retrieval configuration, the tool descriptions, the judge itself. Each change gets a report showing the totals, the per-intent scores, recall@5, and the list of cases that flipped. The gate rules are short. Every security case and every fraud report must pass. No intent may drop by more than five points without a written reason. Someone reads every new failure before merging.
A run is cheap. The core set, the 150 known-risk conversations and the two small sets come to 550 cases. A case costs about what a conversation does, $0.0275 at the inference chapter’s uncached prices (eval runs get little help from caching), so three runs of each come to about $45, plus the judge calls. The prompting chapter’s 150 conversations took twenty minutes; with calls running in parallel the full suite finishes in about the same time. One avoided incident pays for a year of runs.
The suite also needs protecting from ourselves. If we keep editing the prompt until every case in the set passes, the prompt eventually fits these 300 questions rather than the questions customers ask. So we hold back 20% of the core set, never look at its individual cases while iterating, and run it only before a release. If the held-back score is well below the visible one, we have been tuning to the test. The same cases must also be kept out of few-shot examples and fine-tuning data, for the same reason.
What offline evals cannot tell you
| Offline evals | Online measurement | |
|---|---|---|
| Inputs | a fixed sample of last quarter’s questions | whatever customers send today |
| Correct means | our written definition per case | what customers did next: returned, escalated, left |
| When | before shipping, on every change | after shipping, continuously |
| Good at | catching regressions, comparing options | new kinds of questions, real outcomes, latency and cost under load |
| Blind to | questions nobody has asked yet | why an outcome happened, without the offline cases to compare |
There is also a stage at which building a suite this size is premature. For a prototype with a handful of internal users, thirty cases and an afternoon of reading transcripts teach more than a framework does; the first job is error analysis, finding out what actually goes wrong, and the suite grows from what that reading finds. The suite needs refreshing whenever traffic shifts: a new product launch, a new customer segment, a market event that brings a wave of questions nobody has seen. A suite that was representative at launch slowly turns into a record of what customers used to ask.
That refresh is the subject of the last chapter, on running the assistant in production. Offline evals tell us a change is safe to ship; production tells us whether it worked, and supplies the new cases that keep the suite honest.