Skip to content

feat(eval): stop on a Claude quota outage and resume the run later - #5533

Merged
kovtcharov-amd merged 6 commits into
mainfrom
feat/eval-quota-resume
Oct 21, 2026
Merged

kovtcharov-amd merged 6 commits into
mainfrom
feat/eval-quota-resume

Conversation

@kovtcharov-amd

@kovtcharov-amd kovtcharov-amd commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

When the Claude account running a flagship eval ran out of quota, every remaining scenario failed in seconds as an ordinary error and the run still went green: v0.25.1-rc2 lost 68 of 343 scenarios that way (#5493, section 6.4). Now the run stops the moment Claude's quota or credential gives out (or Claude fails to answer two scenarios in a row): nothing else is launched, the rest are recorded as NOT_RUN (never PASS, never an ordinary error), and it exits 3 with the account, the reset time and the command to finish it. gaia eval agent --resume <run-dir> then runs only the scenarios without a result and merges them into the same scorecard, each stamped with the commit and time it ran at.

Closes #5265. Stacked on #5525 (Claude usage); I'll rebase onto main once that merges.

In CI a quota stop already ends the lane (any non-zero exit does), and the integrity gate's --fail-on-zero-token-errors now also counts these scenarios, so a dispatch still fails. The lane's run directory doesn't survive the job, so CI re-dispatches the printed -f scenarios=... list (#5513) rather than using --resume.

Test plan

  • pytest tests/unit/eval tests/test_eval.py tests/unit/test_eval_launch_contract.py: 1579 passed, 30 skipped
  • tests/unit/eval/test_quota_resume.py runs the real runner loop against a fake claude -p that runs out of quota after N scenarios: nothing is launched after it, the rest are NOT_RUN, exit code 3, the message names account, reset and resume command, and the token never reaches the log
  • Resume runs only the missing scenarios, keeps earlier results with their commit and time, warns when commits differ, refuses a different --model, stops again if the quota runs out again, and is a no-op on a finished run
  • A single zero-token failure with no quota or credential wording stays resumable but doesn't stop the run; two in a row do
  • A genuine FAIL, a timeout, a "rate limit" phrase inside a transcript, the scenario's own budget cap, and a driver that forges claude_outage or NOT_RUN never stop a run
  • Outage phrases checked against the strings in the installed claude CLI (2.1.303): "You've hit your limit", "Usage limit reached", "monthly spend limit", "limit resets"
  • PYTHONPATH=src python util/lint.py --all passes
🔍 Technical details
  • gaia.eval.claude_outage.classify_driver_failure reads only the CLI's is_error result, api_error_status, and stderr/stdout when there is no JSON. Its phrase lists extend judge_outage's with the subscription CLI's wording. util/classify_claude_probe.py keeps its own copy because it runs in the preflight before GAIA is installed.
  • A failure with zero tokens and zero API time counts as an outage ("Claude never answered") even without a matching phrase. That was rc2's signature, whose stored errors were cut before the CLI's message.
  • The run loop moved into AgentEvalRunner._execute, which fresh and resumed runs share. The .progress.json path it replaces could never resume anything because every run got a new directory.
  • --resume reads the run's own scorecard.json, which now carries config.plan. CI uploads that file, so a lane that restores its previous artifact could resume too.

A passing scenario kept only the driver's own guess at its cost and dropped
the token counts claude -p reports, so nobody could say what a flagship sweep
cost or where its tokens went. Each scenario now records input, output, cache
read, cache write, API calls and list-price cost under `claude_usage`, summed
across --iterations attempts. The scorecard adds them up per category and per
run, summary.md shows the table, and the all-lanes CI summary adds the lanes.

Usage is filed by role. The scenario session is the `driver`, and it also
judges every turn, so its tokens cover both jobs; a separate judge-only call
files under `judge`. A scenario killed on timeout records nothing, and the
totals say how many scenarios they are missing.
When the Claude account behind gaia eval agent ran out of quota mid-run,
every later scenario failed within seconds as an ordinary error and the run
stayed green: v0.25.1-rc2 lost 68 of 343 scenarios that way. The runner now
reads each failed claude -p call and, when Claude itself was the problem (out
of quota, credential rejected, or never answered), stops at once. That
scenario is INFRA_ERROR, every later one is NOT_RUN, neither counts as a pass,
an error or a regression, and the run exits 3 naming the account, when the
limit resets and the command to finish it.

`gaia eval agent --resume RUN_DIR` runs only the scenarios without a result,
under the run's own model, agent and settings, and rewrites that run's
scorecard with everything merged. Each result records the commit and time it
ran at, so a scorecard that mixes commits says so.

Only the CLI's own error fields are classified, never a transcript: the
agent's sleep tool description says "until a rate limit resets". The phrase
lists extend judge_outage's with the subscription CLI's wording. The
integrity gate's --fail-on-zero-token-errors also counts these scenarios, so
a dispatch still fails on a quota outage.

Refs #5265
@github-actions github-actions Bot added documentation Documentation changes cli CLI changes eval Evaluation framework changes tests Test changes performance Performance-critical changes labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

When Claude's quota or credential gives out partway through an eval, the run now stops at once and marks every remaining scenario as "not run" instead of quietly recording dozens of fake errors and going green. A new gaia eval agent --resume <run-dir> then finishes only what's missing. The logic holds together. The resume path keeps the run's own model, agent and settings, refuses flags that would change them, and keeps the original scenario order. The integrity gate and JUnit output now treat not-run scenarios as unmeasured, not as passes. There are tests that run the real runner loop against a fake CLI that runs out of quota.

One thing to weigh before merge: a failed driver call that used zero tokens is treated as "Claude unavailable" even when its message doesn't look like a quota or credential problem. A per-scenario setup failure that dies before any API call would then stop the whole suite with exit 3 and a misleading "resume later" message. Consider keeping that fallback but showing Claude's raw error in the headline, or requiring a second consecutive hit before stopping.

Real-world evidence

The evidence stage ran the non-inference CLI paths on ubuntu-latest (commit 1101d4ff, synthetic scorecards). Highlights from the bundle:

$ gaia eval agent --resume /tmp/x --category rag_quality --iterations 2
Error: --resume takes the run's own selection and settings, so it cannot be combined with --category, --iterations. Drop them, or start a new run.
exit=2
$ gaia eval agent --resume /tmp/ev/done --model claude-sonnet-5
[ERROR] /tmp/ev/done ran with --model claude-opus-5, but this resume asked for claude-sonnet-5. A resumed run keeps its own --model; drop the flag, or start a new run to measure another one.
exit=1
$ gaia eval agent --resume /tmp/ev/stopped
[ERROR] Pre-flight check failed:
  - Agent UI not reachable at http://localhost:4200: <urlopen error [Errno 111] Connection refused>
  ...
[INFO] Resuming eval-stopped: 2 scenario(s) to run, 1 kept
exit=1

# scorecard afterwards — unchanged
[('budget_query', 'PASS'), ('cross_section_rag', 'ERRORED'), ('csv_analysis', 'NOT_RUN')]
$ python -m gaia.eval.integrity_gate ... --category rag_quality --fail-on-zero-token-errors
rag_quality: 12 scenario(s) run, 12 in baseline, unmeasured=errored=1, not_run=10
::error::Integrity: 11 scenario(s) were cut off or never started because Claude was unavailable: ...
exit=1

The no-scorecard, pre-plan scorecard, nothing-to-resume and missing-scenario cases also behaved as documented. Spot regressions on --compare and lane_summary were clean. Pending strix-halo lane: actually running resumed scenarios and merging them into the scorecard. For that path the verdict rests on static review plus the fake-CLI unit tests.

🔍 Technical details

🟢 Zero-usage fallback can stop the suite on a non-Claude failure (src/gaia/eval/claude_outage.py:317-320)
_never_reached returns UNREACHABLE for any failed payload with zero usage and no duration_api_ms, even without a quota or credential phrase. The CLI can also emit an is_error JSON with zero usage for local failures that happen before any API call (bad --mcp-config, a scenario-specific setup error). The runner would then stop, write NOT_RUN for the rest, exit 3 and print "Claude never answered". The PR explains why the fallback exists (rc2's truncated errors), so this is a judgement call, not a bug. A cheap mitigation is requiring two consecutive zero-usage failures before tripping, or keeping detail prominent in the headline, which _outage_report already partly does via Claude:.

🟢 Integrity gate exit depends on summary counters, not no_tokens (src/gaia/eval/integrity_gate.py:~295)
The evidence bundle found that a scorecard with an empty or stale summary prints the ::error:: outage line but still exits 0. This predates the PR and doesn't happen with build_scorecard output. Since zero_token_errors now catches NOT_RUN and outage results directly, making a non-empty no_tokens fail on its own under --fail-on-zero-token-errors would close the gap.

🟢 _not_run results aren't stamped (src/gaia/eval/runner.py:674)
Skips and real results get ran_at and commit via _stamp_run_info, but NOT_RUN placeholders don't. That's arguably correct, since nothing ran. But a consumer that expects every scenario to carry commit (the docs say "Each scenario records the commit and time it ran at") will see the field missing. Either stamp them with commit: None, or reword the doc to "each scenario that ran".

Strengths

  • _execute is shared by fresh and resumed runs, and the dead .progress.json path is gone. Resume now goes through one tested code path instead of a second one that could never actually run.
  • Defense against a driver forging NOT_RUN or claude_outage (runner.py:2516-2521), and outage detection reads only the CLI's own error fields, never transcripts. That avoids false trips on tool descriptions that mention "rate limit resets".
  • The resume guardrails fail loudly, each naming what's wrong and what to do: clashing flags, a model or agent mismatch, a scenario that no longer loads, a pre-plan scorecard.

eval_flagship.yml runs lane_summary.py as a plain file on a hosted runner
with no GAIA install, and the new usage table imported gaia.eval.claude_usage,
so the summary step would fail on every run. The two helpers it needs are now
inlined (stdlib only), a test pins them to claude_usage's fields, and another
runs the file exactly as CI does (python -S, no gaia on the path).
A failed driver call with zero tokens and no quota or credential wording could
be one scenario's own problem, not the account's, so a single one no longer
stops the whole suite: it is recorded as INFRA_ERROR, stays resumable, and a
second one in a row stops the run. Explicit quota and credential failures
still stop at once.

The integrity gate now fails on outage results counted from the scenarios
themselves, so a scorecard with a stale summary block cannot pass an outage.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Took all three suggestions. A single zero-token failure with no quota or credential wording no longer stops the suite; two in a row do. The gate now fails on an outage even when a scorecard's summary is stale, and the docs say "each scenario that ran" records its commit.

🔍 Technical details
  • d34147a: UNREACHABLE_STOP_AFTER = 2 in _execute. A lone one is still INFRA_ERROR with claude_outage, so --resume re-runs it, and a [WARN] names it. Explicit quota and credential failures still stop on the first hit. Tests: test_one_unexplained_zero_token_failure_does_not_stop_the_run, test_two_in_a_row_stop_the_run.
  • integrity_gate.main returns 1 when no_tokens is non-empty even with no counter problems: test_gate_fails_on_an_outage_even_with_a_stale_summary.
  • NOT_RUN placeholders stay unstamped, because nothing ran. docs/reference/eval.mdx now says so.

Base automatically changed from feat/eval-claude-usage to main October 21, 2026 20:17
# Conflicts:
#	docs/reference/eval.mdx
#	src/gaia/eval/runner.py
#	src/gaia/eval/scorecard.py
#	tests/unit/eval/test_claude_usage.py
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 6b17493 Oct 21, 2026
44 of 46 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the feat/eval-quota-resume branch October 21, 2026 21:01
kovtcharov-amd added a commit that referenced this pull request Oct 21, 2026
Main moved the scenario loop into _execute and made runs resumable
(#5533). The agent-model pin now follows that shape: _execute passes
it to every scenario, _finish records the model the run may claim, and
a resumed run keeps its own pin and refuses a different --agent-model,
the way it already refuses a different --model.
kovtcharov-amd added a commit that referenced this pull request Oct 30, 2026
The plan's cost-and-tiering section has largely landed since it was written: the RC smoke tier, nominated full sweep, weekly backlog lane and Qwen3.6 scoring (#5535), real Claude usage per scenario (#5525) and quota stop-and-resume (#5533). The status line, the implementation table and the stale "isn't recorded" and "v0.25.1 final" claims now say so, and two answered open questions are dropped.

Also fixes the two contradictions the review flagged: the scenario eval could have caught 2 escapes, not 3 (#5413 needs a scripted model), and item 3 adds re-runs to the existing Strix Halo eval.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI changes documentation Documentation changes eval Evaluation framework changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(eval): stop a run as soon as the Claude judge runs out of quota

1 participant