feat(core): store turn_id on ResponseItem metadata#28360
Merged
Conversation
1537199 to
e5daf04
Compare
b4ee3c1 to
3e26c3d
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 15, 2026
## Description This PR adds an optional `metadata` field to `ResponseItem` for Responses API calls. Only mechanical plumbing, no actual values populated and sent yet. Turns out just adding a new field to `ResponseItem` has quite a large blast radius already. This change is backwards compatible because `metadata` is optional and omitted when absent, so existing response items and rollout history without it still deserialize and requests that do not set it keep the same wire shape. For provider compatibility, we strip out `metadata` before non-OpenAI Responses requests so Azure and AWS Bedrock never see this field. My followup PR here will actually make use of it to start storing and passing along `turn_id`: #28360 ## What changed - Added `ResponseItemMetadata` with optional `turn_id`, plus optional `metadata` on Responses API item variants and inter-agent communication. - Preserved item metadata through response-item rewrites such as truncation, missing tool-output synthesis, compaction history rebuilding, visible-history conversion, rollout/resume, and generated app-server schemas/types. - Strip item metadata from non-OpenAI Responses requests while preserving it for OpenAI-shaped requests. - Updated the mechanical fixture/test construction churn required by the new optional field.
9b81c0f to
0b66f2b
Compare
pakrym-oai
reviewed
Jun 15, 2026
pakrym-oai
reviewed
Jun 15, 2026
pakrym-oai
reviewed
Jun 15, 2026
pakrym-oai
reviewed
Jun 15, 2026
fe3d386 to
65e1264
Compare
bede56a to
3fc4d86
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
e02b55c to
b89b047
Compare
b89b047 to
33ba9c8
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
d021e1d to
cbf9aee
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
cbf9aee to
1b7c621
Compare
pakrym-oai
reviewed
Jun 22, 2026
pakrym-oai
reviewed
Jun 22, 2026
| } | ||
|
|
||
| /// Returns the decoded request body without internal item transport metadata. | ||
| pub fn body_json(&self) -> Value { |
Collaborator
There was a problem hiding this comment.
the fact that we are messing with request might be unexpected.
Collaborator
Author
There was a problem hiding this comment.
Changed body_json() back to the raw decoded request body and removed the request-body normalization.
pakrym-oai
reviewed
Jun 22, 2026
| { | ||
| items.push(guardian_developer_message); | ||
| } | ||
| // Some callers insert initial context into prompt/replacement history without first |
Collaborator
Author
There was a problem hiding this comment.
New context windows and compaction; tightened the comment.
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
1b7c621 to
3560732
Compare
pakrym-oai
reviewed
Jun 22, 2026
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
3560732 to
b1275cf
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
b1275cf to
b0201bd
Compare
pakrym-oai
approved these changes
Jun 22, 2026
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
b0201bd to
54adfac
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 22, 2026
54adfac to
616a5f3
Compare
616a5f3 to
8bf4791
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This PR is a followup to #28355 and starts assigning
internal_chat_message_metadata_passthrough.turn_idto durable Responses API items created during a turn.The goal is that those items keep the
turn_idthat introduced them when Codex resends stateless HTTP context, reconstructs history for resume/fork paths, or reuses websocket response state.What changed
internal_chat_message_metadata_passthrough.turn_idwhen missing as response items enter durable history, initial/replacement history, inter-agent communication history, and local compaction summaries.compaction_triggerfieldless because it is a request control, not a durable response item.