Add session headers to realtime conversation starts (#34681)

## What changed

- Include the Codex `session-id` and `thread-id` headers when starting realtime conversations over WebSocket or WebRTC.
- Add coverage confirming that WebRTC call creation forwards both identifiers while preserving the existing realtime request metadata and SDP payload.

GitOrigin-RevId: 668bee9a7d4797ad0a396e9ca4dc56b2c379cba7
This commit is contained in:
Peter Bakkum
2026-07-22 04:54:54 +00:00
committed by copyberry
parent 21db216db0
commit 963cda85aa
2 changed files with 124 additions and 3 deletions
+9 -3
View File
@@ -24,6 +24,7 @@ use codex_api::RealtimeSessionMode;
use codex_api::RealtimeWebsocketClient;
use codex_api::RealtimeWebsocketEvents;
use codex_api::RealtimeWebsocketWriter;
use codex_api::build_session_headers;
use codex_api::map_api_error;
use codex_config::config_toml::RealtimeWsMode;
use codex_config::config_toml::RealtimeWsVersion;
@@ -1162,7 +1163,7 @@ async fn prepare_realtime_start(
let requested_realtime_session_id = session_config.session_id.clone();
let event_parser = session_config.event_parser;
let originator = sess.originator().await;
let extra_headers = match transport {
let mut extra_headers = match transport {
ConversationStartTransport::Websocket => {
let realtime_api_key = realtime_api_key(auth.as_ref(), &provider)?;
realtime_request_headers(
@@ -1180,10 +1181,15 @@ async fn prepare_realtime_start(
originator.as_str(),
)?
}
};
}
.unwrap_or_default();
extra_headers.extend(build_session_headers(
Some(sess.session_id().to_string()),
Some(sess.thread_id().to_string()),
));
Ok(PreparedRealtimeConversationStart {
api_provider,
extra_headers,
extra_headers: Some(extra_headers),
client_managed_handoffs: params.client_managed_handoffs,
flush_transcript_tail_on_session_end: params.flush_transcript_tail_on_session_end,
codex_responses_as_items: params.codex_responses_as_items,