Repository navigation
fix(responses): validate token metadata as a bundle - #2488
Merged
Merged
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. |
ananthsub
force-pushed
the
ananthsub/fix-responses-token-metadata
branch
from
August 11, 2026 22:15
d0529c6 to
2007c90
Compare
ananthsub
marked this pull request as ready for review
August 11, 2026 22:55
bxyu-nvidia
approved these changes
Aug 11, 2026
Validate token IDs and log probabilities as one payload. Preserve empty arrays and clear metadata after each assistant turn. Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub
force-pushed
the
ananthsub/fix-responses-token-metadata
branch
from
August 11, 2026 23:01
2007c90 to
2298268
Compare
cmunley1
reviewed
Aug 11, 2026
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.
Summary
Responses training metadata consists of
prompt_token_ids,generation_token_ids, andgeneration_log_probs. Partial payloads can currently match a plain union member. Emptyprompt_token_idsare also mistaken for missing metadata.The schema now validates these fields as one bundle. Empty arrays remain valid, while partial or malformed bundles fail validation.
ResponsesConverterState.flush_assistant()clears the bundle after every assistant turn so metadata cannot leak into the next turn.routed_expertsremains optional.flowchart LR ITEM["Assistant item"] --> CHECK{"Any token field present?"} CHECK -->|"No"| PLAIN["Plain assistant message"] CHECK -->|"Yes"| COMPLETE{"Required bundle complete?"} COMPLETE -->|"No"| ERROR["Reject payload"] COMPLETE -->|"Yes"| TRAIN["Training assistant message"] PLAIN --> FLUSH["Flush assistant turn"] TRAIN --> FLUSH FLUSH --> RESET["Clear token metadata"]