Regression Evals in CI
Block merges when prompt/model changes tank quality on the golden suite.
In plain words
Every time someone changes the AI's instructions, a robot reruns a set of test questions and says whether answers got better or worse.
Think of it like…
A smoke alarm and a safety inspection for a building: a quick alarm test runs every day (the smoke suite on each PR), and a full inspection runs on a schedule (the nightly suite), so problems are caught early without closing the building.
Where you’ve seen it
The team has 300 golden cases. A smoke suite of 40 stratified cases runs on every pull request in about 30 seconds (8 parallel workers, ~6 seconds per case end to end) for roughly $0.48; the full 300-case suite runs nightly and on release branches in about 4 minutes for $3.60. A pull request changing the system prompt raises the headline pass rate from 84% to 86% (252 to 258 of 300). A paired comparison shows 16 cases improved and 10 regressed, a McNemar test gives p ≈ 0.33, so the +2 points is not significant, while the per-tag table shows refund-policy accuracy dropped from 91% to 84%. The pull request is blocked on the refund slice with the failing cases linked.
Words you’ll hear
- Baseline
- The scores of the main branch against which a change is compared.
- Paired comparison
- Comparing old and new results case by case on the same inputs.
- Tiered suites
- A small, fast smoke set per pull request and a full set on a schedule.
- Flaky eval
- A case whose pass/fail result changes between identical runs.
Visual diagram
Theory & deep dive
Designing the CI eval suite
Run tiers: a smoke suite (30 to 50 stratified cases that cover each intent, the highest-risk behaviours and recent regressions) on every relevant pull request, and the full suite plus expensive judges nightly or before release. Trigger on path filters (prompts, model config, tool schemas, retrieval settings) so unrelated commits don't burn budget. Pin the model version, set temperature to 0 where possible, fix the judge prompt and model, and store baseline results per case so comparisons are against recorded scores rather than a rerun.
Control cost and latency: run cases in parallel, cache LLM responses keyed by prompt and parameters (record and replay) so unchanged components don't re-call the API, use cheaper deterministic checks first (schema, regex, exact match) and the LLM judge only where needed, and cap tokens per case. Report per-tag results and surface the failing cases in the pull request comment with links to traces, since reviewers need to see *what* regressed, not just a number.
on: pull_request: paths: ["prompts/**", "config/model.yaml", "tools/**"] then run: evals run --suite smoke --baseline main --max-workers 8 --fail-on "tag:refund<0.88"
Statistics, flakiness and gating
Compare on the same cases (paired). Count cases that passed before and failed now (b) and failed before and pass now (c). The McNemar statistic is (|b − c| − 1)² / (b + c): with b = 10 and c = 16 it is (6 − 1)² / 26 = 0.96, p ≈ 0.33, so a headline +2 points on 300 cases is plausible noise. For score metrics use a paired bootstrap confidence interval on the mean difference. Decide thresholds as non-inferiority ("no critical slice drops more than 3 points") and use hard gates for safety and format checks that are deterministic.
Handle flakiness: rerun failures once or twice, track per-case flip rates, quarantine flaky cases with an owner rather than deleting them, and prefer deterministic assertions where possible. Expect the suite to age: refresh cases from production failures, retire obsolete ones and version the dataset and judge so scores remain comparable. Treat CI evals as a regression net, not proof of quality: they complement offline experiments, online A/B tests and production monitoring.
Baseline 252/300 pass, candidate 258/300. Of the changed cases, 16 flipped fail → pass and 10 flipped pass → fail, so the net gain is 6 cases. Because only 26 cases changed, the data can't distinguish this from chance, but the 10 regressions deserve inspection.
How it works, step by step
Step 1 of 41. Trigger on relevant changes
Use path filters so prompt, model, tool and retrieval changes start the eval job.
- Skip
- unrelated commits
When to use it & trade-offs
What it is
Regression evals in CI run your golden dataset automatically on every pull request that touches a prompt, model, retriever, tool schema or guardrail, then compare the results with the baseline from the main branch and fail or warn the build if quality drops. It's unit testing for AI behaviour, with two differences: outputs are stochastic and costly, so you need tiered suites, fixed settings, per-slice thresholds and statistical comparison (paired tests on the same cases) instead of simple equality checks.
Why it matters: AI changes break things invisibly: a prompt edit that fixes one case degrades five others, and a model version bump quietly shifts tone, formatting or tool use. Without automated checks, quality drifts until users notice. CI evals make every change measurable, give reviewers a per-tag diff in the pull request and let teams move quickly because regressions are caught before merge.
When to reach for it
- Every change to prompts, models, tools or retrieval
- Model or provider upgrades
- Protecting safety-critical behaviours with hard gates
When to avoid or be careful
- Gating only on the overall average
- Rerunning the baseline each time with different settings
- Deleting flaky cases instead of fixing or quarantining them
Where each kind of evaluation fits
Strengths: Fast feedback; repeatable; per-slice diffs.
Watch out: Covers only what's in the dataset; costs API spend.
Strengths: Large, thorough comparisons.
Watch out: Slower; run on demand.
Strengths: True outcomes.
Watch out: Needs traffic; slower and riskier.
Interview signals & numbers to know
When this topic comes up
- “Prompt changes keep breaking other things”
- “Evals in CI”
- “Is a 2-point gain real?”
- Smoke versus nightly suites
- Flaky LLM tests
Benchmarks & rules of thumb
- 40 / 300
- smoke and full suite sizes in the example
- $0.48 / $3.60
- approximate cost per smoke and full run
- p ≈ 0.33
- McNemar result for +2 points on 300 cases
Common mistakes & follow-ups
Common interview mistakes
- Blocking on a 1-point average change that is within noise.
- Letting the judge model or prompt change silently between runs.
- Running the full suite on every commit and exhausting the budget.
Likely interviewer follow-ups
- How would you set up evals in CI for an LLM feature?
- How do you tell a real regression from noise?
- How do you control the cost of running evals?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Regression Evals in CI with generative AI interview Q&A and hands-on practice.