RBRunbook
Study

Domains · Domain 5 · 12% of scored questions

Evaluation Engineering and Quality Assurance

About 7 of the 60 scored questions come from this domain. It has 3 skills:

Lessons

Skill

Evaluation System Design

Designing an offline evaluation system that stays valid

An offline evaluation is a set of tasks, a way to run them, and grading logic. Its job is to tell you, before users see a change, whether a prompt, model, or agent change made things better or worse. This lesson covers the decisions that decide whether that answer can be trusted.

Two suites with two jobs

Anthropic's guidance on agent evals separates two kinds of suite.

SuiteQuestion it answersExpected pass rateUse
RegressionDoes it still do what it used to do?Close to 100%Gate merges and releases
CapabilityWhat can it not do yet?Starts lowMeasure progress

A suite at 100% still catches regressions, but it can no longer show improvement. That is saturation. Near saturation, a large real improvement shows up as a fraction of a point, so the suite makes two different systems look the same. The fix is to add harder tasks, usually taken from recent production failures, and track them separately. Do not delete the saturated suite: capability tasks that pass reliably graduate into the regression suite.

Choose the grader the task allows
  • Code-based (exact match, string match, tests, state checks): fastest, cheapest, reproducible. Use it wherever the answer can be checked by a rule.
  • LLM-based: for judgments a rule cannot express. Validate it against human labels before relying on it.
  • Human: the reference standard, slow and expensive. Use it to calibrate the other two.

For agents, grade the outcome, the state of the environment at the end of the trial, in preference to what the agent says it did or the exact path it took. Exact tool-sequence checks fail valid solutions.

Golden sets and contamination

A golden set is only useful while the system under test has not seen it. Contamination has three common routes:

  1. Tuning on the set. Dozens of prompt revisions selected by the same cases fit those cases. Keep a held-out split that is scored only at release decisions.
  2. Leakage into the prompt. Few-shot examples copied from the golden set make those cases pass for the wrong reason. Score only cases that do not overlap.
  3. Leakage into retrieval. If the reference answers are indexed in the corpus the application searches, the score measures lookup of the answer key.

The signal is the same in each case: the offline score rises while an independent measure, such as an audit of live outputs, does not.

CI/CD gates and release criteria

Model output varies between runs, so a single run of a small suite has noise of several points. A gate with a fixed threshold inside that noise band fails unchanged code and trains engineers to re-run until green. Options, in order of preference:

  • Run several trials per task and use the per-task mean.
  • Compare candidate and baseline on the same tasks (a paired comparison removes task-difficulty variance).
  • Report an interval with the score, and size the suite for the smallest regression you need to detect.

Write release criteria per slice, not only overall. An aggregate can rise while a regulated or high-harm slice falls. A typical rule: no critical slice may regress beyond its noise band, and the overall score must not drop.

Retrieval-grounded systems: measure by stage
MetricStage it isolates
Recall of the labeled passage in the top kRetrieval
Share of answer claims supported by retrieved text (groundedness)Generation
Answer correctnessEnd to end

Low recall with high groundedness means the model is faithful to the wrong passages: fix retrieval. High recall with low groundedness means the model adds unsupported claims: have it find a supporting quote for each claim and retract claims without one, and add a groundedness check to the suite.

Keep the suite honest
  • Convert user-reported failures into test cases. This closes coverage gaps as usage shifts.
  • Test both directions of a behavior (when it should happen and when it should not).
  • Start each trial from a clean environment. Shared state causes correlated failures or inflated scores.
  • Read transcripts. A 0% pass rate on a task across many trials usually means a broken task or grader. A reference solution that passes all graders proves the task is solvable.
Raising the pass threshold on a saturated suite does not restore its signal. The suite still contains only tasks the system already passes; the higher bar only narrows the margin for noise.

Sources
Demystifying evals for AI agents
Define success criteria and build evaluations
A statistical approach to model evaluations
Writing effective tools for agents
Reduce hallucinations
Introducing Contextual Retrieval

Skill

LLM-as-Judge Engineering

Engineering and validating an LLM judge

An LLM judge is a measuring instrument. Before its scores gate a release or feed a dashboard, you need evidence that it measures what human experts would measure. Anthropic's documentation puts it briefly: LLM-based grading is fast and flexible, and you should test it for reliability first, then scale.

First decide whether you need a judge

If the check can be written as a rule (a field equals a verified value, a test passes, a record exists), use code. A judge adds cost, latency, and run-to-run variation. Use one where the judgment needs interpretation: tone, completeness, whether a claim is supported by a source.

Rubric design
  • Explicit criteria. Write what earns each verdict. A vague rubric produces inconsistent verdicts, in humans and in models.
  • Constrained output. Ask for a fixed label such as correct or incorrect, or a defined scale. Free-form assessments cannot be aggregated.
  • One dimension per judge call. A single score for accuracy, compliance, and tone lets a warm tone offset a policy violation. Grade each dimension with its own isolated judge.
  • Reasoning before the score. Let the judge reason before it produces the verdict, for example with thinking enabled. This improves grading on cases that need several steps.
  • A way out. Give the judge a verdict such as Unknown for cases where its input lacks the evidence. Without it, the judge invents grounds for a verdict.
Calibrate against human labels

Collect a set of outputs labeled by domain experts and compare the judge's verdicts with theirs. Read the result as a confusion matrix, not as one number.

MeasureWhat it tells youLimit
Raw agreementShare of items where judge and human matchInflated when one class dominates
Cohen's kappaAgreement corrected for chanceOne number; hides direction of error
Recall on the fail classShare of real failures the judge catchesNeeds enough failures in the set
Precision on the fail classShare of judge failures that are realSame

If 92% of items are passes, a judge that passes everything agrees with humans 92% of the time and catches nothing. When the judge is a gate, recall on the fail class is the number that matters.

Check the humans first

Have two experts label the same items independently and compute their agreement. That figure is the ceiling for the judge. If the experts agree weakly, the guideline is ambiguous, and tuning the judge prompt against those labels fits noise. Rewrite the guideline with anchored criteria, relabel, then calibrate the judge. A good task is one where two domain experts independently reach the same verdict.

Bias and position effects
BiasEvidenceControl
PositionWin rate changes when the order of the two responses is swappedJudge both orders; count only consistent verdicts, or randomize order per item
LengthJudge prefers the longer output; blind human reviewers do notCriteria that score content independently of length; validate on unequal-length pairs
Scale compressionScores cluster on one or two valuesBinary criteria or anchored scale points

The test for any suspected bias is the same: change only the suspect property, hold the content fixed, and see whether the verdict moves.

Judge drift

A judge is a prompt plus a model version. Change either and the instrument changes. Scores from different judge versions are not comparable, even when the new judge is better.

  1. Pin the judge's model version and version its prompt.
  2. Keep a frozen human-labeled calibration set. Run every judge version on it.
  3. When changing the judge, re-score the previous baseline with the new judge so both sides of a comparison use one instrument.
  4. Re-derive gate thresholds from the new baseline.

Calibration also ages when the product changes. A judge calibrated on last year's traffic can fail on a new product line while the overall agreement figure still looks acceptable. Measure agreement per slice and refresh labels when the mix shifts.

A score that jumps when nothing in the application changed is a finding about the measuring instrument. Check the judge's configuration history before reporting a quality gain.

Sources
Define success criteria and build evaluations
Demystifying evals for AI agents
Define outcomes

Skill

Online Quality Measurement

Measuring quality on live traffic

Offline suites test the cases you thought of. Live traffic contains the cases you did not. Online quality measurement answers two questions: how good is the system on real usage right now, and did a change make real outcomes better?

What each online method gives you
MethodStrengthWeakness
Production monitoringReal behavior at scaleReactive; no ground truth for grading
A/B testingMeasures user outcomes and controls for confoundsSlow; needs enough traffic
User feedbackReal examples of problems you did not anticipateSparse and self-selected; skews to severe issues
Transcript reviewFinds subtle failures; builds intuitionDoes not scale

No single layer catches everything. Combine them, and use each for what it is good at.

Sampling live traffic

Decide what the sample is for.

  • Estimating a rate across all traffic needs a uniform random sample. Conversations that received feedback are a small and unrepresentative share, so a rate measured on them does not describe the whole.
  • Watching a rare, high-harm slice needs oversampling. A uniform sample gives too few cases from a slice that is 0.4% of traffic.
  • Doing both means stratified sampling: fix a share of the review budget for the rare slice, then weight each stratum by its traffic share when you compute the overall rate. Pooling the oversampled reviews without weights biases the overall figure.

Feedback-triggered review is still valuable for finding failures. It is a discovery tool, not an estimator.

A/B testing
  1. Fix the plan before launch: primary metric, guardrail metrics, sample size, and when you will analyze.
  2. Choose the randomization unit to match the experience. For multi-turn products assign the user or session, not the request. Per-request assignment mixes both variants inside one conversation, which harms users and makes the arms indistinguishable.
  3. Size the test. With few sessions the interval on the difference is wide, so the result can exclude neither a real gain nor an unacceptable loss. Work out the sample size needed to detect the smallest effect you care about.
  4. Do not stop on a peek. Checking significance repeatedly and stopping the first time it crosses the line produces false positives. Analyze at the planned point, or use a method designed for sequential looks.

A result with an interval of minus 9 to plus 5 points is not evidence of no difference. It is an inconclusive test.

Feedback loops

Explicit feedback and outcome signals can disagree. A friendlier variant can raise the thumbs-up rate while more tickets reopen. Decide in advance which metric states the purpose of the product and treat the others as supporting evidence. Implicit measures such as task completion usually sit closer to the purpose than ratings do.

Close the loop into the offline suite. Triage reported failures, reproduce them, and add them as graded cases. A failure fixed by hand and not added to the suite can return with the next model or prompt change, because nothing checks for it.

Match the metric to the task type
Task typeFitting metricPoor fit
Extraction, classificationField-level or label-level correctness against corrections or delayed ground truth, by segmentA holistic 1 to 5 quality rating
AgenticOutcome in the system of record; turns, tool errorsRating of the final message
Retrieval-groundedShare of claims supported by retrieved passages; retrieval recallNumber of passages retrieved
Open-ended generationCalibrated rubric judge; how much humans edit before useExact match against one reference

A metric that stays flat while users report a problem is measuring something else. Break it out by segment, such as document template, intent, or customer tier, before concluding that quality is stable.

Reporting a failure rate measured only on thumbs-down conversations as the product's failure rate. The sample was selected by the failure it is meant to estimate.

Sources
Demystifying evals for AI agents
Define success criteria and build evaluations
A statistical approach to model evaluations

Sample questions

Sample question
A freight company runs a nightly offline suite of 80 shipment re-routing tasks against its Claude-based agent in a sandbox with a seeded shipments database. Each task is graded by matching the agent's final message against phrases such as "has been re-routed". The suite reports 96%. An engineer replays 20 passing trials and finds this in 5 of them:
tool_result update_route: {"error":"CARRIER_LANE_CLOSED"}
assistant: Your shipment has been re-routed via the Rotterdam hub.
The shipment rows for those 5 trials are unchanged. Which change to the suite most directly closes this gap?
  • AGrade each trial by querying the sandbox database for the expected shipment state
  • BReseed the sandbox database before every trial to remove state left by earlier tasks
  • CRequire the tool-call sequence in each trial to match a recorded reference trajectory
  • DGrade each trial with an LLM judge that scores the final message against a tone rubric
Show the answer and explanation

Answer:

  • Grade each trial by querying the sandbox database for the expected shipment state

The grader reads what the agent said, and the agent said the work was done when the tool had returned an error. What matters is the outcome: the state of the environment at the end of the trial. Checking the shipment record against the expected route catches every trial where the claim and the state differ. A judge that scores the final message still sees only the claim, so it passes the same five trials. Matching a reference tool-call sequence checks the path, and here the agent made the expected call; it was the result that failed, and exact-path checks also fail valid alternative approaches. Reseeding before each trial is good isolation practice, but the evidence shows unchanged rows and a false claim, which leftover state does not explain.

Sample question
An accounts-payable pipeline uses Claude to extract five fields from supplier invoices (supplier ID, invoice number, currency, total, due date) into JSON. The offline suite holds 600 invoices with values verified by the finance team. Outputs are graded by an LLM judge that returns a 1–5 "extraction quality" score per invoice. A full run takes 40 minutes, and two runs over the same stored outputs produced mean scores of 4.31 and 4.18. The team wants to run the suite on every pull request and block merges on regressions. Which grading approach should replace the current one?
  • AHave two reviewers hand-grade a rotating sample of 50 invoices before each merge
  • BReplace the 1–5 scale with a pass or fail verdict from the same judge on each invoice
  • CCompare each extracted field with the verified value in code after normalizing formats
  • DRun the judge three times per invoice and gate merges on the median of the three scores
Show the answer and explanation

Answer:

  • Compare each extracted field with the verified value in code after normalizing formats

Every field has a verified value, so the check is a deterministic comparison. Code-based grading is the fastest and most reliable option when the task allows it: the same outputs always get the same score, a run takes seconds, and a failure names the field that was wrong. Taking the median of three judge runs reduces the noise but triples the cost and time of a grader that is not needed for this task. A pass or fail verdict from the judge is easier to read than a 1–5 score but is still a non-deterministic model call standing in for an equality check. Hand-grading a sample is slow, covers 50 of 600 invoices, and cannot run on every pull request.

↑↓ move↵ openesc close