Eval Gates in CI
Fail the pipeline when quality, safety, or cost metrics regress past thresholds.
In plain words
An eval gate is an automatic check that stops a change from shipping if the AI got worse, more expensive, slower or less safe.
Think of it like…
Quality control at the end of a production line with several tests: a unit must pass the strength test, the safety test, the weight limit and the speed spec; failing any one stops shipment, and the thresholds have tolerances so normal variation doesn't halt the line.
Where you’ve seen it
A pull request changes the system prompt. The gate runs the 300-case suite and compares it with the baseline stored for main. Quality: overall pass rate 86% versus 84% (+2 points); the paired counts are 10 cases that regressed and 16 that improved, so the difference is +6 cases = +2.0 points with standard error √(26 − 6²/300)/300 = 1.7 points and a 95% interval of [−1.3, +5.3]; the gate's rule is non-inferiority (lower bound above −3 points), so overall quality passes. Slice rule: no critical slice may fall by more than 5 points: refunds fall from 41/45 (91.1%) to 38/45 (84.4%), −6.7 points, so it fails. Safety: action-level attack success is 1.1% against a ceiling of 2%: pass. Cost: $0.01305 per request versus $0.01195 (+9.2%) against a +10% budget: pass. Latency: p95 5.4 s versus 4.9 s and an SLO of 5.0 s: fail. The PR comment shows a table of the five checks, links to the failing refund cases and the slow traces, and the check status is "failed" because two blocking gates failed. The author fixes the refund wording and trims retrieved context; the re-run passes, and when the PR merges the new scores become the baseline.
Words you’ll hear
- Non-inferiority margin
- The largest drop you'll tolerate, tested against the confidence interval's lower bound.
- Baseline
- Stored scores of the main branch against which candidates are compared.
- Blocking vs warning gate
- A gate that fails the build versus one that only reports.
- Ratchet
- Updating the baseline or tightening thresholds only after approved improvements.
Visual diagram
Theory & deep dive
Designing thresholds that mean something
Compare the candidate with the baseline on the same cases (paired) and gate on the confidence interval, not the raw difference. With n = 300, b regressions (pass → fail) and c improvements (fail → pass), the difference is (c − b)/n and its standard error is √((b + c) − (b − c)²/n)/n: for b = 10 and c = 16 that is +2.0 points ± 1.7 (95% interval [−1.3, +5.3]). A non-inferiority rule ("the lower bound must exceed −3 points") tolerates normal noise but blocks real regressions; a rule like "any decrease fails" would block roughly half of neutral changes. Choose the margin from how much quality you can afford to lose and how many cases you can run: a smaller margin needs more cases.
Add per-slice rules for critical tags (refunds, safety-relevant intents): a point-estimate limit (no more than a 5-point drop) works on small slices (n = 45) where intervals are wide, optionally with a flag for review when the drop is smaller. Add absolute safety ceilings (action-level ASR ≤ 2%), cost budgets (tokens or dollars per request ≤ +10% of baseline), latency SLOs (p95 ≤ 5.0 s) and format validity gates (schema-valid outputs ≥ 99%). Mark each gate block or warn: new or noisy gates start as warnings, graduate to blocking once their false-block rate is understood. Keep gate definitions in version-controlled config next to the evals so changes are reviewed.
300 cases, 10 regressed, 16 improved: net +6 = +2.0 points. SE = √(26 − 36/300)/300 = √25.88/300 = 0.0170. 95% interval = 2.0 ± 3.3 = [−1.3, +5.3] points. With a −3 margin the gate passes; the same data would fail a rule requiring significant improvement.
Operating gates: noise, overrides and maintenance
Control noise: fix model versions, temperature and judge prompts; run flaky-prone cases several times and use majority or mean; quarantine cases whose results flip between identical runs (with an owner) rather than deleting them; and re-run only failed gates once to separate bad luck from real regressions while logging the retry. Report each gate's historic false-block rate (how often a block was overturned) and tune. Keep the eval suite fast and cheap enough to run on every relevant PR (the 40-case smoke set) and run the full suite nightly and before release; cache deterministic steps and parallelise cases to hold gate time under a few minutes.
Governance: provide an override path (a label such as eval-override that requires a justification and approval from a named owner) and log every override in the audit trail; review overrides monthly. Baselines update only when a change is merged with approved improvements (a ratchet), so the bar rises with the product; store baseline scores with the dataset, judge and model versions. Revisit thresholds when the dataset, model, prices or SLOs change. Complement gates with post-deploy checks (canary analysis, online monitoring), because offline suites miss real traffic. Track outcomes: share of PRs blocked, share of blocks that were real regressions, escaped regressions found in production and time spent on override reviews.
Main branch scores: overall 84%, refunds 91.1%, p95 4.9 s. A merged change improves overall to 86% and holds refunds at 91.1% with approval, so the baseline becomes 86%. The next PR is compared with the new baseline, preventing slow erosion through many small "within noise" drops.
How it works, step by step
Step 1 of 41. Define metrics and slices
Choose quality, safety, cost and latency metrics and tag critical slices with severity.
- Store
- baseline per commit
When to use it & trade-offs
What it is
An eval gate is a pipeline step that blocks or flags a change when measured AI behaviour regresses past agreed thresholds. Gates cover four dimensions: quality (task success overall and on critical slices), safety (action-level attack success rate, policy violations), cost (tokens or dollars per request) and latency (p95 or time to first token). Good gates compare the candidate with a stored baseline from the main branch, use statistical margins instead of raw point differences, apply per-slice rules so averages can't hide a regression, distinguish block from warn, and have a documented, audited override path. They turn evaluation from a report people may read into a control that always runs.
Why it matters: Without gates, evals are advisory: a green average hides a 7-point drop on refunds, a cheaper prompt quietly raises p95 latency past the SLO, or a safety regression ships because nobody looked at the dashboard. Overly strict gates have the opposite failure: noisy thresholds block good changes, teams learn to retry until green or disable the check. The craft is choosing thresholds that catch real regressions at an acceptable false-block rate and keeping them current as the product evolves.
When to reach for it
- Every PR touching prompts, models, tools or retrieval
- Release branches and model upgrades
- Enforcing safety, cost and latency budgets
When to avoid or be careful
- Gating on raw average differences with no margin
- Blocking on noisy new metrics from day one
- Silent baseline resets after regressions
Gate styles
Strengths: Automatic; explainable; catches slice regressions.
Watch out: Needs maintenance and noise control.
Strengths: No friction.
Watch out: Easy to ignore; regressions ship.
Strengths: Human judgement.
Watch out: Slow and inconsistent.
Interview signals & numbers to know
When this topic comes up
- “The average went up but refunds got worse”
- Non-inferiority margin
- Blocking vs warning gates
- Baseline ratchet
- Override audit
Benchmarks & rules of thumb
- [−1.3, +5.3]
- 95% interval for the +2.0-point paired difference
- −6.7 pts
- refund-slice drop that failed the 5-point rule
- +9.2% / 5.4 s
- cost and p95 results versus +10% and 5.0 s limits
Common mistakes & follow-ups
Common interview mistakes
- Letting developers retry until a flaky gate passes without recording it.
- Using one global threshold for all slices.
- Never updating the baseline, so improvements aren't protected.
Likely interviewer follow-ups
- How would you set eval gates for a prompt change?
- How do you avoid blocking good changes because of noise?
- How should overrides be handled?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Eval Gates in CI with generative AI interview Q&A and hands-on practice.