AI Development

AD-04

Build the eval harness

What you'll produce: Eval suite with a CI gate

Definition

An eval harness is the code and data that test an AI system the same way every time. It holds a versioned set of cases, checks that score each output, a pinned environment to run them in, and a gate in continuous integration that stops a change from merging when the results are worse than the agreed threshold.

TL;DR

Why a harness and not a spot check

Every team checks outputs by hand at first. That stops working at a predictable point. Hamel Husain describes it from a real product: fixing one failure caused another, nobody could say how the system was doing beyond a feeling, and the prompt kept growing to cover edge cases. Without a fixed set of cases, each change is judged on the three examples someone happened to try.

A harness replaces that with a repeatable run. The same cases, the same checks, the same environment, on every change. Its value is comparison. You can say whether Tuesday's prompt is better than Monday's, and whether a new model version breaks anything you had working.

Our own note on eval design puts the order plainly: decide what failure looks like before the agent exists. The spec supplies that definition. The harness is what enforces it once code starts changing.

Start by reading, not by building

Husain's advice for a minimum setup is to begin with error analysis, not infrastructure. Review a few dozen real outputs whenever something significant changes, and let one person who understands the users make the quality call.

The method is simple and comes from qualitative research.

  1. Collect traces that represent real use.
  2. Read each one and write a free-form note about what went wrong. Record the first failure, because later ones often follow from it.
  3. Group the notes into categories and count them.
  4. Repeat until new traces stop producing new categories.

The counts tell you where to spend effort. They also protect you from generic metrics that look rigorous and measure nothing your users care about.

Three kinds of check

Husain describes levels of evaluation that differ in cost, and the cost decides how often each one runs.

Check What it covers When it runs
Code assertions Structure, required fields, citations, tool calls, prohibited content Every change
Human and model judgment Faithfulness, relevance, tone, anything that needs reading Every change that touches behaviour, or nightly
Live experiments Effect on real users After significant product changes

Assertions first. These are ordinary tests. Organise them by feature and scenario, and add one whenever a new failure shows up in the data. For agents, test the tool name, the arguments, the result, and the state afterwards as separate checks.

Judges second. For criteria code cannot check, Eugene Yan recommends binary labels and one evaluator per dimension. A single judge asked to score five things at once is hard to align, and you cannot tell which dimension is off. He also recommends treating the judge as a model to be validated: hold back part of the labelled data, tune on the rest, and report agreement on the part you held back. Make sure the labelled set has enough failures to learn from.

Outcome before steps. For multi-step agents, Husain suggests scoring whether the run met the goal, then adding step-level checks only where failures cluster.

Pin the environment, measure the noise, set the gate

AI systems do not give identical results on identical inputs, and the environment adds its own variation. Anthropic's engineering team reports that on one agentic coding benchmark, the gap between their most and least generously resourced setups was 6 percentage points, from infrastructure configuration alone. Containers killed for brief memory spikes counted as failures that had nothing to do with the model.

Two practices follow. Record everything that can move a result: model version, tool versions, resource limits, timeouts, retrieval index version. Then run the unchanged system several times and write down the spread. That spread is your noise floor. A gate that blocks on a two-point drop when identical runs differ by three will block at random, and the team will learn to ignore it.

With the noise floor known, the gate is a short list of rules in the pipeline.

  • Any never-rule case fails: block.
  • Any objective assertion fails: block.
  • A judged pass rate falls below baseline by more than the measured noise: block.
  • Anything else: report, do not block.

Run the fast checks on every change. Run the slower judged set on changes to prompts, tools, retrieval, or model version, and nightly. Keep the holdout out of day-to-day tuning and run it before a release. Name one person who can override the gate, and record every override with a reason.

Worked example: a contract summary feature

This example is fictional. A legal operations team builds a feature that reads supplier contracts and returns the renewal date, the notice period, and a short summary of termination terms.

The team reviews 60 outputs with one of the company's lawyers. Four categories account for most failures: a date taken from the wrong clause, a notice period stated when the contract has none, a summary that adds terms not in the text, and a missing clause reference.

They build the suite in three parts. Assertions check that dates parse, that every cited clause number exists in the document, and that the notice field says "not stated" on the eight contracts with no such clause. One judge answers a single question: does the summary contain any term not supported by the cited clauses? The lawyer labels 80 summaries pass or fail with a one-line reason. The judge is tuned on 60 and agrees with her on 18 of the 20 held back. The two disagreements go into the judge's examples and a fresh batch is labelled.

Five identical runs give a judged pass rate between 86 and 89 percent. The gate blocks below 84 percent, or on any failure of the eight "not stated" cases.

Two weeks later a prompt change makes summaries more readable. The suite shows the pass rate at 88 percent, and two "not stated" cases now return an invented notice period. The change is blocked. Nobody would have caught it by reading a few samples.

Common failure modes

  • Building dashboards before reading traces. The metrics end up generic and the real failures go unmeasured.
  • Scores on a scale. Averages of 3.7 and 3.9 start arguments and settle nothing.
  • An unverified judge. A model grading a model, with no human labels to check it against.
  • Tuning against the holdout. Once the builder has seen it, it stops measuring anything new.
  • A gate tighter than the noise. It fails at random and gets switched off.
  • A suite that never grows. Production failures are the best source of new cases.

How it connects to the other pillars

The product pillar supplies the inputs. The rubric and golden set from defining quality become the first cases, and the release criterion in the spec becomes the gate's threshold. If those do not exist, the harness has nothing principled to enforce.

The factory pillar builds on the output. A verification ladder for agent workers is a series of gates, and this harness is one rung: the one that checks model behaviour, next to the tests, type checks, and reviews that check code. An agent worker that can run the suite itself gets feedback in minutes, and a person only has to look at the changes that pass.

Run it yourself

Time: ~2 to 3 days for a first version

  1. Review traces and name the failures — You need: 30 to 100 traces from the prototype and the person whose judgment defines quality. You get: A failure list grouped into categories, with a count for each. Note the first thing that went wrong in each trace. Later errors are often caused by it.
  2. Assemble and split the case set — You need: The labelled cases from the spec, plus one or more cases for each failure category. You get: A versioned case file with expected outcomes, split into a working set and a holdout that nobody tunes against. Include a clear pass, a close-but-wrong case, a refusal for a missing source, a risky action that must escalate, and a right answer with weak evidence.
  3. Write code assertions for objective checks — You need: The case set and the output format. You get: Fast tests for structure, required fields, citations that resolve, tool name and arguments, prohibited content, and resulting state.
  4. Build one judge per subjective criterion — You need: Pass or fail labels with short critiques from the domain expert, on outputs that include plenty of failures. You get: A judge prompt per criterion and its measured agreement with the expert on labels it was not tuned on.
  5. Pin the environment and measure noise — You need: A fixed model version, tool versions, resource limits, and time limits. You get: The spread of results across several identical runs, recorded next to the baseline.
  6. Wire the gate into CI — You need: The baseline, the noise spread, and the never-rules from the spec. You get: A pipeline step with written thresholds, a list of checks that block, and a named override owner.
  7. Feed production back in — You need: Sampled production traces and user-reported failures. You get: New cases added on a schedule, and judges rechecked against fresh labels.

Do it with AI

You are helping me design an eval suite with a CI gate for one AI feature. Work only from what I paste. Do not invent failure modes I have not shown you evidence for. Ask if something is missing.

Feature and task: [ONE SENTENCE]
Definition of correct and never-rules from the spec: [PASTE]
Labelled cases I already have: [PASTE OR DESCRIBE COUNT AND FORMAT]
Notes from reviewing real outputs, one line per trace, stating the first thing that went wrong: [PASTE 30 OR MORE NOTES]
What changes should trigger the suite: [PROMPTS, TOOLS, RETRIEVAL, MODEL VERSION, OTHER]
Time and cost I can afford per CI run: [MINUTES, AMOUNT]

Step 1. Group my notes into failure categories. Give each a name, a one-line definition, and a count. Do not create a category with no supporting note.

Step 2. For each category, say whether it can be checked by code (objective) or needs a judgment (subjective). For objective ones, write the assertion in plain language, precise enough to implement. For subjective ones, write a single pass or fail question and describe what a pass and a fail look like.

Step 3. Propose the case set: which existing cases to keep, which new cases to add per category, and which cases to move to a holdout. Make sure the set includes a clear pass, a close-but-wrong case, a missing-source refusal, a risky action that must escalate, and a correct answer with weak evidence.

Step 4. Propose the gate. List the checks that block a merge outright (never-rules and objective checks), the pass-rate threshold for judged criteria relative to the baseline, how many repeat runs are needed to estimate noise, and what fits in my time and cost limit on every change versus nightly.

Step 5. List what a person must do before this goes live: labels to produce, judges to verify, thresholds to approve.

Output a table of checks (category, type, assertion or question, blocking or not, run on every change or nightly), then the case-set plan, then the gate rules, then open questions.

Chain it

  1. Trace reviewer — Clusters traces and drafts a failure category for each cluster, with example traces; Prototype or production traces → A proposed failure list with counts and examples; gate: The domain expert reviews at least 30 traces by hand and corrects the categories
  2. Case builder — Drafts new cases for each failure category and proposes expected outcomes; The approved failure list and existing labelled cases → A candidate case file with a suggested holdout split; gate: The domain expert approves expected outcomes for the holdout
  3. Check writer — Implements code assertions and drafts one judge prompt per subjective criterion; The case file and the failure definitions → A runnable suite and each judge's agreement with human labels
  4. Gate runner — Runs the suite on every change, compares against the baseline and noise spread, and reports which cases changed; The change, the suite, and the stored baseline → A pass or block decision with the failing cases listed; gate: A named owner decides any override and records the reason

How AI changes this

Automate

Keep human

Stage

FAQ

How many cases do I need to start?

Fewer than most teams expect. A first suite can be the labelled cases from the spec plus one or two cases per failure category you found in review. What matters is that failures are well represented. A set where almost everything passes cannot tell you whether a check works. Grow the set from production failures.

Can I use a model to grade outputs?

Yes, for criteria that code cannot check, with two conditions. Ask one pass or fail question per judge, and measure the judge against a person's labels on examples it was not tuned on. Recheck when you change the judge's model or prompt. An unverified judge is an opinion, not a test.

Why pass or fail instead of a 1 to 5 score?

People rarely agree on where a 3 ends and a 4 begins, and a model judge will not either. A binary label forces a decision about what is acceptable and produces labels that are faster to collect and easier to check. If you need detail, add a short written critique to each label.

What should block a merge?

Any failure on a never-rule case, any failed objective check, and a drop in a judged pass rate that is larger than the run-to-run noise you measured. Everything else can warn. Keep the blocking list short enough that the team trusts it, and name one person who can override it with a recorded reason.

How do I evaluate an agent that takes many steps?

Score the outcome first. Did the run achieve the goal, yes or no? Then, for the workflows that fail most, add step checks for tool choice, arguments, error handling, and whether earlier constraints were kept. Checking steps before outcomes produces a lot of numbers and little direction.

Sources

Related