By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
'I changed one sentence. What did I break?' Regression testing answers it in minutes instead of discovering it in support tickets next week. The mechanics are simple: a baseline, a comparison, and a rule for what counts as a regression.
| You changed | Must re-run | Can skip |
|---|---|---|
| A rule or constraint in the prompt | Rule compliance, red-team set, refusal cases | Nothing — rules touch everything |
| Retrieval count or chunk size | Retrieval precision/recall, faithfulness, completeness | Format checks |
| Output format / JSON schema | Schema validation, all downstream parsers | Semantic quality metrics |
| Model or model version | Everything | Nothing. This is a new system. |
| A few-shot example | Behaviour, tone, format, and 'does the example leak' | Retrieval tests |
The mean tells you whether the suite got worse. The per-case diff tells you what got worse, which is what you actually need.
def diff_scores(baseline: dict[str, float], current: dict[str, float], tol=0.05):
"""Return per-case deltas, worst first."""
rows = []
for case_id, old in baseline.items():
new = current.get(case_id)
if new is None:
rows.append((case_id, None, "missing"))
continue
delta = round(new - old, 2)
verdict = ("same" if abs(delta) <= tol
else "worse" if delta < 0 else "better")
rows.append((case_id, delta, verdict))
return sorted(rows, key=lambda r: (r[1] is not None, r[1] or 0))
# [('q_014', -0.54, 'worse'), ('q_002', -0.06, 'worse'), ('q_031', 0.0, 'same'), ...]Three rules, in priority order:
That structure means a prompt change can genuinely improve 50 cases and worsen 2, and you will see exactly which two. Sometimes you accept the trade — but you accept it knowingly and you write it in the changelog.
Eventually you will want to compare two prompts on real traffic. The rules are the same as any product experiment, with two AI-specific twists: hold the model constant so the prompt is the only variable, and judge a sample, because scoring every conversation is expensive and unnecessary.
| Signal | What it tells you | Watch out for |
|---|---|---|
| Judge score on a 5% sample | Quality direction | Judge drift between arms — use one judge version |
| Thumbs / escalations | Real user satisfaction | Rare events need weeks, not days |
| Deflection rate | Did the bot resolve it without a human? | Deflection can rise by refusing harder questions |
| Cost per conversation | Prompt bloat | Longer prompts change latency too |
Key takeaways
Regression testing = baseline + same cases + per-case comparison + a rule.
Which tests to re-run depends on what changed; a model change means everything.
Per-case diffs matter more than the mean — they tell you what to fix.
Hold the model constant when comparing prompts, and judge a sample rather than all traffic.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.