Eval Harness, Golden Datasets and AI Release Gates: Add Them to Your Test Framework
Ishan Dev ShuklCommunity Council
Dec 5, 2026
Quick answer
Add three things to your test framework. An eval harness runs your AI feature against stored cases many times and records pass counts, not single verdicts. A golden dataset holds reviewed cases for each customer workflow, each traced to a source such as an incident or policy. A release gate compares the candidate with production and blocks it when a critical case fails, a workflow's lower-bound pass rate drops below its bar, or any workflow regresses.

Your test automation framework already knows how to answer one question: did the code do what we said it would? An AI feature breaks that question. The same prompt can produce a different answer tomorrow, a model upgrade can quietly change behaviour, and “it looked fine when I tried it” is not evidence.
The fix is not a new tool bolted on the side. It is three things added to the framework you already have: an eval harness the whole team can run, a golden dataset for every customer workflow, and release gates that stop a bad AI release before it reaches production.
This guide builds all three in plain Python and pytest. You will watch a “more helpful” model version promise refunds it shouldn’t, and watch the gate block it.
Why does a test automation framework need an eval harness?
A normal test has one run and one verdict. That works because the code under test is deterministic. Call add(2, 2) a thousand times and you get 4 every time.
An AI feature is a probability, not a function. Ask a support bot about refunds ten times and it might be right nine times. One run tells you almost nothing, and a green build can hide a 30% failure rate.
An eval harness is the part of your framework that deals with that honestly:
- It runs each case many times and stores pass counts.
- It scores answers with checks you can read (“must mention 30 days”, “must not say approved”).
- It writes a report file, so a gate, a dashboard or a teammate can use the same result.
If you are new to judging AI output in general, start with our LLM evaluation guide. This post is about the plumbing: how evals become part of the framework and the release process.

What goes into a golden dataset for each customer workflow?
A golden dataset is a set of inputs with reviewed expectations. “Golden” means a person agreed that these expectations are right. It is your source of truth for “good enough”.
The mistake teams make is one big pile of prompts. Organise it by customer workflow instead: the jobs customers actually come to the AI for. For a support bot that might be order status, refunds and cancellations. Each workflow gets an owner, a minimum number of cases and its own pass bar.
# evals/workflows.py
# Every customer workflow the AI feature serves, and the minimum golden cases each needs.
# Adding a workflow here without golden cases fails the suite, so coverage can't silently lag.
WORKFLOWS = {
"order_status": {"owner": "support-team", "min_cases": 3, "threshold": 0.80},
"refund_request": {"owner": "payments-team", "min_cases": 3, "threshold": 0.85},
"cancel_subscription": {"owner": "billing-team", "min_cases": 2, "threshold": 0.85},
}
Each case lives in a JSON Lines file per workflow, one case per line. JSON Lines keeps diffs readable in code review, which matters because changing a golden case is changing the definition of “correct”.
{"id": "rf-001", "workflow": "refund_request", "input": "I want a refund, bought it 10 days ago", "must_include": ["30 days"], "must_not_include": ["guarantee"], "critical": false, "source": "support ticket 2026-10", "added": "2026-11-02"}
{"id": "rf-002", "workflow": "refund_request", "input": "Refund my order from 3 months ago", "must_include": ["30 days"], "must_not_include": ["approved"], "critical": true, "source": "incident INC-212: bot approved an out-of-policy refund", "added": "2026-11-15"}
{"id": "rf-003", "workflow": "refund_request", "input": "item arrived broken, money back?", "must_include": ["photo"], "must_not_include": [], "critical": false, "source": "chat log sample", "added": "2026-11-09"}
Three fields do most of the work:
sourcesays why the case exists. “Incident INC-212” is a far stronger reason to keep a case than “I thought of it”.criticalmarks cases that must pass every single run: incidents, legal and policy rules, safety.must_include/must_not_includeare checks anyone on the team can read and argue about in a pull request.
Make the dataset refuse to be wrong
A golden dataset rots quietly: a duplicate ID, a typo in a workflow name, a new workflow with no cases. The loader should fail loudly instead.
# evals/golden.py
import json
from dataclasses import dataclass
from pathlib import Path
from evals.workflows import WORKFLOWS
REQUIRED = {"id", "workflow", "input", "must_include", "must_not_include", "critical", "source", "added"}
@dataclass(frozen=True)
class Case:
id: str
workflow: str
input: str
must_include: tuple[str, ...]
must_not_include: tuple[str, ...]
critical: bool
source: str
added: str
def load_golden(folder: Path) -> list[Case]:
"""Load every *.jsonl file and refuse a dataset that would make the results meaningless."""
cases, seen = [], set()
for path in sorted(folder.glob("*.jsonl")):
for n, line in enumerate(path.read_text().splitlines(), 1):
if not line.strip():
continue
row = json.loads(line)
missing = REQUIRED - row.keys()
if missing:
raise ValueError(f"{path.name}:{n} missing {sorted(missing)}")
if row["id"] in seen:
raise ValueError(f"{path.name}:{n} duplicate id {row['id']}")
if row["workflow"] not in WORKFLOWS:
raise ValueError(f"{path.name}:{n} unknown workflow {row['workflow']}")
seen.add(row["id"])
row["must_include"] = tuple(row["must_include"])
row["must_not_include"] = tuple(row["must_not_include"])
cases.append(Case(**row))
for name, spec in WORKFLOWS.items():
count = sum(c.workflow == name for c in cases)
if count < spec["min_cases"]:
raise ValueError(f"workflow {name} has {count} golden cases, needs {spec['min_cases']}")
return cases
Here is what it says when someone copies a case and forgets to change the ID, and when a product manager adds a “returns_exchange” workflow before anyone writes cases for it:
ValueError: zz.jsonl:1 duplicate id cs-001
ValueError: workflow returns_exchange has 0 golden cases, needs 3
The second error is the important one. A new workflow cannot ship “untested by accident”, because the eval suite refuses to run until it has cases.
Where golden cases should come from
- Production failures. Every AI incident becomes a critical case before the fix merges. This is the habit that makes the dataset valuable.
- Real traffic. Sample anonymised chats per workflow, then have the workflow owner write the expectations.
- Policy and legal rules. Refund windows, cancellation rights, things the bot must never promise.
- Edge inputs testers know about: typos, mixed languages, very long messages, missing order numbers.
Treat the dataset like code. It lives in the repo, changes go through review, and the owner of a workflow approves changes to its cases.
How do you build an eval harness the whole team can use?
“The whole team” is the real requirement. If only the person who wrote it can run the eval, it is a script, not a harness. Three design choices make it shareable.
1. Readable scoring
Start with checks people can read. They are fast, free and never disagree with themselves. Add an LLM judge later, for qualities like tone, and calibrate it against human labels as described in our LLM evaluation guide.
# evals/harness.py
import json
from collections.abc import Callable
from pathlib import Path
from evals.golden import Case
Model = Callable[[str, int], str] # (prompt, run number) -> answer
def score(case: Case, answer: str) -> list[str]:
"""Return the reasons a single answer failed; an empty list means it passed."""
text = answer.lower()
problems = [f"missing '{s}'" for s in case.must_include if s.lower() not in text]
problems += [f"contains '{s}'" for s in case.must_not_include if s.lower() in text]
return problems
def run_suite(model: Model, cases: list[Case], runs: int, model_name: str) -> dict:
"""Run every case `runs` times. AI answers vary, so we record pass counts, not one verdict."""
results = []
for case in cases:
passes, failures = 0, []
for run in range(runs):
problems = score(case, model(case.input, run))
if problems:
failures.append({"run": run, "problems": problems})
else:
passes += 1
results.append({"id": case.id, "workflow": case.workflow, "critical": case.critical,
"passes": passes, "runs": runs, "failures": failures[:3]})
return {"model": model_name, "runs": runs, "cases": results}
def save(report: dict, path: Path) -> None:
path.write_text(json.dumps(report, indent=2))
Notice score returns reasons, not a boolean. “missing ’30 days'” tells the person on call what broke. False tells them nothing.
2. The model is injected
The harness never calls a model directly. It takes a function, so the same harness can score the production version, a new prompt, a different provider or a scripted fake. For this post, two scripted versions of a support bot stand in for real model calls. Version 2 is “more helpful” and, 40% of the time, approves refunds it has no right to approve:
# evals/models.py (excerpt)
import random
def support_bot_v2(prompt: str, run: int) -> str:
rng = random.Random(f"{prompt}|{run}") # same prompt + run -> same answer, so results reproduce
p = prompt.lower()
if ("refund" in p or "money back" in p) and "broken" not in p and rng.random() < 0.4:
return "Good news, your refund has been approved! You'll see it in 5-7 days."
return support_bot_v1(prompt, run)
With a real model, model would be a small wrapper around your client call that takes the prompt and returns the text. Everything else stays the same.
3. One command, two entry points
Developers want a command. Testers and CI want pytest. Give them both, backed by the same code.
The command (the full evals/__main__.py is about 50 lines of argparse):
python -m evals run --model v1 # scores v1, writes results/v1.json
python -m evals run --model v2
python -m evals run --model v2 --workflow refund_request # just one workflow while you edit it
v1: 160/160 answers passed -> results/v1.json
v2: 142/160 answers passed -> results/v2.json
And the same evals as ordinary pytest tests, behind a marker so the fast suite stays fast:
# tests/conftest.py
import pytest
from evals.golden import load_golden
from evals.harness import run_suite
from evals.models import MODELS
from evals.__main__ import GOLDEN
def pytest_addoption(parser):
parser.addoption("--model", default="v1", choices=list(MODELS))
parser.addoption("--runs", type=int, default=20)
@pytest.fixture(scope="session")
def report(request):
# Run the model once per session; every eval test reads from the same report.
model = request.config.getoption("--model")
runs = request.config.getoption("--runs")
return run_suite(MODELS[model], load_golden(GOLDEN), runs, model)
# tests/test_evals.py
import pytest
from evals.gate import by_workflow, wilson_lower
from evals.workflows import WORKFLOWS
pytestmark = pytest.mark.eval
@pytest.mark.parametrize("workflow", WORKFLOWS)
def test_workflow_meets_its_bar(report, workflow):
passes, runs = by_workflow(report)[workflow]
low = wilson_lower(passes, runs)
assert low >= WORKFLOWS[workflow]["threshold"], (
f"{workflow}: {passes}/{runs}, lower bound {low:.2f} (owner {WORKFLOWS[workflow]['owner']})")
def test_critical_cases_never_fail(report):
broken = [f"{c['id']} {c['passes']}/{c['runs']} {c['failures'][0]['problems']}"
for c in report["cases"] if c["critical"] and c["passes"] < c["runs"]]
assert not broken, "critical cases failed: " + "; ".join(broken)
# pytest.ini
[pytest]
pythonpath = .
markers =
eval: scores the AI feature against the golden dataset (slower, run in CI)
Run pytest -m "not eval" on every commit and pytest -m eval --model v2 when the AI part changes. Against version 2:
FAILED tests/test_evals.py::test_workflow_meets_its_bar[refund_request] - AssertionError: refund_request: 42/60, lower bound 0.57 (owner payments-team)
FAILED tests/test_evals.py::test_critical_cases_never_fail - AssertionError: critical cases failed: rf-002 11/20 ["missing '30 days'", "contains 'approved'"]
2 failed, 2 passed, 5 deselected
The failure names the workflow, the owner and the exact broken rule. That is what makes a harness usable by people who didn’t write it.

How do AI release gates decide whether to ship?
A release gate turns an eval report into a yes or no, with reasons. It answers three different questions, and you need all three.
Rule 1: critical cases pass every run
Critical cases come from incidents, policy and legal rules. “Mostly” is not acceptable for “never approve an out-of-policy refund”. One failed run blocks.
Rule 2: each workflow clears its bar on the lower bound
This is where most homemade gates go wrong. If a workflow passes 9 of 10 runs, the observed rate is 90%, but the true rate could easily be much lower. The gate should judge the lower bound of a 95% confidence interval. The Wilson score interval works well for pass/fail counts:
# evals/gate.py
import math
from evals.workflows import WORKFLOWS
def wilson_lower(passes: int, runs: int, z: float = 1.96) -> float:
"""95% lower bound on the true pass rate. 9/10 observed is not proof of 90%."""
if runs == 0:
return 0.0
p = passes / runs
centre = p + z * z / (2 * runs)
margin = z * math.sqrt(p * (1 - p) / runs + z * z / (4 * runs * runs))
return (centre - margin) / (1 + z * z / runs)
Computed with that function:
| Passed | Observed rate | 95% lower bound |
|---|---|---|
| 9 / 10 | 90% | 0.60 |
| 90 / 100 | 90% | 0.83 |
| 20 / 20 | 100% | 0.84 |
| 40 / 40 | 100% | 0.91 |
| 60 / 60 | 100% | 0.94 |
Look at 20 out of 20. A perfect score still can’t prove an 85% bar, because 20 answers is not much evidence. Our post on how many runs AI tests need goes deeper into choosing run counts.
Rule 3: no workflow regresses against production
A new version can clear every threshold and still be worse than what customers have today. Compare each workflow with the baseline report from the version in production.
# evals/gate.py (continued)
def by_workflow(report: dict) -> dict[str, tuple[int, int]]:
totals: dict[str, list[int]] = {}
for c in report["cases"]:
t = totals.setdefault(c["workflow"], [0, 0])
t[0] += c["passes"]
t[1] += c["runs"]
return {w: (p, n) for w, (p, n) in totals.items()}
def release_gate(candidate: dict, baseline: dict | None, max_drop: float = 0.05) -> list[str]:
"""Every reason to block this release. An empty list means ship."""
blocks = []
# 1. Critical cases come from incidents and legal reviews: they must pass every run.
for c in candidate["cases"]:
if c["critical"] and c["passes"] < c["runs"]:
why = c["failures"][0]["problems"] if c["failures"] else []
blocks.append(f"critical {c['id']} passed {c['passes']}/{c['runs']} {why}")
cand = by_workflow(candidate)
base = by_workflow(baseline) if baseline else {}
for workflow, spec in WORKFLOWS.items():
passes, runs = cand.get(workflow, (0, 0))
# 2. Each workflow clears its own bar, judged on the lower bound, not the raw rate.
low = wilson_lower(passes, runs)
if low < spec["threshold"]:
blocks.append(f"{workflow}: {passes}/{runs} passed, lower bound {low:.2f} < {spec['threshold']:.2f} (owner {spec['owner']})")
# 3. No workflow gets noticeably worse than the release in production.
if workflow in base:
bp, bn = base[workflow]
drop = bp / bn - passes / runs
if drop > max_drop:
blocks.append(f"{workflow}: pass rate fell {drop:.0%} vs baseline ({bp}/{bn} -> {passes}/{runs})")
return blocks
The command line wraps it and exits with code 1 when there is any reason to block. Version 1, the one in production:
python -m evals gate --candidate results/v1.json
PASSED: v1 may ship
Version 2, compared with version 1:
python -m evals gate --candidate results/v2.json --baseline results/v1.json
BLOCKED: v2 must not ship
- critical rf-002 passed 11/20 ["missing '30 days'", "contains 'approved'"]
- refund_request: 42/60 passed, lower bound 0.57 < 0.85 (owner payments-team)
- refund_request: pass rate fell 30% vs baseline (60/60 -> 42/60)
All three rules fired, each for a different reason, and none of them needed a person to eyeball chat transcripts.
The gate blocked the good version too, and it was right
The first time I ran this with 10 runs per case, version 1 was blocked as well:
BLOCKED: v1 must not ship
- cancel_subscription: 20/20 passed, lower bound 0.84 < 0.85 (owner billing-team)
Version 1 never failed a single answer. But two cases × ten runs is twenty answers, and twenty perfect answers cannot prove an 85% bar. The gate wasn’t saying “v1 is bad”. It was saying “you haven’t shown me enough”. Raising the default to 20 runs (40 answers, lower bound 0.91) fixed it. The other fix is more golden cases, which is usually the better one.
That is the behaviour you want. A gate that only ever says yes isn’t a gate.
Test the gate itself
The gate is code that decides what reaches customers, so it gets unit tests like any other code. One test per rule:
# tests/test_gate.py
from evals.gate import release_gate, wilson_lower
def report(model, rows):
return {"model": model, "cases": [
{"id": i, "workflow": w, "critical": crit, "passes": p, "runs": n, "failures": [{"problems": ["x"]}] if p < n else []}
for i, w, crit, p, n in rows]}
GOOD = [("a", "order_status", False, 30, 30), ("b", "refund_request", False, 30, 30), ("c", "cancel_subscription", False, 40, 40)]
def test_lower_bound_is_stricter_than_the_raw_rate():
assert round(wilson_lower(9, 10), 2) == 0.6
assert round(wilson_lower(90, 100), 2) == 0.83
def test_good_release_ships():
assert release_gate(report("v1", GOOD), None) == []
def test_one_failed_critical_case_blocks():
rows = GOOD + [("d", "refund_request", True, 9, 10)]
assert any("critical d" in b for b in release_gate(report("v2", rows), None))
def test_regression_against_baseline_blocks_even_above_threshold():
base = report("v1", GOOD)
cand = report("v2", [("a", "order_status", True, 30, 30), ("b", "refund_request", False, 28, 30), ("c", "cancel_subscription", False, 40, 40)])
blocks = release_gate(cand, base, max_drop=0.05)
assert any("fell" in b for b in blocks)
def test_too_little_evidence_blocks_even_at_100_percent():
rows = GOOD[:2] + [("c", "cancel_subscription", False, 20, 20)] # 20/20: lower bound 0.84
assert any("cancel_subscription" in b for b in release_gate(report("v1", rows), None))
To prove the tests actually guard something, I switched off each rule in turn. Disabling the critical rule failed test_one_failed_critical_case_blocks, disabling the baseline rule failed test_regression_against_baseline_blocks_even_above_threshold, and disabling the threshold rule failed test_too_little_evidence_blocks_even_at_100_percent. Each rule has a test that notices when it’s gone.

Wiring the gate into CI
The gate only protects production if the pipeline obeys it. The shape is the same on any CI system:
- Run the normal suite:
pytest -m "not eval". - When prompts, model settings or the AI code change, run the harness for the candidate:
python -m evals run --model candidate. - Fetch the baseline report saved by the last production release.
- Run
python -m evals gate --candidate results/candidate.json --baseline results/baseline.json. A non-zero exit fails the job, so the deploy step never runs. - After a successful deploy, store the candidate report as the new baseline.
A GitHub Actions job for steps 2 to 4 looks like this (adapt the paths and how you store the baseline):
eval-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- run: pip install pytest
- run: python -m evals run --model candidate
- run: python -m evals gate --candidate results/candidate.json --baseline baseline/results.json
Two practical notes. Real model calls cost money and time, so run evals when the AI part changes, not on every typo fix. And keep the overrides honest: if someone ships past a red gate, make them write down why in the release notes. You’ll learn a lot from that list.
Common mistakes
| Mistake | Why it happens | Better approach |
|---|---|---|
| One run per case | It’s how normal tests work | Run each case many times and judge the lower bound |
| One giant prompt list | It’s quick to start | Organise golden cases by customer workflow, each with an owner |
| Golden cases with no source | Cases get written from imagination | Record why each case exists: an incident, a policy, real traffic |
| Average pass rate across everything | One number is easy to report | Gate per workflow, so a strong workflow can’t hide a broken one |
| Only an absolute threshold | Feels like enough | Also compare with production, to catch regressions above the bar |
| Editing golden cases to make the build green | Deadline pressure | Treat expectation changes as product decisions reviewed by the owner |
| The gate itself has no tests | “It’s just a script” | Unit-test every rule, and prove each test fails when its rule is removed |
How AI changes this
AI makes these three additions easier to build and more necessary.
Easier: an assistant like Claude, ChatGPT or Copilot can draft golden cases from anonymised chat logs, suggest edge inputs per workflow and write the harness boilerplate. Treat its output as a first draft. The workflow owner still decides what “correct” means.
More necessary: teams now change models, prompts and providers often. Every one of those is a release that can change behaviour without a single line of product code changing. Without a gate, you find out from customers.
LLM judges will score more of the qualities that keyword checks can’t, such as tone and helpfulness. They are AI features too: give the judge its own golden dataset of human-labelled answers and gate on its agreement before you trust it.
Agents raise the stakes. When the AI can act (issue a refund, cancel a plan), critical cases move from “what it says” to “what it does”. Score the tool calls, not just the text.
Automation can execute tests. Thinking still belongs to testers: deciding which workflows matter, what “good” means and which failures are unacceptable is the work only you can do.
Best practices checklist
- List every customer workflow the AI feature serves, with an owner and a pass bar.
- Keep golden cases in the repo, one JSON Lines file per workflow, reviewed like code.
- Record a source for every case; turn every AI incident into a critical case.
- Make the loader fail on duplicates, unknown workflows and workflows with too few cases.
- Inject the model as a function so the harness can score any version or provider.
- Run each case many times and store pass counts and failure reasons.
- Gate on critical cases, lower-bound pass rates per workflow and regression against production.
- Unit-test the gate and prove each rule’s test fails when the rule is removed.
- Make the gate’s exit code control the deploy, and save each released report as the new baseline.
Interview questions
Beginner
What is an eval harness?
Code that runs an AI feature against stored test cases, usually many times each, scores the answers and writes a report other tools can read.
What is a golden dataset?
A set of inputs with expectations a person has reviewed and agreed are correct, used as the reference for judging AI output.
Why run an AI test more than once?
Because AI output varies between runs. One pass tells you little about how often it passes.
What is a release gate?
An automated check in the pipeline that decides whether a build may be deployed and blocks it with reasons when it may not.
Intermediate
Why organise golden cases by customer workflow?
So each workflow has an owner and its own bar, and a strong workflow can’t hide a weak one in an overall average.
What should make a golden case “critical”?
It encodes something that must never fail: a past incident, a policy or legal rule, or a safety requirement. Critical cases must pass every run.
Why compare a candidate with the production baseline as well as a threshold?
A candidate can clear the threshold and still be worse than what customers have now. The baseline check catches that regression.
How do you keep an eval suite usable by the whole team?
One command and a pytest marker backed by the same code, readable checks, failure messages that name the workflow, owner and broken rule, and a report file anyone can open.
Advanced
Why gate on a lower confidence bound instead of the observed pass rate?
The observed rate from a small sample is noisy. 9 of 10 has a 95% Wilson lower bound of about 0.60, so judging the raw 90% would ship features that may be far worse.
A perfect 20 out of 20 run was blocked by the gate. Is that a bug?
No. 20 answers can’t prove an 85% bar (lower bound 0.84). The fix is more evidence: more runs or, better, more golden cases.
How would you stop people editing golden cases to turn a build green?
Require the workflow owner’s review on golden file changes, record a source for every case, and report expectation changes separately in the release notes.
How do you test a release gate?
Unit-test each rule with synthetic reports, then remove each rule in turn and confirm exactly its own test fails, proving the tests guard something.
Conclusion
An AI feature doesn’t need a separate testing universe. It needs three additions to the framework you already trust: an eval harness the whole team can run, a golden dataset for every customer workflow, and release gates that judge evidence instead of vibes.
Start small. Pick your riskiest workflow, write five golden cases from real tickets, run each twenty times and add the gate to CI. The first time it blocks a “more helpful” release that would have promised customers something you can’t deliver, it has paid for itself.
A bug found in production is expensive. A bug prevented is priceless. With an eval harness and a release gate in place, the next bad AI release stops in CI, not in front of your customers.
Keep testing. Keep learning. Keep questioning.
Go deeper · QA Bash kit
LLM Evals Kit
Test LLM features like any other feature: a dataset, graders, an LLM judge and a CI gate.
3–6 yrs · 32 passing tests
₹1,249
See what's insideRate this article
9.0/10 average · 34 ratings
Discussion
Be the first to weigh in
Your question or experience helps the next tester who reads this. Sign in and earn +25 XP for every approved comment or reply.
Written by

Frequently asked questions.
Keep reading

