[rollout-trace] Include x-request-id in rollout trace.#20066
Merged
cassirer-openai merged 3 commits intomainfrom Apr 28, 2026
Merged
[rollout-trace] Include x-request-id in rollout trace.#20066cassirer-openai merged 3 commits intomainfrom
cassirer-openai merged 3 commits intomainfrom
Conversation
The header x-request-id holds the ID of the request in responses API. Storing this in our rollout traces allows us to more easily trace the rollout through upstream systems. The field upstream_request_id was already present in our reduced state but it incorrectly held the response ID.
89a0fc4 to
f57441f
Compare
Contributor
Author
|
@codex review |
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f57441f28a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
Why
Rollout traces need an identifier that can be used to correlate a Codex inference with upstream Responses API, proxy, and engine logs. The reduced trace model already exposed
upstream_request_id, but it was being populated from the Responses APIresponse.id. That value is useful forprevious_response_idchaining, but it is not the transport request id that upstream systems key on.This PR separates those concepts so trace consumers can reliably answer both questions:
Structure
The change keeps the upstream request id at the same lifecycle level as the provider stream:
codex-apicaptures thex-request-idHTTP response header when the SSE stream is created and exposes it onResponseStream. Fixture and websocket streams set the field toNonebecause they do not have that HTTP response header.codex-corecarries that stream-level id intoInferenceTraceAttemptwhen recording terminal stream outcomes. Completed, failed, cancelled, dropped-stream, and pre-response error paths all record the id when it is available.rollout-tracenow records both identifiers in raw terminal inference events and response payloads:response_idfor the Responses APIresponse.id, andupstream_request_idforx-request-id.InferenceCall. It also usesresponse_idforprevious_response_idconversation linking, which removes the old accidental dependency on the misnamedupstream_request_idfield.InferenceCompleted,InferenceFailed, orInferenceCancelled) in one place. That keeps status, partial payloads, response ids, and upstream request ids consistent across success, failure, cancellation, and late stream-mapper events.Why This Shape
x-request-idis a property of the HTTP/provider response envelope, not an SSE event. Capturing it once incodex-apiand plumbing it through terminal trace recording avoids trying to infer the value from stream contents, and it preserves the id even when the stream fails or is cancelled after only partial output.Keeping
response_idseparate fromupstream_request_idalso makes the reduced trace model less surprising:response_idremains the conversation-continuation id, whileupstream_request_idis the operational correlation id for upstream debugging.Validation
The PR updates trace and reducer coverage for:
x-request-idfrom SSE response headers;previous_response_idreconstruction tied toresponse_idrather than transport request ids.