Forward client voice session IDs in realtime requests (#53784)

## What changed

Add optional `voiceSessionId` to realtime start parameters and forward it as the `voice-session-id` header for WebSocket, WebRTC, and existing-call transports. Keep this client-generated voice session identifier distinct from `realtimeSessionId`, which uses `x-session-id`.

## Testing

Extend serialization tests and add coverage for distinct session ID headers, WebRTC request forwarding, and existing-call handshake forwarding.

GitOrigin-RevId: cb558dbb9d438f2d34e281199a7e81fe5d33b879
This commit is contained in:
Chris Dong
2026-10-13 22:21:31 +00:00
committed by copyberry
parent b56a579fc6
commit 6786dccbe7
19 changed files with 139 additions and 0 deletions
@@ -4083,6 +4083,7 @@ mod tests {
realtime_end_instructions: Some("Resume normal text responses.".to_string()),
prompt: Some(Some("You are on a call".to_string())),
realtime_session_id: Some("sess_456".to_string()),
voice_session_id: Some("voice_789".to_string()),
transport: None,
version: Some(RealtimeConversationVersion::V3),
voice: Some(RealtimeVoice::Marin),
@@ -4122,6 +4123,7 @@ mod tests {
"realtimeEndInstructions": "Resume normal text responses.",
"prompt": "You are on a call",
"realtimeSessionId": "sess_456",
"voiceSessionId": "voice_789",
"transport": null,
"version": "v3",
"voice": "marin"
@@ -4154,6 +4156,7 @@ mod tests {
realtime_end_instructions: None,
prompt: None,
realtime_session_id: None,
voice_session_id: None,
transport: None,
version: None,
voice: None,
@@ -4179,6 +4182,7 @@ mod tests {
"realtimeStartInstructions": null,
"realtimeEndInstructions": null,
"realtimeSessionId": null,
"voiceSessionId": null,
"transport": null,
"version": null,
"voice": null
@@ -4207,6 +4211,7 @@ mod tests {
realtime_end_instructions: None,
prompt: Some(None),
realtime_session_id: None,
voice_session_id: None,
transport: None,
version: None,
voice: None,
@@ -4233,6 +4238,7 @@ mod tests {
"realtimeEndInstructions": null,
"prompt": null,
"realtimeSessionId": null,
"voiceSessionId": null,
"transport": null,
"version": null,
"voice": null
@@ -257,6 +257,10 @@ pub struct ThreadRealtimeStartParams {
pub prompt: Option<Option<String>>,
#[ts(optional = nullable)]
pub realtime_session_id: Option<String>,
/// Client-generated identifier for the product voice session. This is distinct from
/// `realtimeSessionId`.
#[ts(optional = nullable)]
pub voice_session_id: Option<String>,
#[ts(optional = nullable)]
pub transport: Option<ThreadRealtimeStartTransport>,
/// Overrides the configured realtime protocol version for this session only.