Topic 2 of 5 · 4 min read
Catching regressions from prompt edits
Goal: Read a per-case eval diff after a prompt edit and identify the regression hidden by a stable average.
After a prompt edit, compare results case by case, not just the average: a stable score can hide cases that broke while others improved. A prompt is code that a model interprets, and a one-word change can shift behaviour in places you did not look.
Check yourself · 1 of 3
A prompt edit leaves the pass rate at 87% before and after. What does that tell you?
Why it matters
Suppose a prompt edit fixes 6 cases and breaks 6 others. The pass rate does not move, and the pull request looks safe. But the 6 broken cases may be the ones customers hit most, or the ones with legal risk. The average cannot tell you. The per-case diff can.
Put prompts in the repo
Keep prompts in files, not in a dashboard or a database row someone edits live. Then every change has an author, a diff, a review and a commit that CI can run against. If prompts must be edited outside the repo, store a version id with every logged run so a result can be tied to the exact text.
How to read a per-case diff
Compare the run on the base branch with the run on the branch under review, case by case, and sort cases into four groups:
- Still pass (ignore).
- Newly fail (read first). These are the regressions.
- Newly pass (the intended gains; check they match the goal of the edit).
- Still fail (known problems, not caused by this change).
Then read the actual outputs of the newly failing cases. Ask what the edit changed that explains them. Often a new rule such as "always answer in two sentences" collides with a case that needs a list, or a added example pulls every answer toward its format.
Handle noise
Models are not deterministic. A case that flips once may be luck. For cases that flip, rerun them several times, or use temperature 0 where the provider honours it. Count a case as regressed only when it fails consistently, or when the failure rate across trials rises.
Before and after
Before: the author reports "accuracy 87% to 87%, ship it." After: the diff shows 5 newly failing cases, all about cancellations, and 5 newly passing ones, all about shipping. The edit added a line about shipping that told the model to avoid cancellation language. The author narrows the line and the cancellation cases pass again.
What goes wrong
- Looking only at the headline score.
- Fixing the new failures by adding case-specific instructions to the prompt. That overfits to the suite and makes the next edit more fragile.
- Comparing against an old saved run made with a different model or dataset, so the diff measures the wrong thing.
Examples
The average that did not move
case base branch
refund-late-delivery pass pass
- cancel-before-shipping pass FAIL
- cancel-after-shipping pass FAIL
+ shipping-address-change FAIL pass
+ shipping-international FAIL pass
overall 18/20 18/20
Both runs score 18 of 20. The branch fixed two shipping cases and broke two cancellation cases. Cancellation requests carry refund money, so the team rejects the edit and rewrites the shipping line.
Noise or regression
A case fails on the branch. Run it 5 times on each side: base passes 5 of 5, branch passes 1 of 5. That is a regression. If the branch had passed 4 of 5, the single failure would more likely be noise, and you would watch it rather than block.
Key points
- A stable average can hide a set of newly failing cases cancelled out by newly passing ones.
- Keep prompts in the repo so every edit has a diff, a reviewer and a commit CI can run.
- Group cases into still passing, newly failing, newly passing and still failing, and read newly failing first.
- Rerun flipping cases several times before calling them regressions, because outputs vary between runs.
- Compare against a run on the base branch with the same model and dataset, not an old saved result.
Common mistakes
- Approving an edit because the overall score did not drop.
- Editing prompts in a dashboard with no version recorded next to the results.
- Patching each newly failing case with a special-case sentence in the prompt.
- Comparing two runs made with different models, datasets or temperature settings.
Check yourself · 2 of 3
In a per-case diff after a prompt edit, which group do you read first?
Check yourself · 3 of 3
One eval case fails once on a branch run but passed on base. What is the best next step?
Practice items, not counted towards your mastery.
Start here
- promptfoo: Testing prompts with GitHub Actions (opens in a new tab)DocsFree
A working CI recipe that runs an eval on every pull request that touches a prompt and comments the results.
- Evaluation best practices (OpenAI) (opens in a new tab)DocsFree
Vendor guidance on building evals, running them continuously and checking them against real usage.
- GitHub Actions documentation (opens in a new tab)DocsFree
Triggers, path filters, caching and scheduled workflows: the parts of CI this skill relies on.
More for this topic
- Your AI product needs evals (Hamel Husain) (opens in a new tab)ArticleFree
Argues for running unit-test style evals on every change and looking at the individual failures.