Module 5 · Reliability, observability and cost · Chapter 18 · Free
Eval gates in CI/CD: shipping model and prompt changes safely
- A model or prompt change is a code change. It ships through the same pipeline, with a gate that can stop it.
- The gate runs a fixed golden set, checking correctness, format, refusals, latency and cost against thresholds set from the current version.
- Small sets and flaky judges lie. Size the set, set rerun rules, and canary before rollout.
The picture: the gate is a weighbridge on the deploy road. The limit comes from the last good load, not hope.
- How to build and own a golden set that stays honest.
- What the gate runs, and thresholds from a baseline.
- Block, warn and review outcomes, and who may override.
- Why one point on twenty cases means nothing, with the maths.
Copperline is a made up B2B SaaS company. On a Friday, a prompt tweak for its support copilot merged with no eval run, because prompts were treated as text, not code. All figures are illustrative.
- By Monday, Ana, the support lead, had an illustrative 214 tickets where wrong format answers broke the helpdesk parser.
- Priya Nair, the staff platform engineer, rolled back in minutes, but finding the cause took two days: three prompt edits had shipped together.
- Trust cost most: Ana asked for manual review of every AI change for a month.
Chapter 12 promised this gate. Here we build it.
- Model and prompt changes are code changes.
- The golden set: fixed, representative, versioned.
- What the gate runs, and thresholds from the baseline.
- Outcomes, overrides and flaky evals.
- Shadow and canary, then the break-it lab.
Next: why a prompt gets the same pipeline as a service.
Step 1: A prompt change is a code change
Three things change copilot behaviour: model weights, prompts and retrieval settings. All live in the repo, ship in one pipeline and carry a version.
- Same pull request rules: review, tests and a named approver.
- Same artefact: the deploy records model version, prompt version and eval scores together.
- Same rollback: one command returns to the last version that passed, prompts included.
Think of a prompt as a recipe card that changes the dish even when the chef stays the same. Where the picture breaks down:
- A recipe gives the same dish each time. A model varies run to run.
- One bite cannot test taste. You need a set of cases and a score.
Scoring basics live in the evals chapter. Here we wire the score into the pipeline.
Next: the fixed set.
Step 2: The golden set, fixed and owned like code
The golden set is a fixed set of representative requests, each with expected properties: facts the answer must contain, format it must follow, or a refusal it must give.
- Representative: cover the real mix: common questions, long documents, edge cases and abuse attempts.
- Owned: Priya's team owns the set, Ana owns whether cases match support reality. Changes need review.
- Versioned: every gate result names the set version. A score means nothing without it.
- Refreshed from production: Chapter 17, "Observability for AI services: traces, tokens and quality signals", surfaces new request shapes. Each month, a few anonymised real cases join and stale ones retire.
- Never edited with the change: a prompt pull request may not change the set judging it. Set changes ship separately, first.
Next: what the gate runs.
Step 3: What the gate runs, and where thresholds come from
Every change runs four check groups on the set, in CI, before any traffic:
- Correctness: expected facts present, banned claims absent. Rules score it where possible, a judge model only where rules cannot reach.
- Format: output parses: valid JSON where required, fields present, length in limits. Hard checks, pass or fail per case.
- Refusal behaviour: must refuse cases are refused, must answer cases are not. Both directions count.
- Latency and cost budgets: p95 latency and cost per request stay in budget, so a slower change cannot sneak through.
Thresholds come from the current version, measured on the same set, not from wishes:
- Run the current version three times. That spread is your baseline noise.
- Set the gate a small margin below the baseline mean, wider than that noise.
- Keep absolute floors for safety: refusal cases must pass at 100 percent, no margin.
Predict first:
A threshold the current version cannot reach blocks everything. A gate that always says no gets overridden or deleted, and then it protects nothing. Set the gate from the baseline: at or near 86 percent, minus a small margin for noise.
Next: what the gate does with a result.
Step 4: Block, warn, or ask a human
- Block: a hard check fails, a floor is missed, or a score drops past the margin. No merge, no deploy.
- Warn: a score moves inside the noise band, or cost rises but stays in budget. The change may ship, with the warning on the pull request.
- Human review: a borderline result or judge disagreement spike sends the change to Priya or the on call engineer, failing cases attached.
Overrides are narrow. Only Priya, as gate owner, can override a block, in the pull request, with a written reason and an expiry at the next release. Tom, the SRE, can override a warn. Nobody overrides a refusal floor. Every override is logged.
Next: why eval scores wobble.
Step 5: Flaky evals, judge variance and small numbers
Scores move when nothing real changed. The model varies run to run, and a judge model varies too: the same answer can pass on one run and fail on the next. Treat every score as a range.
- Rerun rule: a borderline result reruns twice more. The gate uses the median of three, never the best.
- No cherry picking: rerunning until green is banned. All runs are recorded.
- Sample size first: ask how many cases sit behind a move. Small sets swing wildly.
Worked example, all figures illustrative. The first golden set had 20 cases. The current copilot passes 17 of 20: 85 percent. A prompt change passes 16: 80 percent.
1. One case is five points. 1 / 20 = 0.05. The scary five point drop is one case flipping.
2. One flip is normal. Tom reruns the unchanged version and gets 17, 16 and 18 passes. Variance alone swings two cases, or 10 points.
3. Grow the set. At 200 cases, one case is 1 / 200 = 0.5 points. A real five point drop now means about 10 cases changed, worth blocking on.
4. Set the margin from the swing. On 20 cases, a margin under 10 points blocks on noise. On 200, Priya sets 2 points: four times the one case step.
5. The lesson. One point on twenty cases is less than one case. Grow the set before you trust the gate.
Next: the last check before rollout.
Step 6: Shadow and canary evaluation before rollout
Passing earns a trial, not the whole fleet. Chapter 12, "Model deploys and rollouts: canary, shadow and rollback", set the stages:
- Shadow: the new version answers real requests unseen by users. Compare answers, latency and cost with the live version.
- Canary: an illustrative 5 percent of users gets the new version. Chapter 17 quality signals, errors and cost are watched against the rest.
- Promote or roll back: each stage has a pass bar set in advance. Miss it and the rollout rolls back.
Think of a dress rehearsal, then opening night in a small theatre. Where the picture breaks down:
- Shadow doubles serving cost while it runs, so it is time boxed.
- A canary slice can miss rare cases. The golden set still runs first.
Next: the picture, then the lab.
Step 7: The picture, a change crossing the gate
Press Next to walk a change to rollout.
- A change opens as a pull request. Nothing ships around the pipeline.
- CI runs the versioned golden set, the same cases the current version faced.
- Correctness, format, refusals, latency and cost are scored against thresholds.
- Block, warn or review. Overrides are named and expiring.
- Passing earns shadow, then a canary slice.
- Each stage clears its bar, or the change rolls back.
Next: the break-it lab. This gate cannot fail.
Step 8: Break-it lab, the gate that cannot fail
Why this exercise: a gate that always passes is worse than no gate, because the team trusts it.
Lab: This is Copperline's eval gate, translated from the chapter's broken eval-gate.yaml into code. This lab runs in your browser and needs JavaScript enabled.
- Together, the faults make green mean nothing.
- The config also set on_fail to warn and counted the best rerun. The fix blocks and takes the median.
Next: mix-ups.
In production practice, eval gates often earn trust slowly: start with warnings, publish scores on every pull request, then make hard checks blocking once the set and thresholds prove stable on your own traffic. Judge scores tend to drift when the judge model changes, so pin the judge version and rerun the baseline when it changes.
Mix-ups to avoid
- "Prompts are content, not code." A prompt change changes behaviour for every user. It gets a gate.
- "A bigger threshold is safer." A bar the current version cannot reach blocks everything and teaches bypassing.
- "Green on twenty cases proves quality." One case is five points at that size. Mostly noise.
- "Rerun until it passes." That shops for luck. Fixed counts and the median keep it honest.
- "The gate replaces canary." The gate checks a fixed set, canary checks real traffic. Both.
Chapter quiz
Five questions, 70% to pass.
Review this chapter in 5 minutes
Watch the whole chapter recapped: a fixed golden set, thresholds from the baseline, block warn and review outcomes, and shadow then canary rollout.
- Model, prompt and retrieval changes are code changes: one repo, one pipeline, one rollback.
- Golden set: fixed, representative, owned, versioned, refreshed from Chapter 17 signals, never edited in the change it judges.
- Gate checks: correctness, format, refusals, latency and cost. Thresholds: baseline minus a margin wider than noise; safety floors at 100 percent.
- Outcomes: block, warn, review. Overrides: gate owner only, written, expiring, logged; refusal floors never.
- Noise maths, illustrative: on 20 cases one case is 5 points; on 200, 0.5. Reruns: median of three.
- Passing earns shadow, then canary, then rollout, per Chapter 12.
Decision rule: if the set is small, the bar is a wish, or the target moved with the change, green means nothing. Fix the gate first.
Review
Glossary
- Eval gate
- Pipeline check that runs an eval set and can block a change. Example: a low score stops the merge.
- Golden set
- Fixed, versioned set of representative requests with expected properties. Example: 200 cases, version 14.
- Baseline
- Current version's measured scores on the same set. Example: 86 percent across three runs.
- Threshold margin
- Small gap below the baseline allowing for noise. Example: gate at 84, baseline 86.
- Judge model
- Model used to score answers rules cannot check. Example: grading expected facts.
- Judge variance
- Score changes from the judge alone on the same answer. Example: pass one run, fail the next.
- Refusal floor
- Absolute pass rate on must refuse cases. Example: 100 percent, no override.
- Shadow evaluation
- New version answers real requests unseen by users. Example: one day before canary.
- Canary evaluation
- New version serves a small slice of users under watch. Example: an illustrative 5 percent slice.
- Override
- Named, reasoned, expiring exception to a block. Example: gate owner approves one release.
Next: "Incident response for AI systems: failure modes and runbooks".