Repository navigation
fix(token-id-capture): skip instruction content in the conversation d… - #3935
Conversation
|
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. |
|
|
||
| _FINGERPRINT_DOMAIN = b"nemo-gym-lineage" | ||
| _CONTEXT_DOMAIN = b"nemo-gym-lineage-context" | ||
| _INSTRUCTION_ROLES = frozenset({"system", "developer"}) |
There was a problem hiding this comment.
This fixes the Chat Completions shape but not the other two. The Responses instructions field and the Anthropic system field reach the digest through the _ng_request_envelope pseudo-turn built in base_responses_api_model._request_envelope, and that item still hashes the instruction text in full. I traced the hash inputs with the patch applied: a date-only change in the system prompt still produces different digests for both the Responses and Anthropic paths, so the Claude Code agent has the midnight bug today, and the @ai-sdk/openai TODO in opencode_sandboxed_agent/app.py:603 would bring it back for OpenCode the day someone resolves it.
Suggest splitting the envelope into two items, an instructions item with a role that _is_instruction_item recognizes and a tools item that stays fully hashed. That's a local edit since _ENVELOPE_ROLE isn't referenced anywhere else, and the version bump to 3 already covers it. I prototyped this and all three shapes then survive the date change while tool-schema changes, removed instructions, and edited user turns are still rejected. The module docstring's claim that "Chat, Responses, and Anthropic shapes normalize to the same hash input" should hold again after that, whereas right now this change breaks it.
|
/ok to test 5fc5a31 |
5fc5a31 to
fe4709f
Compare
|
/ok to test fe4709f |
@hemildesai, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
…igest OpenCode regenerates its system prompt on every request, and that prompt carries today's date. conversation_digest hashed the system prompt's content, so every rollout that crossed 00:00 UTC failed the parent context check on its next model call and lost its token lineage. In one NeMo RL SWE training step this rejected 453 of 512 rollouts as placeholders. System and developer items now contribute their role and position to the digest but not their content. Every user, assistant and tool turn is still covered. FINGERPRINT_VERSION goes from 2 to 3, so ledger entries hashed the old way are ignored rather than compared against the new digest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Sugam Devare <sdevare@nvidia.com> Signed-off-by: Hemil Desai <hemildesai@users.noreply.github.com>
fe4709f to
3aa2c3e
Compare
|
/ok to test 3aa2c3e |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37671896789 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37700527898 |
Follow-up to #3935, which stopped conversation_digest from hashing system and developer content. That covered the Chat Completions shape only. The Responses `instructions` field and the Anthropic `system` field reach the digest through the `_ng_request_envelope` pseudo-turn, where they were serialized together with the tool schemas and hashed in full. A date-only change in the system prompt therefore still broke the parent link for Responses and Anthropic callers (Claude Code today, OpenCode again once it moves to @ai-sdk/openai). The envelope is now two items. Tools keep a reserved role and are hashed in full. Instructions take the `system` role, so the digest counts their position but not their content, the same rule #3935 applies to Chat system messages. Tools come first so a Responses request yields the same item sequence as the equivalent Chat request, and the two now digest identically. Removed instructions and changed tool schemas are still rejected. Entries hashed the old way are already invalidated by the FINGERPRINT_VERSION bump to 3 in #3935. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com>
OpenCode regenerates its system prompt on every request, and that prompt carries today's date. conversation_digest hashed the system prompt's content, so every rollout that crossed 00:00 UTC failed the parent context check on its next model call and lost its token lineage. In one NeMo RL SWE training step this rejected 453 of 512 rollouts as placeholders.
System and developer items now contribute their role and position to the digest but not their content. Every user, assistant and tool turn is still covered. FINGERPRINT_VERSION goes from 2 to 3, so ledger entries hashed the old way are ignored rather than compared against the new digest.