@@ -26,6 +26,7 @@ vi.mock('@openai/agents/realtime', () => {
26
26
FakeOpenAIRealtimeWebSocket . prototype . sendAudio = vi . fn ( ) ;
27
27
FakeOpenAIRealtimeWebSocket . prototype . close = vi . fn ( ) ;
28
28
FakeOpenAIRealtimeWebSocket . prototype . _interrupt = vi . fn ( ) ;
29
+ FakeOpenAIRealtimeWebSocket . prototype . updateSessionConfig = vi . fn ( ) ;
29
30
return { OpenAIRealtimeWebSocket : FakeOpenAIRealtimeWebSocket , utils } ;
30
31
} ) ;
31
32
@@ -146,4 +147,22 @@ describe('TwilioRealtimeTransportLayer', () => {
146
147
expect ( marks [ 2 ] . mark . name ) . toBe ( 'b:1' ) ;
147
148
expect ( audioListener ) . toHaveBeenCalledTimes ( 3 ) ;
148
149
} ) ;
150
+
151
+ test ( 'updateSessionConfig keeps audio format' , async ( ) => {
152
+ const twilio = new FakeTwilioWebSocket ( ) ;
153
+ const transport = new TwilioRealtimeTransportLayer ( {
154
+ twilioWebSocket : twilio as any ,
155
+ } ) ;
156
+ await transport . connect ( { apiKey : 'ek_test' } as any ) ;
157
+ const { OpenAIRealtimeWebSocket } = await import ( '@openai/agents/realtime' ) ;
158
+ const spy = vi . mocked (
159
+ OpenAIRealtimeWebSocket . prototype . updateSessionConfig ,
160
+ ) ;
161
+ transport . updateSessionConfig ( { instructions : 'hi' } ) ;
162
+ expect ( spy ) . toHaveBeenCalledWith ( {
163
+ instructions : 'hi' ,
164
+ inputAudioFormat : 'g711_ulaw' ,
165
+ outputAudioFormat : 'g711_ulaw' ,
166
+ } ) ;
167
+ } ) ;
149
168
} ) ;
0 commit comments