Sub topic 11
Reporting results and triaging failures
This chapter assumes you already have a golden dataset, deterministic checks, a baseline pass rate, and a CI job that runs the suite. Here you will make the results readable and decide what to do when a case fails.
Why a red build is not enough
A failing eval job that only says "1 failed" sends the developer into the logs. LLM failures also differ from unit-test failures. A case can fail because the prompt got worse, because the model's output varied, because the check is too strict, or because the case itself is wrong. Good reporting gives you the evidence to tell these apart quickly.
For each failed case, record:
- The case id and its tags, such as
adversarialorformat. - The input sent to the model.
- The raw output, before any parsing.
- Which check failed and why.
- The model name, prompt version, and parameters used for the run.
Writing a machine-readable report
Pytest can write a JUnit XML file, and most CI systems render it. You also want a small summary of your own, so a human can see the pass rate against the baseline at a glance. The script below reads a results list and writes a Markdown summary.
import json
from pathlib import Path
def write_summary(results, baseline, path="eval-summary.md"):
total = len(results)
passed = sum(1 for r in results if r["passed"])
rate = passed / total
lines = [
"## Eval results",
"",
f"- Pass rate: {rate:.1%} ({passed}/{total})",
f"- Baseline: {baseline:.1%}",
"",
"| Case | Check | Reason |",
"| --- | --- | --- |",
]
for r in results:
if not r["passed"]:
lines.append(f"| {r['id']} | {r['check']} | {r['reason']} |")
Path(path).write_text("\n".join(lines) + "\n", encoding="utf-8")
Path("eval-results.json").write_text(json.dumps(results, indent=2), encoding="utf-8")
if __name__ == "__main__":
sample = [
{"id": "refund-01", "passed": True, "check": "", "reason": ""},
{"id": "refund-02", "passed": False, "check": "required_keys", "reason": "missing 'amount'"},
]
write_summary(sample, baseline=0.95)In GitHub Actions, append the summary file to $GITHUB_STEP_SUMMARY and upload eval-results.json as an artifact. Keep the full outputs in the artifact, because the summary table should stay short.
Triage: sort failures by cause
When the suite fails, work through the failures in a fixed order. Starting with the cheapest explanation saves time.
The categories in practice:
| Cause | Typical sign | Action |
|---|---|---|
| Flaky output | Passes on rerun, failure not tied to your change | Repeat the case and use a pass-rate threshold |
| Check too strict | Output reads fine but a phrase differs | Loosen the check, for example match on keywords |
| Bad case | Expected value is wrong or outdated | Correct the case and note it in the change |
| Real regression | Output is wrong, and it began with your change | Fix the prompt, parameters, or model choice |
| Provider drift | Failures with no change on your side | Check the model version, see the pinning chapter |
To find out whether your change caused a failure, run the same case against the base branch. If it passes there and fails on your branch, your change is responsible. This comparison is the most useful single step in triage.
Look for patterns, not single cases
Group failures by tag. Five failures across five different tags suggest noise or a broad change such as a model swap. Five failures all tagged json_format point to one cause, usually a prompt edit that weakened the formatting instruction. Also compare which cases flipped from pass to fail and which flipped from fail to pass. A change that fixes three cases and breaks four is a trade-off, and the reviewer should see it stated.
Keeping reports useful over time
- Store each run's results with the commit hash so you can plot the pass rate over time.
- Post the summary as a pull request comment, so reviewers see it without opening CI.
- Never print secrets or user data from real traffic into public logs. Redact or sample outputs in reports.
Exercise
A pull request lowers the pass rate from 96% to 91%. All five new failures carry the tag json_format, and each one passes when you rerun it on the base branch. What is the most likely cause, and what is your next step?
Show answer
The most likely cause is a real regression from the pull request, probably a prompt or parameter edit that weakened the formatting instruction. The cases pass on the base branch, so the change is responsible, and the shared tag points to a single cause. Next, read the raw outputs of the failed cases to confirm what broke, fix the prompt, and rerun the suite. Do not lower the baseline.