Route WebRTC sideband joins to the Realtime API (#35830)

## What changed

- Use `https://api.openai.com/v1` for WebRTC sideband websocket joins instead of deriving the URL from the model provider.
- Keep `experimental_realtime_ws_base_url` as an explicit sideband override for local development and tests.
- Exclude provider query parameters when building sideband URLs.

## Testing

- Add coverage that a frameless sideband join uses `wss://api.openai.com/v1/live/rtc_test` even when the provider points at the ChatGPT backend.
- Update the sideband retry end-to-end test to inject its mock server URL through the new override.

GitOrigin-RevId: 5d3d2cd69905ba04143010ced36a22712825b563
This commit is contained in:
Peter Bakkum
2026-07-28 21:16:06 +00:00
committed by copyberry
parent 50a7328f50
commit 438c9e98db
3 changed files with 71 additions and 10 deletions
+12 -1
View File
@@ -458,6 +458,7 @@ struct ConversationState {
struct RealtimeStart {
api_provider: ApiProvider,
realtime_sideband_base_url: Option<String>,
extra_headers: Option<HeaderMap>,
client_managed_handoffs: bool,
flush_transcript_tail_on_session_end: bool,
@@ -518,6 +519,7 @@ impl RealtimeConversationManager {
async fn start_inner(&self, start: RealtimeStart) -> CodexResult<RealtimeStartOutput> {
let RealtimeStart {
api_provider,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,
flush_transcript_tail_on_session_end,
@@ -569,6 +571,10 @@ impl RealtimeConversationManager {
};
let client = RealtimeWebsocketClient::new(api_provider);
let client = match realtime_sideband_base_url {
Some(base_url) => client.with_webrtc_sideband_base_url(base_url),
None => client,
};
let (task, sdp) = if let Some(sdp) = sdp {
let call = model_client
.create_realtime_call_with_headers(
@@ -1090,6 +1096,7 @@ pub(crate) async fn handle_start(
struct PreparedRealtimeConversationStart {
api_provider: ApiProvider,
realtime_sideband_base_url: Option<String>,
extra_headers: Option<HeaderMap>,
client_managed_handoffs: bool,
flush_transcript_tail_on_session_end: bool,
@@ -1127,7 +1134,8 @@ async fn prepare_realtime_start(
.clone()
.unwrap_or(ConversationStartTransport::Websocket);
let mut api_provider = provider.to_api_provider(Some(AuthMode::ApiKey))?;
if let Some(realtime_ws_base_url) = &config.experimental_realtime_ws_base_url {
let realtime_sideband_base_url = config.experimental_realtime_ws_base_url.clone();
if let Some(realtime_ws_base_url) = &realtime_sideband_base_url {
api_provider.base_url = realtime_ws_base_url.clone();
}
let realtime_call_api_provider =
@@ -1182,6 +1190,7 @@ async fn prepare_realtime_start(
));
Ok(PreparedRealtimeConversationStart {
api_provider,
realtime_sideband_base_url,
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,
@@ -1381,6 +1390,7 @@ async fn handle_start_inner(
) -> CodexResult<()> {
let PreparedRealtimeConversationStart {
api_provider,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,
flush_transcript_tail_on_session_end,
@@ -1401,6 +1411,7 @@ async fn handle_start_inner(
};
let start = RealtimeStart {
api_provider,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,
flush_transcript_tail_on_session_end,