Repository navigation
Conversation
Add token_id_capture.record_last_output_item. With external staging, each ledger row then records the call's last served output item (CallRecord.last_output_item) in fingerprint mode too, so a framework can run its output detectors on ordinary capture. source_history behavior is unchanged, and the default keeps model text out of ordinary ledgers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Draft
3 of 4 tasks
Main moved the capture code: nemo_gym/token_id_capture is now nemo_gym/models/token_capture, and the capture middleware is now in nemo_gym/models/model_call_capture.py. This merge moves the record_last_output_item wiring into the new middleware file. It keeps main's Dynamo staging check next to the new external_staging check, and updates the two tests to TokenCaptureConfig and CaptureContext.capture_key. Main also added _CAPTURE_PUBLIC_FIELDS, the capture settings that run artifacts show unmasked. record_last_output_item is a boolean control, so it joins that list, and the schema test passes again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
yfw
added a commit
to NVIDIA-NeMo/RL
that referenced
this pull request
Nov 18, 2026
Main gained #4776, which adds a thinking_tags argument to RolloutReassembler and RolloutReassemblerActorConfig for the malformed think-tag reward penalty. This branch added an argument with the same name for the message-level detector, and the auto-merge kept both. Both resolve to env.nemo_gym.thinking_tags or the default, so one argument now serves both checks: setup sets it when the think-tag penalty or a message-level penalty is on. Other conflicts: _spinup_gym keeps main's rollout-recovery arguments, and the single-controller guide keeps main's reflowed text and drops its "remain unsupported with capture" sentence for the new paragraph. Also: - Pin Gym to c3e5931262, NVIDIA-NeMo/Gym#5447 merged with Gym main. It descends from main's pin 9e2e5d0ad0, and Gym's dependencies and version did not change, so uv.lock stays valid. - Every check reads the active algorithm block, so PPO gets the same support. Add a PPO validation test, and name both blocks in the guide. - Shorten three in-function comments to two lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…, as last_output_item For a Chat Completions reply, vllm_model puts the parsed reasoning back into content as <think>...</think>answer, and completion_items keeps Chat text as served. So last_output_item held the think block, and NeMo RL's malformed-thinking detector flagged normal reasoning turns that the echo path does not flag. - detector_items() lifts a Chat reply's think blocks into a reasoning item, as the Chat Completions converter does for the agents. Only the record_last_output_item branch uses it; source_history rows and completion_items are unchanged. - Handler test: a Chat reply with a think block records only the answer (vLLM, Megatron and Dynamo handlers). - Test that token_id_capture.record_last_output_item reaches each call's CaptureContext, for both values. - vllm_model integration test: with the setting on, the Chat and Responses routes record the same last item. - Docs: keep the status sentences together, give the setting its own paragraph, and say that the stored text can include reasoning. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Main now has #5771 (allow_system_suffix), which touches the same lines in secret_utils.py, model_call_capture.py, token_capture/config.py, external_capture.py and sink.py. Both settings are kept. In install_model_call_capture each argument keeps its own closing "),". Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
This branch has not been 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 does this PR do?
This PR adds the setting
token_id_capture.record_last_output_item(defaultfalse). With external staging, each capture ledger row then recordsCallRecord.last_output_iteminfingerprintmode too. The item is the call's last served output item (type, content text and summary text), assource_historyalready records it.NeMo RL needs this item to support its message-level advantage penalties (
grpo.malformed_thinking_advantageandgrpo.invalid_tool_call_advantage) with token capture. On the echo path, RL runs its detector on the last output item of each model call. With capture, the finalizer has only the ledger rows, and ordinary rows do not carry that item today. RL side: NVIDIA-NeMo/RL#5022.The default keeps model text out of ordinary ledgers, as before.
source_historybehavior does not change. The other source-history evidence (output_items,response_status,replay) stays off infingerprintmode.Changes:
nemo_gym/token_id_capture/config.py: the new field, and a check that it requiresexternal_staging: true.nemo_gym/base_responses_api_model.pyandnemo_gym/token_id_capture/sink.py: the capture middleware passes the setting to each call'sCaptureContext.nemo_gym/token_id_capture/external_capture.py: when the context asks for it, the row records the last item fromcompletion_items(served_payload), the same source thatsource_historyuses.fern/versions/latest/pages/model-server/model-call-capture.mdx: one paragraph about the setting.Validation
test_record_last_output_item_persists_only_the_last_item_in_fingerprint_mode(vLLM and Megatron handlers) andtest_record_last_output_item_requires_external_staging. The handler test fails without the change inexternal_capture.py.pytest tests/unit_tests/test_external_capture_handlers.py tests/unit_tests/test_token_id_capture.py tests/unit_tests/test_completion_evidence.py: 285 passed.pre-commit run --files <changed files>: passed.5911d628c(NeMo RL main's Gym pin), so the RL PR can pin this commit alone. It rebases onto Gymmainwithout conflicts.Rollouts
N/A. The change adds one optional ledger field and changes no environment or agent behavior.
End to end: a NeMo RL run with the setting on (Super 3.5 video teacher, token capture, 32 GB200 nodes, 8 uvicorn workers on the policy model server) did 12 training steps with no errors. After 6 steps, all 16,384 ledger rows had
last_output_item. The field was 7.5 MB of the 32.3 MB of row bytes (23%). The median item was 52 bytes. 43 rows ended inside reasoning (finish_reason: length), so their last item is the reasoning item with its summary text. These 43 rows held 2.3 MB of the field's bytes, up to 140,602 bytes in one row.Compatibility and benchmark impact
None for existing configurations, because the default is
false. A framework that sets the field needs a Gym with this change, becauseTokenIdCaptureSettingsforbids unknown keys.Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).🤖 Generated with Claude Code