Forward Deployed EngineeringAI EngineeringBehavioral Regression Testing
Design an eval suite that catches silent quality regressions when you upgrade the underlying model.
Question 60 of 73 · Updated
On this page
- Interview-ready answer
- 1. Test behaviors that ordinary benchmarks miss
- 2. Maintain three independently useful test collections
- 3. Metamorphic testing: verify relationships between outputs
- 4. Differential testing: do not let improvements hide regressions
- 5. Statistical power: plan the suite around detectable losses
- 6. Automate the gate, not the judgment
- 7. Detect silent changes after release
Interview-ready answer#
A silent regression is a behavioral failure that survives ordinary health checks: the API responds, the JSON parses and overall accuracy may even improve, while a previously reliable capability stops working.
I would build a longitudinal behavioral regression suite around three complementary signals: violations of required invariants, newly broken cases relative to a known-good model, and statistically meaningful degradation within important customer slices. I would run the baseline and candidate against the same versioned fixtures, add metamorphic tests that expose sensitivity to irrelevant input changes, and block automatic promotion when required evidence is missing or a critical gate fails.
The objective is not to preserve every old answer. It is to preserve the behaviors the application depends on, detect improvements and losses separately, and make every model upgrade accountable to an explicit release contract.
1. Test behaviors that ordinary benchmarks miss#
A generic benchmark or global accuracy score is not an adequate regression contract for an application. Define invariants with the business owner and evaluate them against observable outcomes.
| Silent failure | Regression probe |
|---|---|
| Valid JSON with changed business semantics | Assert normalized field meanings, units, required facts and allowed values against fixtures |
| Fluent but incomplete policy answer | Check decisive exceptions and required qualifiers, not just answer similarity |
| Correct answer with unsupported evidence | Check claim-level support and source applicability |
| Incorrect tool action with plausible confirmation | Inspect sandbox final state and prohibited effects |
| More conservative model silently refuses ordinary tasks | Measure appropriate abstention and false abstention on answerable cases |
| New tokenizer or stopping behavior removes evidence | Test inputs near practical context and output limits |
| More steps or retries for equivalent work | Compare tool-call counts, completion rates and resource budgets |
Separate behavioral invariants from exact output snapshots. A revised explanation can be better without matching the old wording. Preserve exact values only where the application contract requires them.
2. Maintain three independently useful test collections#
Frozen sentinels: a small, stable set of previously validated cases that runs against every effective model revision. Include production incident regressions, unusual but supported inputs and critical behaviors. Retain fixture versions and historical verdicts; never silently replace the baseline with the latest candidate. A fixed sentinel suite detects cumulative degradation across releases, not just a regression relative to the immediately preceding version.
Fresh representative holdout: periodically collect authorized recent cases reflecting current workloads, including difficult inputs and previously unseen requests. Group related conversations or documents before splitting. This prevents a stable but increasingly stale sentinel suite from creating false confidence.
Challenge and metamorphic suite: systematically generate controlled variations of labeled cases and test expected relationships between their outcomes. Store the base case, transformation, applicability conditions and expected relation. Generated variants are correlated with the original; do not count them as independent population samples.
When a policy genuinely changes, version the expected outcome and retain historical results under the original policy. Otherwise label drift can masquerade as model drift.
3. Metamorphic testing: verify relationships between outputs#
A metamorphic test does not necessarily require one exact gold answer for every variant. It checks whether a known transformation produces the expected relationship in observable behavior.
| Transformation | Expected relation | Preconditions |
|---|---|---|
| Paraphrase a support request | Same eligibility decision and authorized target | Meaning and intent preserved |
| Reorder independent evidence passages | Same required material facts | No order-dependent precedence; all evidence still fits |
| Add an irrelevant document | No change to supported conclusion | Document truly irrelevant, no change to access or context budget |
| Remove the only decisive evidence | Abstain or request clarification | No other authoritative evidence establishes the answer |
| Change a known quantity in a fixture | Correct corresponding change in computed outcome | Rule and remaining inputs unchanged |
| Change only the authenticated identity to an unauthorized one | No protected disclosure or unauthorized action | Authorization context actually changes, not merely text in the prompt |
Some relations demand invariance; others demand a predictable change. This catches models that become sensitive to wording, evidence placement or irrelevant context without lowering standard benchmark scores.
Validate transformation correctness with domain experts or deterministic generators. A paraphrase that changes a policy exception is a different task, not a valid invariance test. Compare normalized semantic outcomes or actual state rather than raw generated strings.
4. Differential testing: do not let improvements hide regressions#
Run both models on identical initial conditions with the same fixtures, evaluator and compatible inference settings. Score each output against an independent contract. Treat disagreements as investigation candidates: the baseline can also be wrong.
Suppose 1,000 cases produce these hypothetical outcomes:
| Outcome | Count |
|---|---|
| Both pass | 850 |
| Baseline passes, candidate fails | 40 |
| Baseline fails, candidate passes | 60 |
| Both fail | 50 |
Overall task success rises from 89% to 91%. Yet 40 previously passing cases now fail: 4% of the entire suite and 4.49% of the baseline-passing subset. If those 40 include an authorization failure or a critical policy exception, the upgrade must not pass merely because the net score improved.
Report gross losses, gains, persistent failures and critical invariant violations independently. Review regressions by failure mechanism and customer slice. Compare against both the immediately preceding release and a long-term reference; otherwise several individually small degradations can accumulate undetected.
FDE-0048 covers migration non-inferiority analysis. Here the additional requirement is a gross-loss budget and invariant protection, even when the net change is positive.
5. Statistical power: plan the suite around detectable losses#
A regression suite must be large enough to detect the degradation the customer cares about. For matched binary outcomes, the difference per independent case is −1, 0 or +1. Let q be the expected fraction of discordant pairs and δ the net degradation worth detecting. Under a simplified large-sample normal planning approximation with variance near q, the required independent case count for a two-sided significance level α and power 1 − β is approximately:
With 5% expected discordance, a two-percentage-point degradation, two-sided α = 0.05 and 80% power, this gives approximately 982 independent cases. This is an illustrative planning calculation, not an exact paired-test sample-size guarantee. Estimate discordance from a pilot and use an appropriate paired power calculation or simulation for the actual design.
Small high-risk slices need their own coverage. If only 20 examples exercise an important behavior, a thousand unrelated easy examples do not provide power to detect its degradation. For repeated generations and transformed variants, cluster analysis at the independent base-case or customer level. Predeclare primary gates and handle multiple comparisons or sequential monitoring appropriately. Inconclusive evidence should trigger more testing or a constrained release, not automatic approval.
6. Automate the gate, not the judgment#
Run a fast invariant and sentinel suite on every candidate; run the larger representative, challenge and load suites before promotion. Record effective model revision, prompt, retrieval and evaluator versions, case IDs, verdicts and evidence. Missing, duplicated or mismatched run results must not become passing scores. Require an independent statistical gate for population-level claims.
A useful deterministic gate enforces an observed gross-loss budget and critical case requirements. The input verdicts must already have been independently evaluated.
PYTHONfrom fractions import Fraction def regression_gate(baseline, candidate, critical, max_loss): # Maps case ID -> independently validated boolean verdict. if not baseline or baseline.keys() != candidate.keys(): return False if not critical <= baseline.keys(): return False if not 0 <= max_loss <= 1: raise ValueError('invalid loss budget') if any(type(v) is not bool for m in (baseline, candidate) for v in m.values()): return False if any(not candidate[k] for k in critical): return False known_good = [k for k in baseline if baseline[k]] if not known_good: return False losses = sum(not candidate[k] for k in known_good) return Fraction(losses, len(known_good)) <= max_loss
Call it separately for mandatory slices with their own budgets; pass exact fractions for thresholds. Validate duplicate case IDs, manifest identity and complete evaluation results before constructing these maps. A False result blocks automatic promotion and triggers investigation. A True result only means this observed gate passed: it is not evidence of statistical non-inferiority, evaluator reliability or zero future risk.
Executed verification: Python 3.13.5 passed 16,392 checks: 16,384 exhaustive combinations of four baseline verdicts, four candidate verdicts, critical-case memberships and four loss budgets, six missing/malformed result cases and two invalid budget cases. The power example was also calculated locally. These tests verify gate logic with synthetic labels, not actual model behavior.
7. Detect silent changes after release#
Run fixed sentinels periodically against the effective deployed model, including provider aliases whose implementation may change without an application deployment. Keep representative production audits and a small stable reference suite even between planned upgrades. Monitor outcome quality, false abstentions, required-fact omissions and tool-state violations by release and risk slice; HTTP success is not a quality signal.
If the gate finds a regression, preserve failing fixtures and classify the failure mechanism. Use the controlled component isolation approach in FDE-0052; do not change the evaluator or prompt simply to recover a score. A validated fallback or narrower capability is preferable to shipping an unexplained critical regression.
FDE-0050 addresses initial launch evaluation; this suite is specifically designed to preserve behavioral commitments over successive model versions while allowing genuine improvements.
References
- 1.
- 2.OpenAI — Evaluation best practices (not live-verified)platform.openai.com
- 3.
- 4.statsmodels — McNemar test (not live-verified)statsmodels.org
- 5.
Related questions
Explore other topics:AI AgentsAI System DesignLarge Language Models