@@ -29,7 +29,10 @@ import {
2929 RealtimeOutputGuardrailSettings ,
3030} from './guardrail' ;
3131import { RealtimeItem } from './items' ;
32- import { OpenAIRealtimeModels } from './openaiRealtimeBase' ;
32+ import {
33+ DEFAULT_OPENAI_REALTIME_SESSION_CONFIG ,
34+ OpenAIRealtimeModels ,
35+ } from './openaiRealtimeBase' ;
3336import { OpenAIRealtimeWebRTC } from './openaiRealtimeWebRtc' ;
3437import { OpenAIRealtimeWebSocket } from './openaiRealtimeWebsocket' ;
3538import { RealtimeAgent } from './realtimeAgent' ;
@@ -147,6 +150,12 @@ export type RealtimeSessionConnectOptions = {
147150 url ?: string ;
148151} ;
149152
153+ function cloneDefaultSessionConfig ( ) : Partial < RealtimeSessionConfig > {
154+ return JSON . parse (
155+ JSON . stringify ( DEFAULT_OPENAI_REALTIME_SESSION_CONFIG ) ,
156+ ) as Partial < RealtimeSessionConfig > ;
157+ }
158+
150159/**
151160 * A `RealtimeSession` is the cornerstone of building Voice Agents. It's the equivalent of a
152161 * Runner in text-based agents except that it automatically handles multiple turns by maintaining a
@@ -206,7 +215,8 @@ export class RealtimeSession<
206215 // modalities, speed, toolChoice, turnDetection, etc.). Without this, updating
207216 // the agent would drop audio format overrides (e.g. g711_ulaw) and revert to
208217 // transport defaults causing issues for integrations like Twilio.
209- #lastSessionConfig: Partial < RealtimeSessionConfig > | null = null ;
218+ #lastSessionConfig: Partial < RealtimeSessionConfig > | null =
219+ cloneDefaultSessionConfig ( ) ;
210220 #automaticallyTriggerResponseForMcpToolCalls: boolean = true ;
211221
212222 constructor (
0 commit comments