Skip to content
Eval Suites50

Prompt regression testing with a runnable example

Sources checked 3 min read · By the Eval Suites editors

In brief

Prompt regression testing compares a proposed prompt with a baseline on the same inputs. Hold the model, settings and tool responses fixed when you run the live comparison. Save the output from each version, then use the same checks to see which cases got worse.

Example inputs
Two synthetic order-lookup messages
Runner
Python 3 standard library
What this test grades
Output type, route and whether the order ID is carried through

What should stay fixed when a prompt changes?

Run the same cases under the same model version and decoding settings. Use recorded or stubbed tool responses if the prompt relies on tools. Save both prompt versions and the outputs so a later reviewer can reproduce the grading. If you change the model or tool behavior as well, label the run as a combined change.

Promptfoo documents exact, structural and model-graded assertions. Check fields and formats in code first, then use a reviewed rubric for qualities the contract cannot express.[1]

Run a saved-output regression test

The example routes order lookups either to an order lookup or to a request for more information. Both rows use synthetic messages and saved example outputs. For both prompt versions, route requests with a stated order ID to lookup and requests without one to ask_for_id. The baseline instruction is “Copy the order ID verbatim when the request includes one. Otherwise return null for order_id.” The candidate instruction is “Always return null for order_id.” The supplied outputs are authored to demonstrate the two checks. The Python script compares those outputs without a model call. To test your own prompt, replace the two saved outputs with results from the same inputs under your baseline and candidate prompts.

Run the saved-output checks
python3 check-prompt-regression.py prompt-regression.json
Expected output
order-present: PASS → FAIL
order-missing: PASS → PASS
1 regression(s)

Exit status 1 with the supplied fixture. As a control, copy the order-present baseline into the candidate field and rerun. The expected exit status becomes 0.

Expected checks for the synthetic order lookup
CaseExpected contractBaselineCandidate
Order presentroute lookup; order_id A17PassFail; loses the order ID
Order missingroute ask_for_id; order_id nullPassPass

Which prompt changes should block a release?

Count a regression when a case passes under the baseline and fails under the candidate. A failure under both versions is an existing problem. Give it an owner even when it leaves the change-specific gate open. For stochastic application behavior, repeat paired runs and inspect the individual failures before promoting a noisy check to a blocking gate.

How to read paired results when the pass rate stays flat
Baseline → candidateIllustrative case countReview action
Pass → pass7Keep the passing cases in the suite.
Pass → fail1Inspect the lost behavior before release.
Fail → pass1Verify the fix against the original contract.
Fail → fail1Keep the existing defect on the issue list.

Both versions pass 8 of these 10 illustrative cases. One fix offsets one regression in the average. The checker still exits 1 for the newly failing case. It exits 2 if the fixture is empty, a case ID repeats or a required field is missing. Repair the input before interpreting a run.

Use the same case IDs in the pull request report and in the saved fixture. Promptfoo documents a GitHub Action for evaluating configured cases in CI.[2] For release ownership, tolerances and slow test tiers, read the agent release-gate guide.

Investigate a case that changed status

Compare the baseline and candidate responses for the same input before reading the summary percentage. Suppose both responses select order lookup, but only the baseline preserves the customer’s order identifier. Record the failing field, expected identifier and observed value. An overall route-accuracy figure can stay flat while the candidate starts querying the wrong record.

Add a neighboring case with the same intended route and a different order identifier. If both candidate outputs contain the first identifier, check for a copied example or a stale saved output. If the case without an identifier fails instead, inspect the rule for asking a clarifying question. Keep those cases separate so a later prompt edit cannot make one pass by breaking the other.

Related suites

Related reading

Sources

  1. 1. Promptfoo: Assertions and metrics · Promptfoo · Official docs · Sources checked
  2. 2. Promptfoo: GitHub Action integration · Promptfoo · Official docs · Sources checked