Skip to content

feat(health): count failed calls with unknown usage and state the token-total rule - #4287

Merged
giuliolovisotto merged 1 commit into
mainfrom
glovisotto/fea-460-failed-call-evidence
Oct 9, 2026
Merged

giuliolovisotto merged 1 commit into
mainfrom
glovisotto/fea-460-failed-call-evidence

Conversation

@giuliolovisotto

@giuliolovisotto giuliolovisotto commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(health): skip failed calls without a generation in token-count checks #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, #4286 accepts either verdict.

Split from

The failure-record half of the original #4287 is now a separate PR, because it needs reviewers from the rollout-collection side: #4292. The two PRs are independent and can merge in either order.

What stays the same

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 fix(health): skip failed calls without a generation in token-count checks #4229 were cut before any byte arrived, and no harness is known to keep partial output.

Issue

No public issue; follows #4229.

Validation

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

@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

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 giuliolovisotto added the area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters label 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]>
@giuliolovisotto
giuliolovisotto force-pushed the glovisotto/fea-460-failed-call-evidence branch from 36ea9b3 to f7ff204 Compare October 9, 2026 13:52
@giuliolovisotto giuliolovisotto changed the title feat(health): keep failed-call evidence on failure records and count unknown usage feat(health): count failed calls with unknown usage and state the token-total rule Oct 9, 2026
@giuliolovisotto
giuliolovisotto marked this pull request as ready for review October 9, 2026 14:05
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 9, 2026 14:06
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@yaoyu-33 yaoyu-33 added complexity:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 9, 2026
@giuliolovisotto
giuliolovisotto added this pull request to the merge queue Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit 80a44cc Oct 9, 2026
52 of 55 checks passed
@giuliolovisotto
giuliolovisotto deleted the glovisotto/fea-460-failed-call-evidence branch October 9, 2026 17:18
ananthsub pushed a commit to ananthsub/Gym that referenced this pull request Oct 12, 2026
The main/merge-queue [run
38069955548](https://github.com/NVIDIA-NeMo/Gym/actions/runs/38069955548/job/114266522363)
completed all probe jobs but failed the P0 measurement: Codex 0/7,
OpenCode 5/7, Pi 6/7, Hermes 7/7. The reporter is correctly exposing
retained-evidence failures.

This integrates the applicable existing fixes with the current
native-session adapters:

- Port NVIDIA-NeMo#4047's temporary Codex session reader and bounded 429 forwarding
retries, including its timeout result preservation. Keep invocation
ownership, original tool IDs/arguments/results and shell exit status
before removing the temporary session. Native sandbox-session execution
remains as implemented on main.
- Port the shell-outcome portion of NVIDIA-NeMo#4046 into the shared OpenCode
artifact parser. Nonzero exits fail; absent/null/invalid exits remain
unknown. Preserve native turn semantics, per that PR's review
discussion.
- Require one terminal-400 token reconciliation outcome: `healthy`, with
a known zero aggregate for zero finished responses. Preserve Hermes'
actual runtime counters when early error returns omit them. Failed model
termination still must be `unhealthy`; missing aggregate usage and
incorrect nonzero totals fail. The health engine is unchanged.

The token-total rule follows merged NVIDIA-NeMo#4287. This deliberately does not
revive closed NVIDIA-NeMo#4286's proposal to accept either healthy or unobserved.
No separate issue is necessary: the linked run is the reproduction, and
NVIDIA-NeMo#4046/NVIDIA-NeMo#4047 plus FEA-461 track the underlying gaps. Existing PRs are
left intact for author/maintainer coordination. Codex work is attributed
to Frederic Lafrance and Giulio Lovisotto; OpenCode's nonzero-exit
correction derives from Frederic's patch.

Validation on macOS arm64 / Python 3.13.14, OpenAI SDK 2.44.0; base
`728ac3395d1bc26b995b03ffb9aa6f0362b768ea`:

- **2,050 passed, 113 skipped** in the final selected suite; skips are
platform/optional-runtime cases.
- Full `pre-commit run --all-files` and staged/working-tree `git diff
--check` pass. Commit has DCO sign-off.
- **28/28 conformance scenarios pass** across all four pinned harnesses;
final Codex-only rerun is also 7/7.
- Real `nvidia/nemotron-3-super-120b-a12b` model smoke: Codex, OpenCode
and Hermes each have four captured model calls, one failed tool followed
by two successful tools, and reward **1.0**. A local verifier
independently checked the file contains `391` and the final answer
contains `CONFORMANCE_DONE`. OpenCode's initial attempt was denied by
its native external-directory permission; the rerun explicitly granted
only the smoke's temporary artifact directory. Both attempts are
retained.

Exact test selection:

```bash
python -m pytest --import-mode=importlib -q -o addopts='' -o log_cli=false \
  scripts/harness_conformance/tests tests/unit_tests/harness_capabilities \
  tests/unit_tests/test_harness_conformance_ci.py tests/unit_tests/test_harness_conformance_checks.py \
  tests/unit_tests/test_rollout_collection.py tests/unit_tests/test_rollout_health.py \
  responses_api_agents/codex_agent/tests responses_api_agents/opencode_agent/tests \
  responses_api_agents/opencode_sandboxed_agent/tests responses_api_agents/pi_agent/tests \
  responses_api_agents/hermes_agent/tests
python scripts/run_harness_conformance.py --harness codex --harness opencode --harness pi --harness hermes --output <NEW_DIRECTORY>
```

Runtime pins: Codex 0.144.4, OpenCode 1.17.11, Pi 0.80.2, Hermes
26bb847a. Source imports were verified against the repair worktree; an
early mixed-source/SDK setup attempt was discarded. The final Codex
suite was rerun after adding malformed-record protection.

Compatibility: correlated local Codex runs temporarily persist a session
and can retry 429 twice; OpenCode shell-status evidence becomes
accurate; terminal-rejection aggregate usage is strict. No dataset,
reward policy, model settings, or benchmark-score claim changes. These
probes qualify local adapter evidence; remote sandbox lifecycle
qualification, Linux-only skipped tests and full repository CI remain
separate. CI classification is **full**, because runner/shared test
paths changed. No CI trust-gate comment was posted.


Follow-up validation (`daab232a8`): Codex returns observations and
timeout state directly instead of encoding synthetic stdout events. All
227 Codex tests passed (45 skipped), all-file pre-commit passed, and all
seven fresh Codex conformance scenarios passed. Retry behavior is
unchanged.

---------

Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: Giulio Lovisotto <[email protected]>
Co-authored-by: Frederic Lafrance <[email protected]>
Co-authored-by: Giulio Lovisotto <[email protected]>

This branch was previously deployed

1 inactive deployment
public — f7ff204f Deployed Oct 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #4854
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 complexity:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants