Skip to content

fix(e2e): a stopped run keeps its output and token usage in the report - #1838

Merged
braboj merged 1 commit into
mainfrom
fix/e2e-stopped-run-usage
Sep 19, 2026
Merged

braboj merged 1 commit into
mainfrom
fix/e2e-stopped-run-usage

Conversation

@braboj

@braboj braboj commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Part of #1707 — its second expected item. The first (the canary completing under the ceiling) needs a live run, which this makes worth taking.

Change

  • tests/providers.py: each API backend reads usage before checking the stop reason, and raises StoppedEarly (a RuntimeError) carrying the partial text and usage. The two OpenAI-compatible backends share _chat_completion.
  • tests/run_e2e.py: a StoppedEarly becomes ERR with elapsed time, tokens, partial output and prompt; the report renders them. Any other provider error renders as before.

This touches only the e2e harness under tests/; no template, no assertion, no test case. No CHANGELOG entry: nothing a consuming project sees.

Verified

A stubbed Gemini returning MAX_TOKENS driven through run_test and render_err:

Tree usage elapsed Tokens line partial output
main (control) None None absent absent
this branch {'output': 65536, 'thinking': None} set present present

Stubbed Anthropic (max_tokens) and chat (length) responses raise StoppedEarly with text and usage; completed ones return as before. A plain provider error renders the same single line. Smoke 33/33, conformance 0 failed (three readings read: no other ready PR, only tests/ harness files changed, both named here), e2e --dry-run builds the canary prompt. Ruff findings on both files are identical to main's.

A run stopped at the ceiling reports output tokens at the ceiling by construction, so the figure alone does not say how far over it went; the partial output shows what the model spent them on.

🤖 Generated with Claude Code

A provider that stopped on anything but a finished answer raised before
it read the response's usage, so an ERR report carried one line and no
figures. Each API backend now raises StoppedEarly carrying the text it
produced and its usage, and the runner reports a stopped run's elapsed
time, tokens, partial output and prompt. Other provider errors render as
before.

Part of #1707

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@braboj
braboj merged commit 6919b32 into main Sep 19, 2026
1 check passed
@braboj
braboj deleted the fix/e2e-stopped-run-usage branch September 19, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant