Skip to content

fix(conformance): accept valid token health after model rejection - #4286

Closed
giuliolovisotto wants to merge 1 commit into
mainfrom
codex/terminal-error-health-expectations
Closed

giuliolovisotto wants to merge 1 commit into
mainfrom
codex/terminal-error-health-expectations

Conversation

@giuliolovisotto

@giuliolovisotto giuliolovisotto commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

The terminal HTTP 400 conformance scenario fails Pi because it requires token reconciliation to be unobserved, although Pi reports zero aggregate usage and Gym correctly reconciles the failed, nongenerating attempt as healthy after #4229. Hermes leaves aggregate usage unavailable, so the same scenario correctly returns unobserved there.

Allow a scenario health expectation to explicitly name multiple acceptable verdicts. Only model_error's token-reconciliation expectation uses this: healthy or unobserved. A wrong nonzero aggregate still fails, missing health results still fail, and the scenario still requires rollout_ended_on_failed_model_call to be unhealthy. Other scenarios retain their exact expectations. Gym's health engine and verdicts are unchanged.

Related: #4229, #4168 and FEA-458. Independent of the model-server error-body fix.

Validation on this branch:

  • 298 passed, 2 skipped across the checker and runner tests. The real health-engine regression covers unavailable aggregate usage, valid zero usage, and incorrect nonzero usage; invalid/empty expectation alternatives are rejected.
  • Full pre-commit run --all-files and git diff --check passed; DCO-signed.
python -m pytest -o addopts= --import-mode=importlib -q \
  tests/unit_tests/harness_capabilities scripts/harness_conformance/tests

Combined conformance rerun

Fresh local validation on main 2fc5407f4 + #4251 + #4048 + #4285 + #4286 (combined commit 3bf248ab523877e368a2615bb39abba58ac9d5ca): Pi 7/7, Hermes 7/7, suite exit 0. All schema, semantic, behavioral and health expectations pass. The CI-equivalent union of runner/checker/Pi/Hermes adapter tests passed 794 tests, 33 skipped, with no failures. These are local-adapter controlled scenarios, not sandboxed benchmark qualification or a claim that remote CI has passed.

python scripts/run_harness_conformance.py --harness pi --harness hermes --output <NEW_OUTPUT_DIRECTORY>
python -m pytest -o addopts= --import-mode=importlib -q \
  scripts/harness_conformance/tests tests/unit_tests/harness_capabilities \
  responses_api_agents/pi_agent/tests responses_api_agents/hermes_agent/tests

@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 area:ci CI workflows, test routing, and repository automation bug Something isn't working labels Oct 9, 2026
@giuliolovisotto

Copy link
Copy Markdown
Contributor Author

Closing this proposal: accepting either healthy or unobserved for the same HTTP-400 scenario hides differences in the evidence harnesses retain. It is not the right conformance contract; the scenario should have one expected outcome.

The replacement work is tracked in:

  • FEA-460: define the shared failed-call evidence rule and retain captured calls on failure records.
  • FEA-461: align the conformance scenario and P0 harness implementations with that rule, after FEA-460 is ready.

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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI workflows, test routing, and repository automation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant