Sub topic 11
Using Evaluations as Release Gates
What this chapter assumes
You have a set of requirements with thresholds, an evaluation dataset where each case has a severity, and graders that mark each case as passed or failed. You can read short Python. This chapter covers how to turn those results into a decision about whether a change ships.
What a release gate is
A release gate is a rule that runs on every candidate change to the AI feature and returns "ship" or "block". A candidate change can be a new prompt, a new model version, a retrieval change, or a configuration change. The rule is written down before you see the results. If you pick the rule after seeing the numbers, you will tend to pick one the candidate passes.
A gate is different from a dashboard. A dashboard shows numbers and leaves the decision to a person. A gate encodes the decision, so people can't skip it under deadline pressure without making that choice visible.
A useful gate answers three questions:
- Is the candidate good enough in absolute terms?
- Does the candidate have any failure we refuse to accept at all?
- Is the candidate worse than what is already in production?
Each question needs a different check. The sections below cover them in order.
Absolute check: the pass-rate threshold
The pass-rate threshold comes from your acceptance criteria. For example, "at least 90% of cases pass overall." It protects against general weakness spread across many cases.
Zero-tolerance check: critical failures
An average hides rare, serious failures. If 1 of 100 cases states a wrong refund deadline and the other 99 pass, the pass rate is 99%. That looks excellent, but the failure may be the one that costs you money or trust. A zero-tolerance rule says that any failed case marked critical blocks the release, whatever the pass rate is.
This is the same pattern as the requirement from the spine: 95% of refund-policy answers must be grounded, and no answer may contradict the policy, with a tolerance of 0 cases. The first line is a threshold. The second line is a zero-tolerance rule.
The following function combines both checks and reports which cases caused a block:
def release_decision(results, min_pass_rate=0.9):
total = len(results)
pass_rate = sum(r["passed"] for r in results) / total if total else 0.0
critical_failures = [r["id"] for r in results if not r["passed"] and r["severity"] == "critical"]
ship = pass_rate >= min_pass_rate and not critical_failures
return {"ship": ship, "pass_rate": pass_rate, "critical_failures": critical_failures}
results = [{"id": f"case-{i}", "severity": "minor", "passed": True} for i in range(9)]
results.append({"id": "refund-014", "severity": "critical", "passed": False})
print(release_decision(results))This prints:
{'ship': False, 'pass_rate': 0.9, 'critical_failures': ['refund-014']}The pass rate is exactly 0.9, which meets the threshold. The release is still blocked because one critical case failed. The output names refund-014, so the person reading the result knows where to look first.
Two details in this function are deliberate:
- An empty result list gives a pass rate of 0.0, not a division error and not a pass. A gate that "ships" because no cases ran is a serious bug.
- A case with no severity needs a default. The runner from the earlier chapter uses
"minor". Decide whether that default is safe for your feature. For a high-risk feature, defaulting unlabeled cases to a stricter level is safer.
Regression check: compare with the current version
A candidate can pass both checks above and still be worse than production. Suppose production passes 97% and the candidate passes 91%. Both clear a 90% threshold, but you would be shipping a decline.
A regression check compares the candidate with a baseline, which is the result of running the same evaluation set against the version currently in production. Two comparisons are useful.
The first is the aggregate drop. The candidate's pass rate must not fall below the baseline's by more than a small allowed margin. The second is case-level regressions, which are cases that passed before and fail now. Even when the total improves, individual losses matter, because users who relied on the old behavior will notice them.
def newly_failing(baseline, candidate):
previously_passed = {r["id"] for r in baseline if r["passed"]}
return [r["id"] for r in candidate if r["id"] in previously_passed and not r["passed"]]
def pass_rate(results):
return sum(r["passed"] for r in results) / len(results) if results else 0.0
def regression_report(baseline, candidate, max_drop=0.02):
drop = pass_rate(baseline) - pass_rate(candidate)
return {
"drop": round(drop, 4),
"drop_ok": drop <= max_drop,
"newly_failing": newly_failing(baseline, candidate),
}Treat the newly_failing list as something a person reviews, not as an automatic block. Some losses are acceptable trade-offs. For example, a new prompt may refuse a borderline request that the old one answered, and that refusal may be correct. Others are real defects. A gate that blocks on every single case regression will block almost every change, because nondeterministic output makes some cases flip between runs. A gate that ignores them lets slow decline through.
A workable policy is to block automatically on any new critical failure and on an aggregate drop beyond the margin. For other newly failing cases, require a reviewer to look at them and write a short note.
How the checks fit together
The order matters for the reader, not for the logic. Run all checks every time and report every reason for a block. If the gate stops at the first failure, a developer fixes that one, reruns, and discovers the next one, which wastes cycles.
Edge cases and failure modes of the gate
Small samples make thresholds noisy
With 40 cases, one failure is 2.5 percentage points. A 95% threshold then means "at most 2 failures," and a single flaky case can flip the decision. Zero failures in a small set is also weaker evidence than it looks. A rough rule of thumb: if you observe 0 failures in n independent cases, the true failure rate could still be as high as about 3/n at 95% confidence. With 100 cases, that is up to 3%. If your requirement says 0 tolerance for a critical failure, a 100-case set cannot prove it. It can only show that you found none. For critical categories, add more cases, especially adversarial ones.
Nondeterminism makes one run unreliable
The same candidate can pass on one run and fail on the next, because the model samples its output. Options for handling this:
- Lower the sampling temperature for evaluation runs, if your production setting allows testing at that value.
- Run each case several times and count a case as passed only if it passes in all runs (strict) or in a majority (lenient). Use strict for critical cases.
- Record the number of runs in the gate output so people know how much to trust it.
Gaming the gate
If developers tune the prompt until the evaluation set passes, the set stops measuring quality and starts measuring how well the prompt was fitted to it. Keep a held-out portion of cases that developers don't read while iterating, and run it only at the gate. When a held-out case fails, you have found a real generalization problem.
Thresholds that are never allowed to fail
If the gate has never blocked anything, it may be too loose. If it blocks everything, people will route around it. Review the history of gate decisions occasionally. A gate that is bypassed with a manual override should log who overrode it and why.
Grader errors
A gate is only as good as its graders. A model-based judge that is miscalibrated can fail good outputs or pass bad ones, and the gate will faithfully act on that. Use code-based checks or human-reviewed labels for critical rules where you can, and keep judge calibration current as covered in the previous chapter.
Summary of the gate checks
| Check | Question it answers | What it blocks | Typical rule |
|---|---|---|---|
| Pass-rate threshold | Is quality good enough overall? | Broad weakness | Pass rate at or above the acceptance threshold |
| Zero-tolerance rule | Is any unacceptable failure present? | Rare, severe failures | No failed case marked critical |
| Aggregate regression | Is it worse than production? | Quiet decline | Drop no larger than the allowed margin |
| Case-level regression | Which previously passing cases broke? | Lost behavior | Reviewer sign-off on each newly failing case |
Where the gate runs
Run the gate in the same place as your other automated checks, for instance on every pull request that touches prompts, model settings, or retrieval code, and before each deployment. Save the full result, the baseline it compared against, and the dataset version with each run. If someone asks later why a release shipped, you can answer from the record.
Evaluations take time and cost money, especially with model-based judges. A common compromise is a small fast subset on every change and the full set before release. Include all critical cases in the fast subset.
Common errors
- Using only the pass rate, so critical failures hide in a high average.
- Comparing the candidate with a fixed number and never with the current production baseline.
- Treating one noisy run as a final verdict on a nondeterministic system.
- Blocking on every individual regression, which makes the gate unusable.
- Letting the evaluation set drift so that the baseline and candidate were scored on different cases. Always score both on the same dataset version.
Exercise
A candidate prompt scores 96% on a 50-case evaluation set, and your minimum pass rate is 90%. One failed case is marked critical. Production scored 97% on the same set. Does the candidate ship? Name each check and its result.
Show answer
It does not ship. The pass-rate threshold passes (96% is at least 90%). The zero-tolerance rule fails because one critical case failed. The aggregate regression check passes if your margin is at least 1 point (97% minus 96% is a 1-point drop). Any one failed check is enough to block, and the gate should report the critical case ID so it can be fixed.
Exercise
Your gate reports "ship: true" with a pass rate of 0.0 on a run where the grader service was down and returned no results. What is wrong, and how would you change the gate?
Show answer
The gate treats missing results as acceptable. With no results the gate should block, and a grader error should be reported as a separate failure reason. Add a check that the number of graded cases equals the number of cases in the dataset, and add a test that simulates an empty or failed run and expects a block.
Exercise
You ran a 100-case critical-category set and saw 0 failures. Can you claim the failure rate is below 1%?
Show answer
No. With 0 failures in 100 cases, the rough 95% upper bound on the true failure rate is about 3/100, or 3%. To support a claim of under 1%, you would need roughly 300 independent cases with no failures, or you would need to state the requirement and evidence in terms of what the set can show.