# How Do You Regression-Test Prompts?

> How to catch a prompt or model change that breaks what already worked, using a fixed test set, a baseline and a release gate, explained simply for your AI interview.

**In short:** Keep a fixed set of past cases with agreed good answers, run the whole set on every prompt or model change, and block the change if any case that used to pass now fails. It catches the quiet damage a fix does to behaviour that already worked.

AI and LLM interview question Q257, Evaluation and observability. Intermediate, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-to-regression-test-prompts

## Say it in 30 seconds

A regression test checks that a change didn't break what already worked. I keep a fixed set of past cases, each with an agreed good answer. When I edit a prompt or swap a model, I run the whole set. If a case that passed before now fails, the change waits until we understand why. Every live failure that teaches us something gets added to the set.

## Say it in 2 minutes

Prompts look harmless to edit, and that is the risk. Changing one line to fix a complaint can quietly change how the model handles a case that worked last week. Regression testing is how we catch that before users do. A regression is something that used to work and now doesn't.

I start with a golden set: a fixed list of past cases, each with an agreed good answer or a pass rule written before I look at any output. The cases come from real work, such as a hard claim, a question that confused the bot last month, or an edge case from support. Code checks grade the cases with a clear answer. A judge model, a second AI model that marks answers against a checklist, grades the rest, and only after we have checked the judge against people.

Every change runs the whole set against the same model and settings. I compare each case with the baseline, which is the last version we shipped. A pass that turns into a fail blocks the release until someone understands why. An overall score can hide this, because a gain on new cases can cover a loss on old ones.

A model swap needs the same test. Providers retire older models, and a replacement can behave differently on your tasks. So I run the full set on the new model well before the old one is switched off, and I keep the set growing as live failures teach us something new.

## What is regression testing for prompts, in plain words?

A prompt is the instruction text you send a model. Regression testing asks one question after every change: does the new version still handle everything the old one handled?

Without tests, the usual pattern is reactive. A user complains, someone reproduces the problem by hand, fixes it, and hopes nothing else moved. The fix often works, and the damage shows up a week later in another corner of the product.

Think of a payroll team that reruns last month's pay runs after changing a tax formula, to check that nobody's pay moved by accident. A claims triage prompt needs the same check. An edit that speeds up small hail claims can quietly stop the model flagging a repeat claim.

- **Golden set:** A fixed list of past cases, each with an agreed good answer or pass rule.
- **Baseline:** The results of the version you shipped last, kept to compare against.
- **Pass rule:** What a good answer must do, written down before you see the output.
- **Grader:** The code or the judge model that marks each answer pass or fail.
- **Gate:** The rule that blocks a release if it breaks a case that used to pass.

## How does a regression run work?

A run has four parts: the new version, the golden set, the same model settings and a grader. The output is a list of the cases that changed, with a pass or fail for each one.

*Diagram, How a regression run works: A regression run sends the same fixed cases through the new version and grades every answer. Each result is compared with the baseline one case at a time. A past pass that now fails blocks the release.*
1. You change one thing: the prompt or the model.
2. The same fixed cases go in beside it.
3. The model answers every case with the same settings.
4. Each graded answer is compared with the baseline, case by case.
5. A past pass that now fails means the release is blocked.
6. No past pass has failed, so the change can ship.

1. **Freeze the baseline:** Keep the answers and grades of the version you run today. That is the baseline you compare against.
2. **Change one thing:** Edit one prompt or swap one model. Two changes at once make the cause hard to find.
3. **Run every case:** Send the whole golden set with the same model settings. A different setting is a different test.
4. **Grade each answer:** Code checks mark the cases with a clear answer. A judge model marks the rest against a written checklist of what a good answer does (a rubric).
5. **Gate the release:** Any case that passed in the baseline and fails now blocks the change. A gain elsewhere does not cancel it out. If a case is flaky, repeat it before you gate on it.

## What makes a good regression set?

Start with what has already gone wrong in real use, then add the edge cases you fear. Anthropic's guide asks for evals (tests that score the AI's answers) that mirror your real-world task distribution, and it warns against forgetting edge cases.

A stable set is worth keeping. Anthropic describes capability tests that reach a high pass rate becoming a regression suite, run continuously to catch slow changes in behaviour (drift). The same idea holds for a prompt: once a case is solved, it stays in the set.

> "Regression evals ask, "Does the agent still handle all the tasks it used to?" and should have a nearly 100% pass rate" (Anthropic, on agent evals)
>
> "Set up continuous evaluation (CE) to run evals on every change, monitor your app to identify new cases of nondeterminism, and grow the eval set over time" (OpenAI, evaluation best practices)

Nondeterminism means the same prompt can give a different answer on a second run.

Here is a small worked case. An insurer's claims triage prompt labels each claim fast-track, needs-review or fraud-check. Four cases from real claims work form the set, and each row pairs a claim with its agreed label.

The team's new version is meant to speed up small hail claims. It also stops flagging a repeat claim such as "Third claim on this policy in 30 days". Here is the check in plain Python. Each version's labels are written out, so the gate is what gets tested.

```python
# A regression check for an insurance claims triage prompt. No real model: each
# prompt version's labels are written out, so the grader and the gate are tested.
GOLDEN = [
    {"id": "C-101", "claim": "Hail damage to a parked car, 1,850 USD", "want": "fast-track"},
    {"id": "C-102", "claim": "Third claim on this policy in 30 days", "want": "fraud-check"},
    {"id": "C-103", "claim": "Water leak, 14,000 USD, policy lapsed yesterday", "want": "needs-review"},
    {"id": "C-104", "claim": "Cracked windscreen, 320 USD", "want": "fast-track"},
]
RUNS = {
    "v1": ["fast-track", "fraud-check", "needs-review", "needs-review"],
    "v2": ["fast-track", "fast-track", "needs-review", "fast-track"],
}

def passed(run):
    return {c["id"] for c, label in zip(GOLDEN, run) if label == c["want"]}

for name, run in RUNS.items():
    print(f"{name}: {len(passed(run))}/{len(GOLDEN)} pass")
broke = sorted(passed(RUNS["v1"]) - passed(RUNS["v2"]))
fixed = sorted(passed(RUNS["v2"]) - passed(RUNS["v1"]))
print("v2 broke:", broke or "nothing")
print("v2 fixed:", fixed or "nothing")
print("gate:", "BLOCKED" if broke else "SHIP")
```

Output:

```text
v1: 3/4 pass
v2: 3/4 pass
v2 broke: ['C-102']
v2 fixed: ['C-104']
gate: BLOCKED
```

Both versions pass three of four cases, so the overall pass rate looks flat. A case-by-case list of what changed shows the problem: C-102 breaks and C-104 is fixed. The gate blocks the release, and the team fixes the repeat-claim rule before it ships.

## How do you grade the cases, and how do you handle a model swap?

Pick the grader for each case. Anthropic's guide says to choose the fastest, most reliable, most scalable method for grading, and OpenAI's guide says to structure evals so they can be scored automatically.

- **Clear answer: Code check.** An exact match, a string check or a schema check. Fast, cheap and the same on every run.
- **Needs judgement: Judge model.** A model marks tone or helpfulness against a written rubric. Check it against people first, and expect some noise.

> **Tip:** If a case flips between runs, the pass rule may be vague, or the model gives different answers on each run. Tighten the pass rule, and run that case several times before you trust one result.

A model swap needs the same test. Anthropic says it regularly retires older models, and once one is retired, requests to it fail. Run the full set on the replacement well before the switch-off date, and compare case by case.

> "To help measure the performance of replacement models on your tasks, consider thorough testing of your applications with the new models well before the retirement date" (Anthropic, model deprecations)

### How would you run this in a team's release process?

A pull request changes the prompt file. The team's CI job, the automatic checker that runs on every push, runs a small, quick set of checks on each change and the full golden set each night. Anthropic's guide agrees that automated evals belong in CI, running on each change.

1. **Small set on every change:** Keep the per-change run cheap, so people never skip it.
2. **Full set on a schedule:** Run every case each night and before each release, and keep the results.
3. **Block on a broken case:** Any past pass that fails stops the merge until the owner explains it.
4. **Grow the set:** Each fixed live failure becomes a new case, so it cannot come back unnoticed.

Full runs cost money in model calls, so the per-change set stays small and the bill is checked each month.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: a change that breaks what already worked.
- [ ] A fixed golden set of real cases, with agreed good answers.
- [ ] Case-by-case comparison with a baseline, then a gate on the release.
- [ ] Code checks where possible, and a judge model checked against people.
- [ ] The full set re-run on every model swap, before the old model is retired.
- [ ] The set grows with every live failure.

**Common traps**

- Trap: "Our average score went up, so it's fine." Better: An average can hide a case that broke. Compare case by case, and gate on any past pass that fails.
- Trap: "We'll test it by hand after launch." Better: Hand checks miss what nobody remembers to try. Keep the set saved in Git or a similar version history, and run it on every change.
- Trap: "The judge model is always right." Better: A judge is a grader, and it needs checking. Compare its marks with people on a sample, and watch for flips between runs.

## Can you spot the regression?

**Spot the regression:** Your team changed the refund-policy prompt. Which result should block the release?

A. The average score rose from 88 to 91 percent.
B. Two new edge cases now pass that failed last week.
C. The 30-day refund case passed in the baseline and now quotes the old 14-day rule.
D. A judge model gave one new case a slightly lower score.

**Answer:** C. A case that passed before and fails now is the regression, even when the average rises. Gate on it, then find out why the model changed its answer.

**Quick check:** Your claims triage prompt works well today, and the model behind it retires next quarter. What should you do first?

A. Ship the replacement model now, since it is newer
B. Run the full golden set on the replacement before the retirement date
C. Add more examples to the prompt and hope for the best
D. Wait for adjusters to report wrong labels

**Answer:** B. A replacement can behave differently on your tasks, so the full set tells you before users do. Shipping untested, or waiting for complaints, lets regressions reach people first.

## Can you answer these from memory?

**Flash cards**

- **What is regression testing for prompts?** Checking that a change does not break cases that already passed.
- **What is a golden set?** A fixed list of past cases, each with an agreed good answer or pass rule.
- **What is the baseline?** The results of the last shipped version, kept to compare each case against.
- **What blocks a release?** Any case that passed in the baseline and now fails.
- **Why can an average score mislead?** A rise on new cases can hide a loss on old ones. Compare case by case.
- **What happens at a model swap?** Run the full set on the replacement well before the old model is retired.

## Likely follow-up questions

- Q100 How do you test prompts systematically? https://designervenkat.online/interview/ai/how-to-test-prompts-systematically
- Q256 Capability evals vs regression evals? https://designervenkat.online/interview/ai/capability-evals-vs-regression-evals
- Q258 How do you A/B test an LLM feature? https://designervenkat.online/interview/ai/how-do-you-ab-test-an-llm-feature
- Q251 How do you calibrate a judge against humans? https://designervenkat.online/interview/ai/how-do-you-calibrate-a-judge-against-humans
- Q248 What is a golden dataset, and how do you build one? https://designervenkat.online/interview/ai/what-is-a-golden-dataset
- Q261 How do you detect drift? https://designervenkat.online/interview/ai/how-do-you-detect-drift

## Learn it in depth

- [Regression Testing](https://designervenkat.online/learn/ai-engineering/regression-testing)
