fix: expose OpenAI Realtime request IDs - #6917
Closed
chenghao-mou wants to merge 1 commit into
Closed
Conversation
longcw
reviewed
Aug 20, 2026
| # aiohttp does not expose WebSocket upgrade headers publicly. | ||
| response = getattr(ws, "_response", None) | ||
| if response is not None: | ||
| self._openai_request_id = response.headers.get("x-request-id") |
Contributor
There was a problem hiding this comment.
it seems x-request-id is not existed in the response during my testing
Member
Author
There was a problem hiding this comment.
Good point. The doc https://developers.openai.com/api/reference/overview#debugging-requests only mentions this as a HTTP response header, and it doesn't seem to support websocket/realtime endpoints. I will close the PR instead.
| """ | ||
|
|
||
| _openai_request_id: str | None = None | ||
| _openai_client_request_id: str | None = None |
Contributor
There was a problem hiding this comment.
duplicates with that in __init__?
| else: | ||
| headers["Authorization"] = f"Bearer {self._opts.api_key}" | ||
| self._openai_client_request_id = str(uuid.uuid4()) | ||
| headers["X-Client-Request-Id"] = self._openai_client_request_id |
Member
Author
There was a problem hiding this comment.
I don't think so. they have an undocumented x-trace-id instead.
Comment on lines
+3833
to
+3838
| provider_request_ids: list[str] = [] | ||
| if generation_ev.response_id: | ||
| provider_request_ids.append(generation_ev.response_id) | ||
| for request_id in generation_ev.provider_request_ids: | ||
| if request_id and request_id not in provider_request_ids: | ||
| provider_request_ids.append(request_id) |
Contributor
There was a problem hiding this comment.
nit: maybe just use list(dict.fromkeys(filter(None, [generation_ev.response_id, *generation_ev.provider_request_ids])))
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.
OpenAI support needs connection-level request IDs to diagnose Realtime failures. Capture the server
x-request-id, send a uniqueX-Client-Request-Id, and expose both through structured logs, realtime error events, assistant metrics, andagent_turnspans.Retry logs retain the applicable connection IDs.
Addresses AGT-3314
Initial prompt and agent context
Model: GPT-5.6