Repository navigation
fix(nemo-gym): keep unserved-call ledger reasons off the receipt poison list - #4749
Conversation
…'s poison list `_assemble_receipt` treated one ledger failure reason as off-chain: a call that finished without staged coordinates never served a completion and can never be a lineage parent. NeMo Gym adds a second reason of the same kind, an engine refusal recorded before generation (NVIDIA-NeMo/Gym#3980), and names both in `nemo_gym.token_id_capture.UNSERVED_CALL_FAILURE_REASONS`. The receipt builder now reads that set and keeps every reason in it off the poison list, with a pin-agnostic fallback to the uncommitted-call reason for a Gym that predates the set. The missing-terminal-row check is unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test 115145c |
|
cc @ananthsub: this is the pin-agnostic NeMo RL change you asked for on NVIDIA-NeMo/Gym#3980 (the |
…taging (NVIDIA-NeMo#4366) > **Stacked PR.** This branch is built on NVIDIA-NeMo#3973 (the finish reason and the incomplete terminal), whose `response_finish_reason` and verdict table it reuses. NVIDIA-NeMo#3973 merged on 2026-10-15 as d5b2892 and `main` is merged in since (3bc2a33), so the diff is this pull request's own changes; the commit list still shows NVIDIA-NeMo#3973's commits (9c8bdf2, ec2f7c3, 744e198, 78b05e8), whose content is on `main` now. Review the three commits that are this branch's: `feat(token-capture): carry the finish reason through worker-custody staging`, `fix(token-capture): withhold the staged rebuild's truncation verdict when the finish reason is unresolved` (the 2026-10-13 review follow-up), and `feat(token-capture): apply the capture's truncation verdict through one shared rule` (ananthsub's review of 2026-10-15). A merge of `main` 3d2e970 sits between them: the generation-cut staging series added fields next to this branch's in `lineage.py`, `staging/records.py` and `staging/rebuild.py`, and both sides are kept. It is independent of NVIDIA-NeMo#3980, which edits neighboring lines of `builder.py`; whichever of the two lands second merges `main` once more. ## What does this PR do? NVIDIA-NeMo#3973 records each locally captured call's finish reason and marks a rebuilt response whose terminal call stopped for `length` or `content_filter` as `incomplete`. Under worker custody, where a framework's inference worker keeps the tokens and the model server records a token-free ledger row per call, no finish reason was recorded, so a rollout rebuilt from staged records reported no truncation verdict: a trainer's truncation rule saw every such rollout as complete. 1. **The ledger row carries the finish reason.** `CallRecord` (`nemo_gym/token_id_capture/staging/records.py`) gains `finish_reason: str | None` in the Chat Completions vocabulary (`stop`, `length`, `tool_calls`, `content_filter`). It is a metadata column like `response_id` and `admitted_at`, outside the staged digest, so no digest or schema version changes; a row written before the column reads `None`. Like every column of these wire models, it binds the model server and the framework to one Gym version: the manifest route serializes it on every row and `CallRecord` forbids unknown fields, so a framework whose Gym predates the column rejects every manifest row as `invalid_manifest_row` and masks the rollout, as `capture_key` (NVIDIA-NeMo#3884) already does. Run the same Gym on both sides. 2. **The external capture handler stamps it.** `_finalize_admitted_response` (`nemo_gym/token_id_capture/external_capture.py`) reads it from the served payload with `response_finish_reason`, which now also understands the Anthropic Messages shape (`stop_reason`, the inverse of the table the Anthropic converter applies when it serves a Responses payload as a Messages response), so the chat, Responses, and Messages dialects record the same reason. 3. **Both ledgers round-trip it.** `_custody_columns` and `_manifest_from_rows` (`nemo_gym/token_id_capture/lineage.py`) store and rebuild the column for the file-backed and the in-memory ledger; a re-commit with a different finish reason is a conflict like any other metadata field. 4. **The rebuild reports the terminal call's reason.** `LinearizedRow` (`nemo_gym/token_id_capture/staging/rebuild.py`) gains `terminal_finish_reason` and the property `incomplete_reason`, which applies NVIDIA-NeMo#3973's table through `incomplete_reason_for_finish_reason`, now a shared function in `records.py` that the local-path builder uses too. Only the terminal call decides: an earlier `length` stop did not end the chain, because a later call extended it. The rebuild also keeps NVIDIA-NeMo#3973's abstention: when the receipt's `terminal_attribution_reason` carries `finish_reason_disagreement` (attribution named one of several token-identical calls that recorded different finish reasons, by call-id order alone), `LinearizedRow.finish_reason_resolved` is `False` and `incomplete_reason` is `None`, so the verdict cannot flip with the call id the receipt names; the token is the shared constant `FINISH_REASON_DISAGREEMENT_REASON` in `records.py`, which `resolve_terminal` emits. A framework's receipt consumer puts the property on the sample's response with `apply_capture_incomplete_verdict` (`records.py`, exported from `nemo_gym.token_id_capture`), the one precedence rule both capture placements apply: a response that reported `completed` or no status takes the verdict, and a harness that reported `incomplete` or `failed` itself keeps its own, exactly as `finalize_rollout_token_capture` does on the local path, which now calls the same helper. The NeMo RL consumer is not open yet: it comes with the Gym pin bump that follows this merge, because NeMo RL can only exercise `incomplete_reason` once its pinned Gym has the column. The receipt-builder half, the switch to `UNSERVED_CALL_FAILURE_REASONS` from NVIDIA-NeMo#3980, is NVIDIA-NeMo/RL#4749 and is pin-agnostic. ## Review follow-up (2026-10-13) yaoyu-33's question on `staging/rebuild.py`: with content-attributed, token-identical calls whose finish reasons differ, swapping the call ids changed `incomplete_reason` although the receipt reported `finish_reason_disagreement`. The rebuild now withholds the verdict in that case, as NVIDIA-NeMo#3973's projection does. The branch also carries a merge of `main` 3d2e970. ## Review follow-up (2026-10-15) ananthsub's two items (4c6c6b3): the precedence rule that keeps a harness's own verdict moved into `apply_capture_incomplete_verdict`, which `finalize_rollout_token_capture` calls on the local path and a framework consumer calls on `LinearizedRow.incomplete_reason` (its docstring points there), with tests for a response that reported no status, `completed`, `incomplete` for its own reason, and `failed`; and the version coupling of the staging wire models is stated on the `finish_reason` column, in the model-call capture docs, and in point 1. After NVIDIA-NeMo#3973's squash, `main` was merged in as 3bc2a33 (no rebase, so the review history stands); the files both sides touched keep this branch's version, which equals NVIDIA-NeMo#3973's final tree plus this branch's lines, and NVIDIA-NeMo#3973's last test, `test_finalize_keeps_a_harness_verdict_that_is_already_incomplete`, sits next to this branch's `apply_capture_incomplete_verdict` tests. Validation of the merge head 3bc2a33: the unit suite (`test_collect_downstream_junit.py` excluded) gave 9160 passed, 56 skipped, 29 failed, 20 errors; 48 of the failures and errors are the environmental set of `main` (telemetry and opensandbox tests that need packages this machine lacks) and the remaining one, a docker-compose shell test, passes on rerun here and on `main`; every `responses_api_models/*/tests` suite passed (vllm_model 534 passed), with genrm_model and local_vllm_model erroring at collection as before. Gate on 4c6c6b3: the unit suite (8754 passed, 56 skipped; the 28 failures and 20 errors are identical to the `main` 4518db9 baseline, telemetry and opensandbox tests that need packages this machine lacks) and every `responses_api_models/<server>/tests` session (`vllm_model` 492 passed; genrm and local_vllm collect errors for missing local packages, as on `main`); the token-capture and staging unit files together: 561 passed. ## Issue No issue filed; found while training with NeMo RL's worker-custody capture under a token budget, where every rollout rebuilt from staged records counted as complete. ## Validation - New tests: `response_finish_reason` for the Anthropic Messages shape (five stop reasons); the ledger row round-trips `finish_reason` on both ledgers, a row without the column reads `None`, and a re-commit with a different reason conflicts; the external capture handler records `length` for every dialect (chat completions, Responses, Messages, compaction) and `stop` on the existing route tests; `verify_and_linearize` reports the terminal row's reason and `incomplete_reason` for `stop`, `length`, `content_filter`, and an unstated reason; with two token-identical rows recording `length` and `stop`, the `finish_reason_disagreement` token withholds the verdict whichever row the receipt names while the recorded reason stays reported, a trail without the token keeps the verdict, and a receipt without a trail resolves as before. - `tests/unit_tests/test_token_id_capture.py`, `test_token_capture_ledger.py`, `test_token_capture_staging_rebuild.py`, `test_token_capture_staging_core.py`, `test_trajectory_builder.py`, `test_terminal_attribution.py`: 401 passed. `responses_api_models/vllm_model/tests`: 409 passed. - Unit suite (`pytest tests/unit_tests`, with `test_collect_downstream_junit.py` excluded for a missing local package), run on the branch tip 0067fd0 after the merge of `main` 3d2e970: 8463 passed, 56 skipped, 28 failed, 19 errors. The failures and errors are the same 47 as on `main` 3d2e970 (telemetry and opensandbox tests that need packages this machine lacks). Each `responses_api_models/<server>/tests` directory as its own session matches `main` apart from the new tests (`vllm_model` 418 passed). - `ruff check` and `ruff format --check` on the changed files: clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: alexandery <[email protected]> Signed-off-by: Lin Jia <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Lin Jia <[email protected]>
…served-call-reasons
…wn reason names The receipt builder reads the ledger reasons of a call that served no completion from Gym's UNSERVED_CALL_FAILURE_REASONS, and applies the uncommitted-call reason alone when Gym exports no set. The comment and the docstring on that fallback now state the mechanism without a change reference. The test of the off-chain reasons builds its failure rows from Gym's UNCOMMITTED_CALL_REASON, and from ENGINE_REFUSED_CALL_REASON when the pinned Gym exports that name, instead of hand-written strings, so a change in Gym's spelling of a reason is what the test measures. The test of the fallback states what a Gym without the set exports. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
Pushed a merge of main plus one commit: the fallback that applies the uncommitted-call reason alone when Gym exports no set stays (the pinned Gym exports only that reason) and its comment states the mechanism without a change reference; the receipt test builds its rows from Gym's own reason names instead of hand-written strings, so a change in Gym's spelling is what the test measures. Tests: test_nemo_gym_token_capture.py 31 passing locally in the Gym lane. |
|
/ok to test 6215a23 |
Brings in the raised nightly GPU-hour cap (#4802) so L0_Unit_Tests_Other passes; no change of this branch's own code. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test 58b8bcc |
linj-glitch
left a comment
There was a problem hiding this comment.
Reviewed at 58b8bcc. No blocking correctness or logic issues found. The unserved-reason compatibility fallback preserves the missing-terminal and served-call failure safeguards.
Validation: 31 token-capture tests passed against the pinned Gym source. Required CI checks passed on this head.
Bring the branch up to date with main. The merge has one conflict, in the docstring of NemoGym._assemble_receipt. Main added the cancelled call as an example of a call that finished without staged coordinates. The resolution keeps the branch's paragraph and carries that example into it. After the merge, the test test_receipt_assembly_keeps_the_uncommitted_rule_on_a_gym_without_the_set fails. The Gym commit that main pins serves UNSERVED_CALL_FAILURE_REASONS through the lazy exports of its token-capture package, so the test can no longer remove the set. The next commit removes the fallback and that test. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
…uilder NemoGym._assemble_receipt read Gym's UNSERVED_CALL_FAILURE_REASONS through getattr and fell back to the uncommitted-call reason alone for a Gym that exports no set. The Gym commit that main pins exports the set, so the fallback has no case left. It can also no longer be tested: that Gym serves the name through the lazy exports of its token-capture package, so a test cannot remove it, and test_receipt_assembly_keeps_the_uncommitted_rule_on_a_gym_without_the_set fails after the merge of main. _assemble_receipt now imports the set and exempts every reason in it. The fallback, its comment and its test are removed, and the docstring no longer describes a Gym without the set. test_receipt_assembly_ignores_every_unserved_call_reason_gym_names no longer installs the set with monkeypatch. It puts one failure row per reason of Gym's set beside a complete chain and expects an unpoisoned receipt. It also asserts that engine_refused_request is a member of the set, so that the refusal stays under test if Gym changes the set. The test fails without the change to nemo_gym.py. docs/design-docs/token-capture-ledger.md said that any failure row poisons the receipt. It now names the exemption. Gym's vLLM Model Server writes engine_refused_request only when it passes the refusal on to the agent, which its setting propagate_context_overflow_errors turns on (VLLMModel._propagate_context_refusal; the default is false), and only when the parent resolution is not source_history, which NeMo RL sets for forest training. With the default, the Model Server answers the refused call with an empty completion, and the row of the call carries request_finished_without_staged_coordinates, which was already exempt. The fix therefore changes a run that turns the setting on. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Two commits follow the approved head
Against 🤖 Generated with Claude Code |
|
/ok to test 152bdfd |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
Review: PR #4749
Approval recommended. No actionable findings in the three changed files at 152bdfd65e6bab9db8703a9d6311c9c15d626013 against e4af41d82f5a99d2e8bd9b263a02f12576fea070.
The receipt filter now uses Gym's pinned unserved-call classification. Missing terminals, pending writes and non-exempt failures still mask the receipt. Defaults and the separate forest policy are unchanged. The updated explanation matches those boundaries.
Validation
Local CPU validation used the default-branch CI image, 766267172432.dkr.ecr.us-east-1.amazonaws.com/rl:45199750919. Its Gym commit matched the unchanged pin.
- An unmodified scratch copy of the token-capture test file ran against the actual head module: 57 passed, also when repeated with the repository's exact Gym selection hooks. Ray-cluster and result-writing session hooks were omitted, so this was not a full local L0 launch. The new regression against base produced 1 expected failure at the
capture_poisonedassertion. test_receipt_edges.pypassed 22 focused cases. Base/head probes, includingreceipt_probe.py, used real Gym parsers to exercise mixed failures, missing terminals, malformed rows and omitted/null/empty defaults.full_path_probe.pypassed three real postprocessing paths with only the manifest fetch mocked. A full module import with optional Gym blocked also passed. The real upstream option branch was exercised with stubbed services, not a live model server.- Full-tree pinned Ruff checks, import ordering and formatting passed.
pyrefly checkreported 0 errors, with 142 suppressed and 385 warnings not shown. Fullpre-commit run --all-filesfailed during hook setup because fetching another repository was prohibited. The narrower passes do not count as an all-hooks pass.
For this head, CI passed Lint check, L0_Unit_Tests_Nemo_Gym, L0_Unit_Tests_Vllm_Nemo_Gym and fast_L1_Functional_Tests_Gym. The review relies on those results. The Gym job explicitly passed the new regression and reported 1354 passed, 45 skipped, 2 deselected. The separate Self-review status still fails with “No self-review”. Approval here does not mean all checks are green or the PR is merge-ready.
No local GPU, model-server, staged-token end-to-end or training/convergence validation was performed.
Review coverage
Five Wave 1 specialists covered code, tests, bugs, design and prior discussion. Independent discovery and the subsequent adversarial challenge pass found no surviving issue. Those two passes used separate children because this runtime cannot resume a completed child. The comment editor completed the final wording: eight children total, comprising five specialists, two adversarial reviewers and one editor. The design reviewer used the skill's explicit no-design-change scope rule. No thread replies are needed.
Pre-POST audit
| Item | Result |
|---|---|
| Inline comments and anchors | OK: none |
| Body wording and comment references | OK |
| Editor links and suggestions | OK: unchanged |
| Admitted revisions and clean trees | OK |
nemo-rl-review: kind=expert harness=unknown/unknown model=unknown effort=unknown review-pr-team=v3 reviewed=152bdfd
Review generated by codex. This was a full review. Request a full review with /review reset=true.
alexandery-nvidia
left a comment
There was a problem hiding this comment.
This is a self-review of head commit 152bdfd. The change is correct: the review team found no correctness bug. Two low-severity comments follow, and each one carries a suggested change.
What this PR does well. _assemble_receipt now exempts every reason in the set that Gym declares beside the reasons themselves (records.py:78-83). At the base, it compared each failure row with one Gym constant (base nemo_gym.py:2411). A new Gym reason of the same kind therefore needs no change in NeMo RL. The new test builds one failure row for each member of the set, so it covers such a reason too. The import has no fallback. So a Gym that stops exporting the set fails with an import error, instead of silently poisoning receipts and masking their rollouts.
Context — no action. Since #4124 moved the Gym pin past NVIDIA-NeMo/Gym#3980 on 2026-10-30 (431c2ff14a), the main branch has pinned a Gym that writes engine_refused_request. On the main branch, the line that decides which failure rows poison a receipt still exempts only request_finished_without_staged_coordinates (base nemo_gym.py:2411). So on the main branch, a run outside forest training that sets propagate_context_overflow_errors: true on the policy's Model Server masks every rollout that has such a row. No config in NeMo RL's tree outside the Gym submodule sets the option, but Gym's own Super 3.5 SWE-bench recipes do (swebench-verified.yaml:50). This PR fixes that regression.
What the team ran.
- The PR's test file passed at the head (57 tests). With the base version of
nemo_gym.py, 56 tests passed and the new test failed. - The team made four one-line changes to the receipt rules: exempt every reason, exempt only
engine_refused_request, restore the base rule, and remove the check that poisons a receipt when no terminal row is found. Each change makes at least one test fail. - The team ran a served call and then a refused call through Gym's own test harness for worker custody, in which the inference worker stages the tokens (
test_external_capture_streaming.py:460). Withpropagate_context_overflow_errors: true, the manifest from Gym's capture ledger gives a poisoned receipt at the base and an unpoisoned receipt at the head. - All pre-commit hooks passed on all files. CI passed every job except the Self-review check, which waits for this review.
Comments.
- (C1) The new
_assemble_receiptdocstring puts the context-window example under the wrong reason for the default setting outside forest training. - (C2) The new test copies Gym's reason string instead of importing
ENGINE_REFUSED_CALL_REASON.
nemo-rl-review: kind=self harness=claude-code/2.1.331 model=claude-opus-5-5 effort=max review-pr-team=v3 reviewed=152bdfd
…tring The docstring of NemoGym._assemble_receipt tied a context-window overflow to the engine's refusal alone, although Gym records that overflow as request_finished_without_staged_coordinates when its Model Server answers with an empty completion of its own. The paragraph now describes each reason of Gym's UNSERVED_CALL_FAILURE_REASONS by what happened to the request, and it gives the overflow as an example of request_finished_without_staged_coordinates. It also corrects three phrases: the description applies to a call that has no other failure row, such a call returned no completion that the engine generated, and it cannot be a lineage parent because it has no committed ledger row or because the agent never received its completion. Only the docstring changes. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
test_receipt_assembly_ignores_every_unserved_call_reason_gym_names checked that the hand-copied string "engine_refused_request" is a member of Gym's UNSERVED_CALL_FAILURE_REASONS. Gym exports that value as ENGINE_REFUSED_CALL_REASON from the same package, so a change of the string's value alone would have failed the test although nothing was broken. The test now imports the name and asserts with it. It still fails when Gym's set lacks the refusal. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
/ok to test 45e558d |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
Follow-up review
Approval recommended for this scoped follow-up. No new actionable issue was found in the two commits since the previous review at 152bdfd65e6bab9db8703a9d6311c9c15d626013.
The docstring correction and owner-constant import complete both self-review requests. Production executable logic is unchanged since that review. This is not a new full review.
Validation
CPU checks used the default-branch CI image, 766267172432.dkr.ecr.us-east-1.amazonaws.com/rl:45199750919, because this head has no successful image build. Its Gym source matches the unchanged pin.
- 57 tests passed from the current token-capture file against the actual head module and real Gym. The scratch runner kept the selection hooks but omitted autouse Ray/GPU fixtures and session, asset and result-writing hooks. This was not a full L0 or Ray integration job.
- Export/set mutations passed for a consistent rename and an added reason; missing-member and missing-export mutations failed as expected. The current regression failed against base at the expected receipt assertion. Receipt and postprocessing probes kept mixed failures, missing terminals and pending writes masked. Upstream default/explicit-option probes used service stubs, not a live model server.
- All three pinned Ruff 0.9.9 checks passed.
pyrefly checkreported 0 errors, with 142 suppressed and 385 warnings not shown.pre-commit run --all-filesfailed during hook setup because it requires fetching an unadmitted repository. The fallback results are not an all-hooks pass. - Default-lane collection without Gym selected zero tests and exited 5. This was a collection check, not a pass.
Current-head Lint check passed. CI is waiting for test approval. Self-review status fails because both threads are still open despite the completed source fixes. No current-head CI test pass or merge-ready status is claimed.
No local GPU, live model-server, staged-token end-to-end or training/convergence validation ran.
Review coverage
Five specialist roles, independent discovery, adversarial challenges and comment editing completed: eight children total. Discovery and challenges used separate children because this runtime cannot resume a completed child. No actionable finding or thread reply survived.
Pre-POST audit
| Item | Result |
|---|---|
| Inline comments and anchors | OK: none |
| Body wording and comment references | OK |
| Editor links and suggestions | OK: unchanged |
| Admitted revisions and clean trees | OK |
nemo-rl-review: kind=expert harness=unknown/unknown model=unknown effort=unknown review-pr-team=v3 reviewed=45e558d
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
aroshanghias-nvd
left a comment
There was a problem hiding this comment.
LGTM. The receipt now uses Gym’s unserved-call reasons while preserving missing-terminal, capture-failure and pending-write safeguards. Defaults and forest behavior remain unchanged.
Validation: all 57 tests in test_nemo_gym_token_capture.py passed locally on CPU, with no exclusions. Supplemental boundary and Gym HTTP checks passed with deterministic workers. No GPU training was run.
nemo-rl-review: kind=expert harness=codex/0.171.0-alpha.13 model=gpt-6-astra effort=high review-pr-team=v2 reviewed=45e558d
aroshanghias-nvd
left a comment
There was a problem hiding this comment.
LGTM. Both review points are resolved, and the head is unchanged from our reviewed version. All 57 focused CPU tests passed; current CI has no failures. No GPU training was run.
nemo-rl-review: kind=expert harness=codex/0.171.0-alpha.13 model=gpt-6-astra effort=high review-pr-team=v2 reviewed=45e558d
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main. The PR is 53 commits behind, and the branch freshness check allows at most 10.
Thanks for clarifying how Gym records refused requests and using its exported refusal reason in the regression test.
Scope: Fixes from 26bee9d through 45e558d and the receipt handling they describe.
Checked:
- Receipt assembly keeps a captured chain when only unserved calls failed. A missing terminal record, a different failure reason, or a pending write still masks the rollout.
- The regression test checks every reason Gym marks as unserved and confirms that the receipt retains the expected terminal call. It passed in the Gym unit-test job at 45e558d.
LGTM — no remaining findings from this re-review.
nemo-rl-review: kind=expert harness=codex/0.173.0 model=gpt-6.2-astra effort=medium review-pr-team=v3 reviewed=45e558d
|
/ok to test 571e445 |
What and why
Problem. With token capture,
NemoGym._assemble_receipt(nemo_rl/environments/nemo_gym.py:2297) builds the receipt of a rollout from the manifest of Gym's capture ledger. A failure row in the manifest marks the receipt as poisoned, and a poisoned rollout becomes a masked row. One failure reason was exempt:request_finished_without_staged_coordinates, which Gym writes for a call that finished without worker commit coordinates. Such a call has no committed ledger row, or the agent never received its completion, so no later call can name it as its parent, and the chain of the calls before it stays complete.Gym has a second reason of the same kind,
engine_refused_request. It marks a call that the inference engine refused before it generated, for example because the prompt no longer fits the context window. Gym names both reasons inUNSERVED_CALL_FAILURE_REASONS(nemo_gym/models/token_capture/records.py:72-83). The receipt builder compared with the first reason alone. A refused call therefore poisoned the receipt, although every call before it had been captured.When Gym writes
engine_refused_request. Gym's vLLM Model Server writes it inVLLMModel._propagate_context_refusal(responses_api_models/vllm_model/app.py:926-947), under two conditions.propagate_context_overflow_errorsis true, so that it passes the refusal on to the agent. The default is false (app.py:556).source_history. NeMo RL setssource_historyfor forest training andfingerprintotherwise (nemo_gym.py:1424-1426).With the default, the Model Server answers the refused call with an empty completion whose
finish_reasonislength(app.py:2017-2032). Gym then records the call underrequest_finished_without_staged_coordinates(_fail_uncommitted_external_call,nemo_gym/models/model_call_capture.py:717), which was already exempt. The fix therefore changes only a run that setspropagate_context_overflow_errors: trueon the policy's Model Server. The Gym lines are those of the Gym commit thatmainpins.Change.
_assemble_receiptimports Gym'sUNSERVED_CALL_FAILURE_REASONSand exempts every reason in it (nemo_gym.py:2363,:2415). Its docstring describes both kinds of call. The Gym commit thatmainpins exports the set, so the code has no fallback for a Gym without it.docs/design-docs/token-capture-ledger.md:116said that any failure row poisons the receipt. It now names the exemption.test_receipt_assembly_ignores_every_unserved_call_reason_gym_names(tests/unit/environments/test_nemo_gym_token_capture.py:404) puts one failure row per reason of Gym's set beside a complete chain of two calls and expects an unpoisoned receipt. It also asserts thatengine_refused_requestis a member of the set (:416), so that the refusal stays under test if Gym changes the set.Unchanged. A rollout whose terminal call has no ledger row is still masked as
missing_terminal_row. Every other failure reason still poisons the receipt. A receipt with pending call ids is still masked by_mask_undrained_receipt(nemo_gym.py:765). The check of forest training in_postprocess_captured_history(nemo_gym.py:2186) is not touched. It admits a failure row only when the failed call also has a committed record, and a refused call has none.Issues
None.
Convergence / perf / functionality proof
No training run was made. With the default
propagate_context_overflow_errors: falseno receipt changes, because Gym does not writeengine_refused_request. The proof of the function is the unit test. It ran on this branch in an environment built frommain'suv.lock, which this branch does not change, with the Gym submodule at the commit thatmainpins, and without a GPU.pytest tests/unit/environments/test_nemo_gym_token_capture.py --nemo-gym-only, with-xdropped from the configured options: 57 passed.nemo_gym.pyreversed: 56 passed and 1 failed. The failure is the test named above, onassert receipt["capture_poisoned"] is False.ruff check,ruff check --select Iandruff format --checkon the two Python files: passed.pyrefly check: 0 errors.Needs upstream changes
None. The Gym commit that
mainpins definesUNSERVED_CALL_FAILURE_REASONSandengine_refused_request.PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.🤖 Generated with Claude Code