Eval Failure Aggregator
Aggregate eval run rows into stable pass-rate and error diagnostics.
Summarize model evaluation runs into pass rate, failing cases, and top errors.
Requirements
- Define
summarize_runs(runs). - Each run is a dict with
case_id,passed, and optionalerror. An optionalcategoryfield may appear on runs; ignore it in this problem (used only in follow-ups). - Return a dict with:
totalpassedpass_ratefailing_casestop_errors
failing_casescontains unique failed case IDs sorted alphabetically.top_errorscontains(error, count)pairs for failed rows with a non-empty error.- Ignore error strings on passing rows; only failed attempts contribute to error counts.
- Sort top errors by count descending, then error alphabetically.
- For no runs,
pass_rateis0.
This is an attempt-level pass rate: passed / total, without rounding. A case that fails once and passes on retry still appears in failing_cases, because that list records any observed failure. A repeated failure increments its error count each time. top_errors contains every distinct non-empty failed error, not only the first few entries.
Example
runs = [
{"case_id": "a", "passed": True},
{"case_id": "b", "passed": False, "error": "timeout"},
]
assert summarize_runs(runs) == {
"total": 2,
"passed": 1,
"pass_rate": 0.5,
"failing_cases": ["b"],
"top_errors": [("timeout", 1)],
}Constraints
- Don't mutate input runs.
- Count each run toward
total, even repeated case IDs. - Count unique case IDs only in
failing_cases. - Every run has a string
case_idand booleanpassed. If present,erroris a string; malformed rows are outside this exercise. Extra fields, includingcategory, do not affect this global summary. - Preserve error strings exactly. Ignore a missing or empty error, but count
" "and"timeout "as non-empty strings distinct from"timeout". Use case-sensitive lexicographic string order for the requested sorts.
For one failed "same" attempt followed by one passing "same" attempt, return total=2, passed=1, and pass_rate=0.5, while keeping "same" in failing_cases. Do not replace the failed observation with the latest result. This summary describes the supplied batch; repeated attempts weight frequently retried cases more heavily and do not by themselves establish performance on a representative population of cases.