Repository navigation
fix(health): skip failed calls without a generation in token-count checks - #4229
Merged
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
giuliolovisotto
marked this pull request as ready for review
October 8, 2026 14:51
Contributor
…ecks A cancelled call or an HTTP error reply produced no generation, so it has no tokens to account for. model_call_missing_token_counts and model_call_zero_completion_tokens still flagged such attempts, which made a rollout unhealthy even when the client retried successfully. Skip them there and in rollout_token_count_mismatch's completeness gate. A rollout that ends on a failed call stays unhealthy through rollout_ended_on_failed_model_call. A failed call that did generate (it has a finish reason) keeps every check, preserving the uncertain-overflow behaviour, and a body capture could not parse stays checked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Giulio Lovisotto <[email protected]>
…ance scenarios The retry_429 and retry_500 scenarios recover after the failed attempts, which have no tokens to account for, so they now expect a healthy rollout. model_error still expects rollout_ended_on_failed_model_call and an unobserved token reconciliation, but no missing-token finding. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Giulio Lovisotto <[email protected]>
giuliolovisotto
force-pushed
the
glovisotto/health-failed-call-tokens
branch
from
October 8, 2026 15:42
417eb5c to
26487f5
Compare
mlazuka
approved these changes
Oct 8, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37822038576 |
This was referenced Oct 9, 2026
giuliolovisotto
added a commit
that referenced
this pull request
Oct 9, 2026
…en-total rule Health gains run.stats.model_call_errors.usage_unknown: failed calls with no finished response and no token counts. The token checks skip these calls (#4229), so any tokens the server spent on them were counted nowhere. The docs now state the token-total rule: response usage counts tokens from responses that finished, so a rollout whose every call was rejected reports zero, and only lost usage of a finished response leaves the comparison unobserved. The _is_failed_attempt docstring no longer claims a skipped call generated nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Giulio Lovisotto <[email protected]>
ehosseiniasl
pushed a commit
to ehosseiniasl/Gym
that referenced
this pull request
Oct 9, 2026
…en-total rule (NVIDIA-NeMo#4287) ## What changed - **New run statistic `run.stats.model_call_errors.usage_unknown`.** It counts failed calls that returned no finished response and carry no token counts. Since NVIDIA-NeMo#4229 the token checks skip these calls, so any tokens the server spent on them (a cancelled or timed-out call may have generated before it was cut) were not counted anywhere. - **Docs: the token-total rule.** - The agent's top-level response `usage` counts tokens from model responses that finished. - A rollout whose every call was rejected reports usage of zero, not missing usage. - Missing usage means a finished response's usage was lost, and only that makes `rollout_token_count_mismatch` unobserved. It is stated in the custom-agent guide (`observability/rollout-evidence`) and next to the check (`evaluation/rollout-health`). - **`_is_failed_attempt` docstring.** It no longer claims a skipped call generated nothing; it means the client got no finished response. ## Why The same rejected model call leaves different evidence depending on the harness. In the conformance scenario's scripted HTTP 400, Pi and OpenCode report the agent's usage as zero, while Hermes, NOOA and Simple Agent leave it missing. Health therefore gives different token verdicts for the same failure: healthy for the first group, unobserved for the second. This PR writes down one rule that harness adapters and the conformance scenario can target. Per-harness fixes and the strict conformance expectation follow separately; until then, NVIDIA-NeMo#4286 accepts either verdict. ## Split from The failure-record half of the original NVIDIA-NeMo#4287 is now a separate PR, because it needs reviewers from the rollout-collection side: NVIDIA-NeMo#4292. The two PRs are independent and can merge in either order. ## What stays the same - No health verdict changes: the token checks behave exactly as after NVIDIA-NeMo#4229. - The existing `model_call_errors` fields are unchanged. ## Not done - **Re-applying the token checks to a cancelled stream that had already delivered output.** The only "output arrived" signal capture records is the time to the first byte. In Responses-API streams the first event (`response.created`) arrives before any token is generated, so this would flag recovered retries again. All 373 cancelled calls in the Terminal-Bench 2.1 run that motivated NVIDIA-NeMo#4229 were cut before any byte arrived, and no harness is known to keep partial output. ## Issue No public issue; follows NVIDIA-NeMo#4229. ## Validation - `usage_unknown` assertions in the NVIDIA-NeMo#4229 health tests: counted for a skipped attempt, and not for a body capture could not parse. - `pytest tests/unit_tests/test_rollout_health.py tests/unit_tests/test_rollout_collection.py tests/unit_tests/harness_capabilities`: 760 passed. - **Full `tests/unit_tests` locally, before the split:** 7554 passed, 25 failed plus 1 collection error. None are in the changed areas: they are sandbox, telemetry, dataset and exporter tests that need dependencies or services not available locally. The same set failed locally for NVIDIA-NeMo#4229 and passed on CI. - `pre-commit run` on the changed files: passed. ## Rollout evidence N/A: a new run statistic and documentation only. No health verdict, check or rollout output changes, so there is nothing for a rollout to exercise. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Giulio Lovisotto <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This branch was previously deployed
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.
What changed
model_call_missing_token_countsandmodel_call_zero_completion_tokensnow skip a failed model call that produced no generation: a cancelled call or an HTTP error reply, which has no finish reason.rollout_token_count_mismatchno longer becomes unobserved because of such a call; it contributes zero tokens to the sum.Why
A failed attempt has no usage to account for, so missing token counts on it say nothing about token accounting. Before this change, a rollout that hit a failed call and then retried successfully was still unhealthy because of the failed attempt's null counts. #3769 had already stopped calling these rollouts "ended on a failed call".
Observed on a Terminal-Bench 2.1 run with Terminus 2: each model call has a 600 s client limit, after which the call is cancelled and retried. 373 cancelled calls across 183 rollouts; about 115 of those rollouts recovered and were unhealthy only through
model_call_missing_token_counts. Controlled conformance scenarios show the same pattern for HTTP 429/500 retries in OpenCode and Codex.What stays the same
rollout_ended_on_failed_model_call(fix(health): stop flagging recovered model calls #3769). Whether a rollout recovered is decided there, per model and in start-time order; this change does not infer retries.test_uncertain_or_real_generations_keep_quality_checksis unchanged).capture_parse_error) is a capture defect, not a failed call, and stays checked.run.stats.model_call_errorsstill counts every failed attempt.Capture stores an HTTP error reply's JSON body as the call's
response, so the rule keys on the missing finish reason rather than on a missing response.Issue
No public issue; this follows #3769.
Validation
pytest tests/unit_tests/test_rollout_health.py responses_api_agents/opencode_agent/tests/test_trajectory.py: 169 passed.rollout_ended_on_failed_model_callonly), and an unparsed capture body (still flagged). Nine of the ten fail without the fix; thecapture_parse_errortest pins unchanged behaviour.test_invocation_bound_failed_call_remains_evaluable(OpenCode) expected a token finding on a 503 without a generation; it now asserts the final-call finding and no token findings.scripts/harness_conformance/scenarios.py: theretry_429andretry_500scenarios now expect a healthy rollout.model_errorkeepsrollout_ended_on_failed_model_calland an unobserved token reconciliation, and no longer expects a missing-token finding.pytest tests/unit_tests/harness_capabilitiespasses with these expectations.pytest tests/unit_tests/test_rollout_collection.py tests/unit_tests/test_cli_main.py: 654 passed.pre-commit runon the changed files: passed.Rollout evidence
Health-only rerun of the saved Terminal-Bench 2.1 run with Terminus 2 described above: 712 rollouts, 89.3 GiB. No model compute: the same saved records were judged three times. Fields that no health check reads (request payloads, turn inputs, raw capture) were dropped to make the file portable. Health at the run's own Gym commit (
832d1cb) still reproduces the run's original result exactly, so the trimming did not change any verdict.ea8c013f4)rollout_ended_on_failed_model_callfindingsmodel_call_missing_token_countsfindingsrun.stats.model_call_errorsrollout_ended_on_failed_model_call.rollout_token_count_mismatch. This adapter does not link turns to model calls, so token reconciliation is unavailable, and the other 529 rollouts are unobserved for the same reason.Compatibility
Health verdicts only: fewer
model_call_missing_token_counts/model_call_zero_completion_tokensfindings on failed attempts, and fewerrollout_token_count_mismatchunobserved results. Rewards, collection outputs and aggregate metrics are unchanged.🤖 Generated with Claude Code