AI Prompt Regression Testing
When to Use
- Compare a prompt change with an observed baseline on a fixed evaluation set.
- Detect schema, factuality, refusal, tool-selection or task-completion regressions.
- Record a reviewable decision when results are noisy, missing or contradictory.
Workflow
- Define the task, representative cases and forbidden outcomes. Use synthetic
or approved/redacted data; freeze case IDs and the dataset revision before runs.
- Record baseline/candidate prompt digests, exact available model/version,
inference settings, tool versions and evaluation environment. Do not hardcode
old model-family options or silently change models between comparisons.
- Predeclare checks and acceptance rules. Use deterministic schema/field checks
for structured output, behavioral checks for tools and a clear human/rubric
standard for open text. Similarity does not prove factual or code correctness.
- Run matched baseline/candidate cases under the same permissions and budget.
Record latency/cost and repeated runs when variability matters. A timeout,
missing output or judge error is incomplete, not a pass or a zero-cost result.
- Treat judge outputs as evidence with limitations. Blind/randomize presentation
where feasible, calibrate against human-labeled examples, and record judge
identity/rubric. Do not ask a model to verify private reasoning or accept a
judge's confidence as an objective correctness measurement.
- Review differences case by case and report the denominators, failures and
uncertainty. Keep mandatory safety/schema failures visible even if aggregate
similarity improves. Use the predeclared rule, not a threshold selected after results.
- Store a redacted report and exact artifacts at an authorized destination.
Decide retain/revise/reject for the stated dataset; deployment is separate.
Regression register
| Field |
Type |
Example / meaning |
| case_id |
string |
PTEST-001; a textual ID, not SERIAL |
| dataset_revision |
immutable reference |
exact case inventory, expected checks and labels |
| prompt_revision |
string |
baseline/candidate digest |
| model_runtime |
string |
exact available ID/version plus settings |
| check |
string |
required JSON fields or approved rubric criterion |
| result |
enum |
pass / fail / incomplete |
| evidence |
reference |
redacted actual output, tool trace or observed check |
| judge_configuration |
optional object |
exact judge ID/rubric/version and calibration limits |
| latency_ms |
nonnegative number or null |
null if not observed; never invented |
| cost |
amount/currency or null |
actual billing basis; unknown remains unknown |
| run_revision |
immutable reference |
binds the report to the actual run |
IDs and statuses must have consistent SQL/JSON/CSV representations. Do not store
private prompts, user messages or tokens in a public spreadsheet or Notion register.
Worked example
Two cases test a support-answer prompt. PTEST-001 requires an answer grounded in
the supplied policy; PTEST-002 requires a structured escalation when the policy
is absent. The candidate sounds more helpful but PTEST-002 has no observed result.
The report is incomplete, not a win. The following Python 3 helper aggregates
already reviewed case statuses; it does not call models or decide correctness.
def summarize_regression(results, expected_case_ids):
if not isinstance(expected_case_ids, list) or not expected_case_ids:
return {"status": "incomplete", "reason": "missing case inventory"}
if any(not isinstance(case, str) or not case for case in expected_case_ids):
return {"status": "incomplete", "reason": "invalid case IDs"}
if len(set(expected_case_ids)) != len(expected_case_ids):
return {"status": "incomplete", "reason": "duplicate expected case IDs"}
if not isinstance(results, list) or any(not isinstance(row, dict) for row in results):
return {"status": "incomplete", "reason": "invalid results"}
by_id = {}
for row in results:
case = row.get("case_id")
if not isinstance(case, str) or case not in expected_case_ids or case in by_id:
return {"status": "incomplete", "reason": "unexpected or duplicate result"}
if row.get("result") not in ("pass", "fail", "incomplete"):
return {"status": "incomplete", "reason": "unknown result"}
by_id[case] = row["result"]
failed_cases = [case for case, result in by_id.items() if result == "fail"]
if set(by_id) != set(expected_case_ids) or "incomplete" in by_id.values():
return {"status": "incomplete", "reason": "missing or incomplete case",
"failed_cases": failed_cases, "evaluated": len(by_id)}
return {"status": "regression" if failed_cases else "checks-passed",
"failed_cases": failed_cases, "evaluated": len(by_id)}
print(summarize_regression(
[{"case_id": "PTEST-001", "result": "pass"}],
["PTE
1---2name: ai-prompt-regression-testing3description: "Use when comparing prompt changes against a fixed evaluation set: record actual model settings, required checks, missing results, judge limitations and case-level regression evidence."4category: Document Processing5source: antigravity6tags: [python, ai, agent, llm, workflow, spreadsheet, presentation]7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/ai-prompt-regression-testing8metadata:9 source: https://skillmd.com/skills/ranbot-ai/ai-prompt-regression-testing10---111213# AI Prompt Regression Testing1415## When to Use1617- Compare a prompt change with an observed baseline on a fixed evaluation set.18- Detect schema, factuality, refusal, tool-selection or task-completion regressions.19- Record a reviewable decision when results are noisy, missing or contradictory.2021## Workflow22231. Define the task, representative cases and forbidden outcomes. Use synthetic24 or approved/redacted data; freeze case IDs and the dataset revision before runs.252. Record baseline/candidate prompt digests, exact available model/version,26 inference settings, tool versions and evaluation environment. Do not hardcode27 old model-family options or silently change models between comparisons.283. Predeclare checks and acceptance rules. Use deterministic schema/field checks29 for structured output, behavioral checks for tools and a clear human/rubric30 standard for open text. Similarity does not prove factual or code correctness.314. Run matched baseline/candidate cases under the same permissions and budget.32 Record latency/cost and repeated runs when variability matters. A timeout,33 missing output or judge error is incomplete, not a pass or a zero-cost result.345. Treat judge outputs as evidence with limitations. Blind/randomize presentation35 where feasible, calibrate against human-labeled examples, and record judge36 identity/rubric. Do not ask a model to verify private reasoning or accept a37 judge's confidence as an objective correctness measurement.386. Review differences case by case and report the denominators, failures and39 uncertainty. Keep mandatory safety/schema failures visible even if aggregate40 similarity improves. Use the predeclared rule, not a threshold selected after results.417. Store a redacted report and exact artifacts at an authorized destination.42 Decide retain/revise/reject for the stated dataset; deployment is separate.4344## Regression register4546| Field | Type | Example / meaning |47|---|---|---|48| case_id | string | PTEST-001; a textual ID, not SERIAL |49| dataset_revision | immutable reference | exact case inventory, expected checks and labels |50| prompt_revision | string | baseline/candidate digest |51| model_runtime | string | exact available ID/version plus settings |52| check | string | required JSON fields or approved rubric criterion |53| result | enum | pass / fail / incomplete |54| evidence | reference | redacted actual output, tool trace or observed check |55| judge_configuration | optional object | exact judge ID/rubric/version and calibration limits |56| latency_ms | nonnegative number or null | null if not observed; never invented |57| cost | amount/currency or null | actual billing basis; unknown remains unknown |58| run_revision | immutable reference | binds the report to the actual run |5960IDs and statuses must have consistent SQL/JSON/CSV representations. Do not store61private prompts, user messages or tokens in a public spreadsheet or Notion register.6263## Worked example6465Two cases test a support-answer prompt. PTEST-001 requires an answer grounded in66the supplied policy; PTEST-002 requires a structured escalation when the policy67is absent. The candidate sounds more helpful but PTEST-002 has no observed result.68The report is incomplete, not a win. The following Python 3 helper aggregates69already reviewed case statuses; it does not call models or decide correctness.7071```python72def summarize_regression(results, expected_case_ids):73 if not isinstance(expected_case_ids, list) or not expected_case_ids:74 return {"status": "incomplete", "reason": "missing case inventory"}75 if any(not isinstance(case, str) or not case for case in expected_case_ids):76 return {"status": "incomplete", "reason": "invalid case IDs"}77 if len(set(expected_case_ids)) != len(expected_case_ids):78 return {"status": "incomplete", "reason": "duplicate expected case IDs"}79 if not isinstance(results, list) or any(not isinstance(row, dict) for row in results):80 return {"status": "incomplete", "reason": "invalid results"}81 by_id = {}82 for row in results:83 case = row.get("case_id")84 if not isinstance(case, str) or case not in expected_case_ids or case in by_id:85 return {"status": "incomplete", "reason": "unexpected or duplicate result"}86 if row.get("result") not in ("pass", "fail", "incomplete"):87 return {"status": "incomplete", "reason": "unknown result"}88 by_id[case] = row["result"]89 failed_cases = [case for case, result in by_id.items() if result == "fail"]90 if set(by_id) != set(expected_case_ids) or "incomplete" in by_id.values():91 return {"status": "incomplete", "reason": "missing or incomplete case",92 "failed_cases": failed_cases, "evaluated": len(by_id)}93 return {"status": "regression" if failed_cases else "checks-passed",94 "failed_cases": failed_cases, "evaluated": len(by_id)}959697print(summarize_regression(98 [{"case_id": "PTEST-001", "result": "pass"}],99 ["PTE