Skip to content
Figure 1Prompt regression runs: pass, fail and unstable cases per release candidate (worked example)
Prompt regression runs: pass, fail and unstable cases per release candidate (worked example)run 1run 2run 3run 4run 5run 6run 7run 8passfailflaky
Invented results. Candidate 3 and candidate 6 would have been blocked by a gate that allows at most a 2 point drop in the pass rate.

Prompt regression testing: baselines, diffs and release gates

A one-word change to a prompt can fix the case in front of you and quietly break twenty others. So can a model upgrade that nobody on the team chose. Prompt regression testing is ordinary regression testing adapted to outputs that vary: a fixed suite, a recorded baseline, checks that tolerate harmless variation, and a gate that stops a release when the measured behaviour gets worse.

Quick answer

Keep a versioned suite of real and edge-case inputs, record a baseline run, and on every change rerun the suite with layered checks: exact checks for structure, property checks for content, a validated grader for quality. Compare rates against the baseline with intervals and block the release if a gated rate falls beyond the agreed margin.

Key figures

Suite size
200 to 1,000 cases, versioned
Triggers
prompt, model, retrieval or setting change
Checks
structure, properties, graded quality
Grader
validated against human labels
Gate
rate drop beyond an agreed margin
Runs per case
3 or more when sampling is on

Why prompts need regression tests

A prompt is code written in a natural language, executed by a component whose behaviour changes when its supplier updates it. The two ways it breaks are familiar from any software: someone changes it to fix one thing and breaks another, or a dependency changes underneath it. What is new is that outputs vary from run to run, so an exact-match assertion fails constantly and teams give up on testing. The fix is to test the properties that matter and measure them as rates, the approach laid out in testing language model features.

Build the regression suite in six steps

  1. Collect the suite from real use

    Sample real inputs (with personal data removed), add every past failure, and add edge cases chosen by partitioning: very long inputs, empty inputs, other languages, and hostile instructions of the kinds catalogued in the OWASP list of language model application risks.

  2. Write layered checks per case

    Exact checks for structure (valid JSON, required fields, length limits), property checks for content (the answer cites the provided document, no invented product names), and a graded quality score only where the first two cannot reach.

  3. Validate the grader

    If a model grades quality, compare its grades with human grades on 200 or more cases and measure agreement before trusting it, as in inter-rater agreement for evaluation labels. Zheng and colleagues found that model graders can match human preferences well but show position and verbosity biases.

  4. Record a baseline

    Run the suite on the current prompt and model three or more times per case if sampling is enabled, and store outputs, check results and settings under a version tag.

  5. Run on every change and compare rates

    Any change to prompt text, model version, retrieval data or sampling settings triggers the suite. Compare pass rates per check family against the baseline with confidence intervals.

  6. Gate the release

    Block the change if a gated rate falls by more than the agreed margin, and review every newly failing case by hand before deciding it is noise.

Most of the value comes from the first two layers, which are cheap and stable
Check layerExampleOracleFlakiness
StructureOutput parses as the required schemaExactNone expected
PropertiesEvery claim quotes the retrieved passageRule or relationLow
MetamorphicRephrased question gets a compatible answerRelation between outputsLow to medium
Graded qualityHelpfulness on a 1 to 5 rubricValidated graderMedium; use rates

Handling variation without hiding regressions

When outputs are sampled, a single run per case is a coin toss. Run each case several times and treat the case as passing if it passes in an agreed share of runs, or compare the distribution of scores. Track cases that flip between runs separately, as you would flaky tests, because instability is itself a finding. Relations from metamorphic testing are especially useful here, since they check consistency directly.

Rule of thumb

If a model upgrade arrives with no regression run, it is an untested release, whoever shipped it.

Worked example: the gate decision on candidate 3

Candidate 3 in the figure above was a prompt change meant to make answers shorter. The suite has 600 cases, each run three times; a case passes a check if it passes in at least two of three runs. The gate allows a 2 point drop in any pass rate. The counts are invented but realistic.

Invented but realistic counts. The shorter answers passed every structural check and lost the citation that the property check requires.
Check familyBaseline pass rateCandidate 3ChangeGate
Structure (valid schema, length limit)597 of 600 (99.5%)596 of 600 (99.3%)0.2 points downPass
Properties (answer cites the retrieved passage)564 of 600 (94.0%)519 of 600 (86.5%)7.5 points downBlock
Metamorphic (rephrased question, compatible answer)546 of 600 (91.0%)540 of 600 (90.0%)1.0 point downPass
Graded quality (mean of 1 to 5)4.14.00.1 downPass

The 45 newly failing property cases were reviewed by hand. 38 of them had dropped the quoted passage to meet the new length instruction, which is a real regression caused directly by the change; 7 were borderline cases that flip between runs and were moved to the unstable list. The candidate went back with a revised instruction that protected the citation, and candidate 4 passed. Without the property layer the release would have shipped on a graded score that moved by a tenth of a point.

Common mistakes in prompt regression testing

  • Running each case once with sampling on, then arguing about whether a failure is real. Fix the runs-per-case rule and the pass rule in the plan.
  • Letting the grader be the only check. Graders drift with their own model updates and carry length and position biases; put structure and property checks first.
  • Gating on an overall pass rate. A 7 point drop in one family disappears inside a 600-case average.
  • Rerunning the baseline on the new model. The baseline is a recorded artefact from the previous version, and regenerating it hides the change you are testing for.
  • Adding failing cases to the suite and then tuning the prompt on them until they pass, which turns a regression suite into a training set.
  • Skipping the run for supplier-side model updates because nobody on the team changed anything.

Expert tips

  • Tag every case with the failure it was added for. When a case fails again, the tag tells the reviewer what the original bug was without a search.
  • Keep a small, fast smoke subset of 50 cases for local iteration and run the full suite in the pipeline; teams that only have the full suite stop running it.
  • Record the supplier's model identifier from the response, not from configuration, so that a silent server-side change shows up in the run record.
  • Review a random sample of passing cases after each run as well as the failures. A prompt can pass every check with answers that have quietly become worse.
  • Store the unstable list as a first-class output and watch its size. Growth in unstable cases usually precedes a regression that the gate will catch later.

How to report a regression run

Each run should be reported as a comparison, never as a single score: the baseline version and the candidate version, the suite version, the runs per case and the pass rule, the per-family pass rates with counts and intervals, the gate margin, the list of newly failing cases with a one-line diagnosis for each, and the decision. Keep the outputs of both runs, since a newly failing case is only diagnosable by reading the two answers side by side. The baseline is the most valuable record the team owns and should be stored with the same care as a release build. The guide to testing language model features covers the wider suite this run sits in.

Common questions

What is prompt regression testing?

Rerunning a fixed, versioned suite of inputs after every change to a prompt, model or setting, and comparing the results with a recorded baseline to catch behaviour that got worse.

How big should a prompt regression suite be?

Usually 200 to 1,000 cases, weighted towards real inputs, past failures and edge cases. It grows as new failures are found.

How do you test outputs that change every run?

Check properties instead of exact text, run each case several times, and compare pass rates with confidence intervals rather than single results.

Can a language model grade the outputs?

Yes, if its grades have been validated against human grades on a representative sample. Published work shows such graders can be biased by answer position and length, so check for that.

When should the suite run?

On every change to prompt text, model version, retrieval content or generation settings, and on a schedule to catch silent changes by the model supplier.

How is prompt regression testing different from a benchmark?

A benchmark compares models on a public task. A regression suite compares one product feature with its own previous behaviour on the team's real inputs, and its job is to catch a drop, so its cases are private, versioned and weighted towards past failures.

Sources

  1. Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena
  2. Liang et al., Holistic Evaluation of Language Models (HELM)
  3. OWASP Top 10 for Large Language Model Applications

This guide is part of the testing AI systems hub. It is best read alongside metamorphic testing for language models and test design for llm features, which cover the neighbouring questions.