Repository navigation
Conversation
hemildesai
force-pushed
the
sdd/token-capture-digest-skip-instruction-content
branch
2 times, most recently
from
October 7, 2026 18:49
fe4709f to
3aa2c3e
Compare
Base automatically changed from
sdd/token-capture-digest-skip-instruction-content
to
main
October 7, 2026 23:22
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>
pthombre
force-pushed
the
pthombre/token-capture-envelope-split
branch
from
October 8, 2026 06:11
c6e07a0 to
2ab3aea
Compare
Contributor
|
/ok to test 2ab3aea |
cmunley1
approved these changes
Oct 20, 2026
This was referenced Oct 22, 2026
This branch was previously 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 changed and why
Follow-up to #3935, requested in this review thread. #3935 stopped
conversation_digestfrom hashingsystem/developercontent so a rollout that crosses 00:00 UTC keeps its token lineage when the harness regenerates a dated system prompt. That covered the Chat Completions shape only.The Responses
instructionsfield and the Anthropicsystemfield reach the digest through the_ng_request_envelopepseudo-turn built inbase_responses_api_model._request_envelope. That item serialized the instruction text together with the tool schemas and was hashed in full, so a date-only change in the system prompt still broke the parent link for the Responses and Anthropic paths. Claude Code (Anthropicsystem) has the midnight bug today, and OpenCode would get it back the day the@ai-sdk/openaiTODO inopencode_sandboxed_agent/app.pyis resolved.This PR splits the envelope into two items:
_ng_request_tools) that is still hashed in full, andsystemrole, which_is_instruction_itemrecognizes, so the digest counts its position but not its content.Tools come first so a Responses request yields the same item sequence as the equivalent Chat request; the two now digest identically, which restores the module docstring's claim that the three dialects normalize to the same hash input. Removed instructions and changed tool schemas are still rejected.
No further
FINGERPRINT_VERSIONbump: the bump to 3 in #3935 already invalidates entries hashed the old way; this PR is rebased ontomainnow that #3935 has merged. A mismatch during any deploy window only yields an unresolved parent, never a wrong one.Behavior change called out:
test_served_calls_do_not_link_across_a_changed_system_promptencoded the pre-#3935 rule that a changed Anthropic system prompt must not link. That rule is what #3935 reversed, so the test is rewritten astest_served_calls_link_across_a_regenerated_system_prompt: a regenerated prompt links, a removed prompt does not.Issue
No tracking issue. #3935 was opened directly from the NeMo RL training failure described in its body (453 of 512 rollouts rejected as placeholders after midnight UTC). This PR completes that fix for the remaining two request dialects.
Validation
Reproduced the gap before the change and confirmed the fix with a script that runs a date-only system prompt change through
_request_messages+conversation_digestfor each dialect:systemmessage)instructions)systemviaanthropic_request_to_responses)Tests run against the final diff:
pre-commit runcould not fetch hook repositories from my sandbox (proxy blocked the clone); the ruff, trailing-whitespace, and end-of-file checks it would run were run directly. DCO sign-off is on the commit.New test
test_the_parent_link_survives_a_date_change_in_every_dialects_instructionsfails on the #3935 branch for the Responses and Anthropic shapes and passes with this PR.Rollout evidence
N/A. This changes the lineage digest's hash inputs for the model server's capture path only; it does not alter agent, verifier, or model behavior. The unit tests above exercise the served
/v1/messagesand/v1/chat/completionspaths through a realSimpleResponsesAPIModelwith capture enabled.🤖 Generated with Claude Code