fix(e2e): a stopped run keeps its output and token usage in the report - #1838
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 raisesStoppedEarly(aRuntimeError) carrying the partial text and usage. The two OpenAI-compatible backends share_chat_completion.tests/run_e2e.py: aStoppedEarlybecomesERRwith 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_TOKENSdriven throughrun_testandrender_err:main(control)NoneNone{'output': 65536, 'thinking': None}Stubbed Anthropic (
max_tokens) and chat (length) responses raiseStoppedEarlywith 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, onlytests/harness files changed, both named here), e2e--dry-runbuilds the canary prompt. Ruff findings on both files are identical tomain'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