Skip to content

fix(eval): name a judge outage instead of dying in an SDK traceback - #4123

Merged
kovtcharov-amd merged 1 commit into
mainfrom
eval/judge-outage-classifier
Sep 24, 2026
Merged

kovtcharov-amd merged 1 commit into
mainfrom
eval/judge-outage-classifier

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

When the Claude judge runs out of credit, the Email Triage Eval currently ends a 21-minute run in a raw SDK traceback whose last line is an HTTP 400 — the same code Anthropic returns for a malformed request. Nothing in that output says the judge never scored anything, so the run reads as "the eval is broken" (or worse, as a model regression) when the actual fix is a spend-limit increase by someone else entirely. After this change the same failure prints a named report — what it is, what to do, where to go — and exits 1 with no traceback.

The bug was in three places, not one: the drafting, briefing and action-item judges all called the SDK unguarded, and all three run in the same CI lane. They now share one guarded call site, so the outage path can't be fixed in two of them and missed in the third.

A 400 on its own still fails as itself. Only the credit-balance and weekly-limit phrasings (and 402/429/401/403) are reclassified — a genuine bug must not be relabelled as someone else's billing problem.

Related: #4080 (the judge org running out of monthly spend is the live instance of this).

Test plan

  • python -m pytest tests/unit/eval/test_judge_outage.py tests/unit/eval/test_claude_judge.py -q → 61 passed
  • python -m pytest tests/unit/eval/ -q → no new failures (8 pre-existing failures in test_release_scorecard.py, unchanged at main)
  • python util/lint.py --black --isort clean on the touched files
🔍 Technical details

The load-bearing detail. JudgeOutageError subclasses RuntimeError, never ValueError. judge_drafts and judge_briefings both catch ValueError to write an ERRORED scorecard row — correct for an unparseable verdict, and exactly wrong for an outage, because it would publish a billing lapse as per-case model failures. TestOutageIsNotAValueError asserts this explicitly so a later refactor can't quietly reintroduce it, and TestJudgeDraftsAbortsOnOutage covers both sides: an outage aborts the run, while an unparseable verdict still produces status == "ERRORED".

Classification rules. 402/429 → quota and 401/403 → credential, decided on status_code alone. 400 is deliberately in neither set, since Anthropic uses it both for "credit balance is too low" and for a malformed request; that case is reached by phrase instead. Exceptions are duck-typed on status_code rather than importing anthropic, matching how claude.py guards its own import, so the module stays importable without the [eval] extras.

Test inputs are the real rejection strings, not paraphrases — the credit-balance 400 body and You've hit your weekly limit · resets Sep 23, 8am (America/Los_Angeles). Those two share no substring, so a classifier tuned only to the first would still miss the live CI failure; both are asserted.

Verified end to end by running the real eval_drafting_report.main() with only the Anthropic transport stubbed: exit code 1, the named report on stderr, no traceback.

Why not util/classify_claude_probe.py. It draws the same line for the CI preflight, but it classifies the text of a claude -p probe, while this classifies a raised SDK exception inside the library. They cannot be one file today: util/ has no __init__.py, is not a package, and setup.py sets package_dir={"": "src"}, so it is not in the wheel and gaia.eval cannot import it. The right end-state is the reverse dependency — the phrase lists live here and the probe script imports them — which is a follow-up, not this PR.

When the Claude judge ran out of credit, the Email Triage Eval ended a
21-minute run in a raw anthropic.BadRequestError whose last line was an
HTTP 400 — indistinguishable from a malformed request, and no hint that
nothing had been scored. A reader who does not know Anthropic returns 400
(not 402) for "credit balance is too low" reads it as an eval defect.

The three judge factories in gaia.eval (drafting, briefing, action items)
all called client.get_completion() unguarded. They now share
judge_completion_text(), which classifies a raised SDK exception into
JudgeOutageError and re-raises anything it does not recognise untouched —
a genuine bug must not be relabelled as someone else's billing problem.
The three CI report scripts wrap main() in run_with_outage_guard(), so an
outage prints a named, actionable report and exits 1 with no traceback.

JudgeOutageError subclasses RuntimeError, never ValueError, and that is
load-bearing: judge_drafts and judge_briefings turn a ValueError into an
ERRORED scorecard row, which is right for an unparseable verdict and
exactly wrong for an outage — it would publish a billing lapse as a model
regression. A test asserts the exception is not a ValueError so a later
refactor cannot quietly reintroduce that.

Status 402/429 and 401/403 classify on their own; 400 deliberately does
not, so the credit-balance case is reached by phrase and a malformed
request still fails as itself. The tests feed the verbatim rejection text
of both live failure modes (the credit-balance 400 and the weekly-limit
message, which share no substring with each other).

Not shared with util/classify_claude_probe.py on purpose: util/ is repo
tooling, is not a package and is not shipped in the wheel, so gaia.eval
cannot import it. The right end-state is the reverse dependency.
@github-actions github-actions Bot added eval Evaluation framework changes tests Test changes performance Performance-critical changes agent::email Email agent changes sidecar Agent sidecar contract / harness labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

When the Claude judge runs out of credit, the email evals now stop with a report that says so — what happened, who fixes it, where to go — instead of ending a 21-minute run in an SDK traceback that looks like the agent failed. All three email judges route through one guarded call, so the outage path can't be fixed in two of them and missed in the third, and a 400 that really means "your request is wrong" still fails as itself.

Nothing blocking. The one thing worth knowing: the same unguarded judge call still exists in the session-eval lane, where it also retries three times before dying in a traceback — a follow-up, not a merge blocker.

Real-world evidence

The evidence bundle exercised all three real report scripts on this runner with only the Claude HTTP boundary faulted with the verbatim production error body. Before → after on the drafting script:

# Before — exit 1, an SDK traceback that never says "billing":
[DRAFT-EVAL] generated 18/18 drafts
Traceback (most recent call last):
  ...
StubAnthropicAPIError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Your credit balance is too low to access the Anthropic API. ...'}}

# After — exit 1, zero traceback lines:
[EVAL] ERROR: JUDGE QUOTA EXHAUSTED [HTTP 400] — the Claude judge never scored anything, so this run
is an INFRASTRUCTURE OUTAGE, NOT a quality regression. Any scorecard from it is meaningless.

  What to do:  Ask an Anthropic org admin to raise the spend limit at
               claude.ai/admin-settings/usage, or wait for the stated reset, then re-run. ...
  Where:       https://claude.ai/admin-settings/usage and amd/gaia issue #4080

EXIT=1        grep -c Traceback stderr -> 0
eval-out/ -> []   # empty: no drafting_gate_report.json written

The check that matters most for trust — a genuinely malformed request is not relabelled as someone's billing problem:

### judge error: malformed request 400 (a REAL bug)
  draft_quality        propagated untouched: StubAnthropicAPIError: Error code: 400 - ...
  briefing_quality     propagated untouched: StubAnthropicAPIError: Error code: 400 - ...
  action_item_quality  propagated untouched: StubAnthropicAPIError: Error code: 400 - ...

Spot regression covered the contrast case: a reachable judge returning garbage still writes 18 ERRORED rows and exits 0, so the abort is scoped to outages only. Briefing and action-item scripts behaved identically. A live judged run (real key + Lemonade) is marked deferred to the strix-halo lane — the outage path can't be triggered against a healthy account anyway, and it's proven here against the real error body. This evidence supports the approve verdict.

🔍 Technical details

Issues found

🟢 The same unguarded judge call survives in the session-eval lane (src/gaia/eval/session_eval.py:210). It wraps client.get_completion in a bounded 3-attempt retry over bare Exception, so a quota outage there burns three attempts plus backoff and then dies in exactly the traceback this PR set out to eliminate. Routing it through judge_completion_text (and skipping retries once classify_judge_exception says quota/credential — retrying an empty wallet never helps) would close the last copy. Follow-up, not a blocker for this PR's scope.

🟢 QUOTA_PHRASES claims to be narrow but carries bare "quota" and "billing" (src/gaia/eval/judge_outage.py:223). _exception_text scans str(exc) + .message + .body, so any future SDK error whose body echoes judged content — and the drafting/briefing corpora are business email — could match on a stray "billing" and abort with the wrong remediation. The status codes and the specific phrases (credit balance, weekly limit, spend limit) already carry the real cases; the two generic words are the ones most likely to misfire.

🟢 JudgeOutageError accepts any kind string but three dicts must agree on it (judge_outage.py:296). headline(), _ACTIONS, and _WHERE all index by kind, so adding a fourth kind to two of the three raises KeyError inside the error-reporting path — the worst place to fail. A Literal["quota", "credential", "unclassified"] annotation plus one _ACTIONS-keyed lookup helper would make the drift impossible to ship.

Note on the duplicated phrase lists

The module docstring is upfront that util/classify_claude_probe.py holds a near-copy and explains why they can't merge today (util/ isn't a package and isn't in the wheel). Worth recording that they have already diverged: the probe has admin-settings/usage, oauth token, and please run /login; this module adds purchase credits, weekly limit, and not logged in. The stated end-state (probe imports from here) is the right one — the longer both live, the more they drift.

Strengths

  • The load-bearing invariant is tested as an invariant. JudgeOutageError subclassing RuntimeError rather than ValueError is what stops judge_drafts' ValueError catch from turning an outage into a scorecard full of ERRORED rows, and TestOutageIsNotAValueError plus the paired abort/still-score tests in TestJudgeDraftsAbortsOnOutage make that impossible to regress silently.
  • Test inputs are the real rejection strings, not paraphrases — the verbatim credit-balance 400 body and the You've hit your weekly limit · resets… text. They share no substring, so a classifier tuned to only one would pass a plausible test suite and still miss the live CI failure; both are asserted.
  • Fixed in all three judges at once via one shared call site, matching CLAUDE.md's fail-loudly rule: unrecognised exceptions re-raise untouched, and raise outage from exc keeps the SDK traceback for anyone who needs the raw error.
  • Duck-typed on status_code instead of importing anthropic, so the module and its tests stay importable without the [eval] extras — consistent with how claude.py guards its own import.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit c026d09 Sep 24, 2026
54 of 57 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the eval/judge-outage-classifier branch September 24, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes eval Evaluation framework changes performance Performance-critical changes sidecar Agent sidecar contract / harness tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants