Consolidate Responses API Codex metadata#27122
Draft
owenlin0 wants to merge 7 commits into
Draft
Conversation
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.
Why
Responses API request instrumentation is the source of truth for downstream Codex analytics that join requests by Codex IDs such as session, thread, turn, and context window. Before this change, those values were assembled through several request-specific paths: HTTP request bodies, websocket handshake headers, websocket
response.createpayloads, compaction requests, and the richx-codex-turn-metadataenvelope all had their own wiring.That made metadata propagation easy to drift across API-key/direct Responses API requests, ChatGPT-auth/proxied requests, websocket requests, and compaction requests. It also made additions like
window_iderror-prone because a field could be added to one transport projection but missed in another.What changed
CodexResponsesMetadataas the core-owned snapshot for Codex metadata sent to ResponsesAPI.client_metadata["x-codex-turn-metadata"], flatclient_metadataprojections, and direct compatibility headers from that same snapshot.responsesapi_client_metadataas enrichment for the Codex turn metadata blob while preventing those extras from overriding Codex-owned fields.Verification
cargo check -p codex-corejust fix -p codex-core