Skip to content

fix(health): stop flagging recovered model calls - #3769

Merged
giuliolovisotto merged 1 commit into
mainfrom
glovisotto/health-last-model-call
Oct 5, 2026
Merged

giuliolovisotto merged 1 commit into
mainfrom
glovisotto/health-last-model-call

Conversation

@giuliolovisotto

@giuliolovisotto giuliolovisotto commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

A model call that fails and is then retried successfully can still make a rollout unhealthy because model_call_failed flags every bound failure. Remove that check and use rollout_ended_on_failed_model_call from #3427 unchanged. Earlier failures remain in diagnostic counts. Existing ignore settings using model_call_failed map to the retained check.

Keep the explicit context-overflow exemptions from this follow-up to #3761: rejected requests do not trigger missing-token, zero-completion-token, or runaway-generation findings. The vLLM adapter records the rejection category with propagation enabled or disabled; HTTP behavior is unchanged. A final rejection still counts as a failure under the retained check. Its existing per-model semantics apply, including to subagent and auxiliary calls.

No separate issue is needed for this focused follow-up. Rewards and benchmark scores are unchanged.

Validation:

  • python -m pytest tests/unit_tests/test_rollout_health.py responses_api_agents/opencode_agent/tests/test_trajectory.py tests/unit_tests/test_fern_docs_links.py --no-cov -q: 173 passed, 17 subtests passed.
  • python -m pytest responses_api_models/vllm_model/tests/test_app.py -k context_overflow_propagation_flag --no-cov -q: 4 passed.
  • python -m pre_commit run --all-files: passed.
  • cd fern && npm run check: passed (0 errors, 1 warning).
  • MiniSWE/Terminus observability tests are delegated to full server CI; the combined local harness test command could not collect because minisweagent is not installed in the core environment.
  • GitHub CI on rebased head 0dbbd3772: passed, including the core coverage gate and all eight server shards. No unresolved CodeRabbit review threads.

Live-model rollout: N/A. Changes are limited to postprocessing and captured error metadata; inference and agent execution behavior are unchanged.

@giuliolovisotto giuliolovisotto added bug Something isn't working area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters needs-review PR is ready for code review and waiting on a reviewer labels Sep 29, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team September 29, 2026 14:40
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team September 29, 2026 15:02
@Glorf
Glorf force-pushed the mbien/fep-1477-execution-outcomes branch from 984e710 to 25a5da4 Compare September 29, 2026 15:32
@yaoyu-33 yaoyu-33 added the complexity:medium Single-domain change with interacting parts or a moderate review surface label Sep 29, 2026
@giuliolovisotto
giuliolovisotto force-pushed the glovisotto/health-last-model-call branch from 7554a0a to 9e73096 Compare September 29, 2026 15:37
@giuliolovisotto
giuliolovisotto force-pushed the glovisotto/health-last-model-call branch from 9e73096 to 13bfdcf Compare September 30, 2026 12:08
Base automatically changed from mbien/fep-1477-execution-outcomes to main September 30, 2026 12:30
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Sep 30, 2026
@giuliolovisotto

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

SHIP — no reliability concerns.

Reviewed the rename of model_call_failed → model_call_last_failed and the context-overflow exclusions. Traced the full path from the vLLM producer through capture persistence to the checks.

What's solid:

  • _last_root_model_calls picks each finished root's last call by model-server request start time, not completion/capture/reference order, and conservatively returns unobserved (never a false finding) on incomplete capture, missing/non-finite/tied started_at, incomplete bindings, ownership gaps, or calls shared across invocations. Single-call roots skip the timestamp requirement. Backed by thorough new parametrized tests.
  • _is_context_overflow_rejection is correctly narrow (requires upstream_attempted, upstream_status_code == 400, and an explicit context_length_exceeded marker), so it excludes recovered overflow from zero-token/missing-token/runaway checks without masking genuine empty generations. Confirmed error_category/upstream_attempted/local_response_reason are actually persisted into response_metadata (base_responses_api_model.py:835,849,1281), so the exclusion fires in production, not just in tests.
  • normalize_ignored_checks maps the legacy ignore name to the new ID; docs and all four test suites updated consistently. No stale references in non-test code.

One deliberate behavior change to be aware of (not a defect): this narrows failure detection — an intermediate policy call that failed hard but was recovered (agent continued, final call succeeded) no longer flips a rollout to unhealthy. This is the documented intent, and the total-failure count is still preserved in the model_call_errors stat, so nothing is silently dropped.

Validation note for the author: per the quality bar, confirm a representative real smoke rollout was inspected (not just the green unit tests) since this changes health-reporting behavior.

@giuliolovisotto giuliolovisotto changed the title fix(health): evaluate the final top-level model call fix(health): stop flagging recovered model calls Oct 2, 2026
@giuliolovisotto

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

SHIP — no reliability concerns.

Reviewed the full diff and traced the capture→health data flow. This is a coherent, well-tested consolidation of model_call_failed into rollout_ended_on_failed_model_call plus a context-overflow exclusion for the per-call quality checks.

Correctness points I verified:

  • No terminal failures lost. The removed model_call_failed only ran over bindings.matched_calls, so it was blind to failures that returned no response id (the 403/auth case your own test at test_a_rollout_whose_last_model_call_failed_is_unhealthy documents). rollout_ended_on_failed_model_call reads _normalized_trajectory_calls directly, so it is strictly more capable at catching terminal failures. The only behavior dropped is flagging retried-and-recovered mid-chain failures as findings — intentional (docstrings + test_only_final_failure_affects_health_for_bound_calls), and model_call_errors still counts every failed call for observability.

  • Overflow exclusion is narrowly scoped. _is_context_overflow_rejection is gated on upstream_attempted is True + upstream_status_code == 400 + explicit context_length_exceeded (local reason or error category), and only suppresses the three quality checks — never rollout_ended_on_failed_model_call. So an unrecovered terminal overflow is still flagged; only recovered ones are quieted. test_uncertain_or_real_generations_keep_quality_checks pins the guards; test_recovered_explicit_overflow_does_not_fail_generation_checks pins the exclusion. Finding logic (checks.py) and unobserved-gating (rollout_health.py) exclude it symmetrically, so excluded calls read as evaluated/healthy rather than stuck in unobserved.

  • error_category plumbing is sound. ModelExecutionOutcome.error_category is NotRequired, so exchange.update(execution) only overwrites when vLLM set it in the overflow branch; non-overflow transport errors keep the _classify_status-derived category. The new field flows through rollout_collection metadata into the normalized calls as expected.

  • Backward compat. model_call_failed is accepted as an ignore-list alias (test_old_failed_check_ignore_name_maps_to_new_check), docs and the v0.6.0 frozen docs are handled correctly, and the osworld model_call_failed strings are an unrelated agent-outcome enum, not the check id.

Docs, reference table, and the three agent observability tests are all updated to match.

🤖 Generated with Claude Code

@wprazuch wprazuch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@giuliolovisotto
giuliolovisotto added this pull request to the merge queue Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37282355529

Merged via the queue into main with commit 0f56dd0 Oct 5, 2026
44 checks passed
@giuliolovisotto
giuliolovisotto deleted the glovisotto/health-last-model-call branch October 5, 2026 08:27
cmunley1 pushed a commit to wdykas/Gym that referenced this pull request Oct 8, 2026
…ecks (NVIDIA-NeMo#4229)

## What changed

`model_call_missing_token_counts` and
`model_call_zero_completion_tokens` now 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_mismatch` no 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. NVIDIA-NeMo#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

- A rollout that ends on a failed call stays unhealthy through
`rollout_ended_on_failed_model_call` (NVIDIA-NeMo#3769). Whether a rollout
recovered is decided there, per model and in start-time order; this
change does not infer retries.
- A failed call that did generate (it has a finish reason) keeps every
check. This preserves NVIDIA-NeMo#3769's rule that an empty length-limited
generation without explicit overflow evidence keeps its quality findings
(`test_uncertain_or_real_generations_keep_quality_checks` is unchanged).
- A 2xx body that capture could not parse (`capture_parse_error`) is a
capture defect, not a failed call, and stays checked.
- A missing count on a successful call is still a finding.
- `run.stats.model_call_errors` still 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 NVIDIA-NeMo#3769.

## Validation

- `pytest tests/unit_tests/test_rollout_health.py
responses_api_agents/opencode_agent/tests/test_trajectory.py`: 169
passed.
- New tests cover a cancelled, HTTP 429 and HTTP 500 attempt followed by
a successful call (healthy, with missing or zero counts), a rollout
ending on each of them (unhealthy for
`rollout_ended_on_failed_model_call` only), and an unparsed capture body
(still flagged). Nine of the ten fail without the fix; the
`capture_parse_error` test 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`: the `retry_429` and
`retry_500` scenarios now expect a healthy rollout. `model_error` keeps
`rollout_ended_on_failed_model_call` and an unobserved token
reconciliation, and no longer expects a missing-token finding. `pytest
tests/unit_tests/harness_capabilities` passes with these expectations.
- `pytest tests/unit_tests/test_rollout_collection.py
tests/unit_tests/test_cli_main.py`: 654 passed.
- `pre-commit run` on the changed files: passed.
- Not run locally: the Terminus 2 and mini-SWE observability tests
(their dependencies are not installed here). Their expectations only
require the token checks to be evaluated, which they still are.

## 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.

| | main (`ea8c013f4`) | this PR |
|---|---:|---:|
| unhealthy | 183 | **68** |
| unobserved | 529 | 644 |
| healthy | 0 | 0 |
| `rollout_ended_on_failed_model_call` findings | 68 | 68 |
| `model_call_missing_token_counts` findings | 373 | 0 |
| `run.stats.model_call_errors` | 373 calls / 183 rollouts | unchanged |

- **The 68 rollouts that ended on a cancelled call stay unhealthy.**
They are the same 68, flagged only by
`rollout_ended_on_failed_model_call`.
- **The 115 that recovered are no longer unhealthy.** They become
unobserved, not healthy, because their only open check is
`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.
- **No other rollout changed verdict.** The other 597 rollouts have the
same verdict under main and this PR.

## Compatibility

Health verdicts only: fewer `model_call_missing_token_counts` /
`model_call_zero_completion_tokens` findings on failed attempts, and
fewer `rollout_token_count_mismatch` unobserved results. Rewards,
collection outputs and aggregate metrics are unchanged.

🤖 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

1 inactive deployment
public — 0dbbd377 Deployed Oct 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #4257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer sla:triage-overdue Review assignment is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants