Deployed Lab

Module 3 · Reliability and cost patterns · Chapter 11 · Free

The eval loop: the pattern that makes every other pattern safer

18 min1 clickable picture1 hands-on lab, 1 design exercise1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: a smoke alarm test button, pressed on a schedule, not when you smell smoke.

Pattern card

Pattern: The eval loop.

Problem: Every prompt, model or data edit changes behaviour, and nobody can feel a 5 point quality drop by reading a few outputs.

Forces: Coverage versus freshness, grading cost versus accuracy, shipping speed versus shipping safety.

Solution shape: A fixed golden set, automatic graders, a release gate with thresholds, plus production sampling feeding new cases back in.

Watch out: An eval that cannot block a release is decoration: run, admired and ignored.

The cold open

Made-up Northwind Support ships a friendlier prompt for its help copilot on a Friday. The demo was lovely: ten questions, ten good answers.

The plan for this chapter
  1. Why demos lie, and the loop that replaces them.
  2. Build the golden set: common, hard, forbidden.
  3. Pick graders: rules, models, humans.
  4. The release gate, and the production half.
  5. A worked example, a lab, and when not to eval.

Next: why ten good demos tell you almost nothing.

Step 1: Demos lie, so run the loop instead

A demo uses hand-picked examples, shown once, judged by eye. Three things go wrong:

Think of the loop as a fire drill: boring, scheduled, scored, which is why it works.

Where the picture breaks down:

The eval loop A change runs against the golden set, passes a gate, ships, then live traffic is sampled and failures are mined back into the golden set. Make a changeprompt, model, data Run golden setsame cases, graded Gatethresholds met? Ship itonly if it passes Sample live usescore real traffic Mine failuresbest ones join set fail: fix and run again
  1. A new prompt, model swap, edited help pages or retrieval tweak. Any can move quality either way.
  2. Same fixed cases, graded the same way, every time. That sameness makes two runs comparable.
  3. Scores face thresholds set in advance. Below the line, the release stops here, not in production.
  4. A pass is evidence the change did not break what already worked.
  5. Grade real conversations too. The set cannot contain questions nobody has asked yet.
  6. Read the worst live failures. Each shows a case your set was missing.
  7. The best failures, with checked answers, join the set. The next change faces a fairer test.

Next: what goes into the set that does all this work.

Step 2: The golden set is a fair test, written down

A golden set is a fixed list of cases: a real-style question, its context, and a known-good answer or a clear judging rule.

How big is big enough? A few hundred fresh, checked cases beat a few thousand stale ones. Grow by mining failures, not bulk generation. A wrong "known-good" answer teaches the gate to punish correct behaviour.

Keep the set versioned like code. When policy changes, update affected answers the same week, or the set grades against a world that no longer exists.

Next: who or what marks the answers.

Step 3: Graders, matched to the kind of truth

The analogy is school marking: a machine marks the maths quiz, a teacher marks the essay, and a second teacher samples both to keep standards honest.

Where the picture breaks down:

Deeper grader design: see the AI engineering course chapter Evals.

Next: turning scores into a decision nobody has to argue about.

Step 4: The release gate turns a score into a decision

  1. Run the golden set on every change: prompt, model, retrieval settings, or the underlying data.
  2. Compare scores with thresholds written down before the run, overall and per slice (refunds, billing, forbidden).
  3. Block the release when a score drops past its threshold. Not "discuss it": block it, then investigate.

Per-slice thresholds matter: an average can hold steady while one slice, say refunds, quietly falls apart.

Predict first:

Block it. A safety slice is not tradable against general quality. Eight in a hundred forbidden requests going wrong is a breach pattern, not a rounding error.

Next: the half of the loop that runs after shipping.

Step 5: Production is the other half of the loop

That is why this is a loop, not a test: the set learns from production, and production is protected by the set. Chapter 15, the support copilot case study, runs it end to end.

Next: when not to eval at all.

Step 6: When NOT to eval

Next: the loop catching a real regression, with the numbers shown.

Worked example: a prettier prompt that made refunds worse

The made-up Northwind copilot now has a golden set: 400 cases, graded automatically. All figures are illustrative.

1. Baseline. The current prompt passes 88% of 400 cases: 0.88 × 400 = 352 passing.

2. The change. A friendlier prompt demos beautifully on ten questions. The gate runs the set anyway: 81%, which is 0.81 × 400 = 324 passing.

3. The drop. 352 − 324 = 28 more failures, a 7 point fall. The threshold is a 2 point drop, so the release is blocked.

4. Mine the failures. Of the 28 new failures, 21 sit in refund questions (illustrative). One cause: the refund policy page was reworded last week, and retrieval now surfaces a vaguer paragraph.

5. The fix. Restore the clear page wording, keep the friendly prompt, rerun: back to 88%, and the release ships.

Notice what the loop bought: the bug was in the data, not the prompt, and no demo would have shown it.

Next: build the judgment yourself, sorting cases and drafting a plan.

Hands-on lab: stock a golden set, then plan one

Why this exercise: most eval quality is decided at the case level. Choosing what belongs in the set is the skill; the tooling is routine.

Do this:

  1. Sort the candidate cases in the lab below. For each miss, read the explanation and ask what harm that case would do inside the set.
  2. Then do the design exercise on paper, using the brief below.

Lab: Most eval quality is decided at the case level, so choosing what belongs in the set is the skill and the tooling is routine. This lab runs in your browser and needs JavaScript enabled.

What to notice

Design exercise. Apply the pattern to this brief (illustrative):

Brief: a recipe assistant for home cooks.
Users ask: substitutions, scaling, timings.
Must never: suggest an allergen the user said to avoid.
The recipe database is edited weekly.

Write a one page eval plan sketch:

  1. List your first 5 cases: at least one common, one hard and one forbidden (allergen) case.
  2. Name the grader for each kind: exact checks for quantities and allergens, a model grader for helpfulness, human spot checks to calibrate.
  3. State the threshold that blocks a release, in numbers, overall and for the allergen slice.
  4. Say when you would NOT build this loop: for example, a one weekend prototype for friends, with no real users.

A strong answer sets the allergen slice at 100%, no exceptions, and treats weekly database edits as changes that must pass the gate, since the worked example showed data edits regressing quietly.

Field note, November 2026

In production practice, evals tend to survive when wired into the release path, so skipping takes more effort than running. Golden sets also commonly grow from real failures, not cases written in advance. Treat both as practice patterns, not statistics.

Mix-ups to avoid

Chapter quiz

Five questions. Score 70% or more to mark this chapter complete.

Review this chapter in 5 minutes

Watch the whole chapter recapped: the golden set, matched graders, the release gate, and mining live failures back into the test.

Decision rule: if a change can reach users, it runs the golden set first, and a score below threshold does not ship.

Review

Glossary

Eval loop
Testing every change against a fixed set, gating the release, then feeding production failures back into the set.
Golden set
A fixed list of cases with known-good answers. Example: 400 support questions, checked by hand.
Case
One test item: question, context, and the good answer or judging rule.
Grader
Whatever marks an answer: a rule, a model with a rubric, or a human.
Release gate
A threshold check that can block a release. Example: score may not drop more than 2 points.
Slice
One group of cases scored separately. Example: all refund questions.
Failure mining
Reading real production failures to find new cases and causes.
Leaked answer
An expected answer copied from the system's own output, so the test grades the system against itself.
Calibration
Checking a grader against human marks on a sample, fixing the rubric where they disagree.

Next: "Caching, batching and cost patterns".