@openai/agents-realtime 0.11.7 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"openaiRealtimeWebRtc.mjs","sourceRoot":"","sources":["../src/openaiRealtimeWebRtc.ts"],"names":[],"mappings":"AAAA,2BAA2B;OAEpB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B;OAM1D,EAAE,SAAS,EAAE,MAAM,qBAAqB;OACxC,MAAM;OAEN,EACL,kBAAkB,GAEnB;OACM,EAAE,kBAAkB,EAAE;OACtB,EAAE,uBAAuB,EAAE;OAC3B,EAAE,OAAO,EAAE;AAElB,MAAM,qCAAqC,GAAG,IAAI,CAAC;AA4DnD;;;;;;;GAOG;AACH,MAAM,OAAO,oBACX,SAAQ,kBAAkB;IAqBG;IAlB7B,IAAI,CAAS;IACb,MAAM,GAAgB;QACpB,MAAM,EAAE,cAAc;QACtB,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,SAAS;KAClB,CAAC;IACF,kBAAkB,CAAU;IAC5B,sBAAsB,GAAG,KAAK,CAAC;IAC/B,MAAM,GAAG,KAAK,CAAC;IACf,eAAe,CAA4B;IAC3C,iBAAiB,GAAG,CAAC,CAAC;IACtB,kCAAkC,CAA4C;IAC9E,wBAAwB,GAAG,IAAI,uBAAuB,CACpD,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EACpC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAChC,CAAC;IAEF,YAA6B,UAAuC,EAAE;QACpE,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJY,YAAO,GAAP,OAA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K,cAAc,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,GAAG;gBACZ,MAAM,EAAE,cAAc;gBACtB,cAAc,EAAE,SAAS;gBACzB,WAAW,EAAE,SAAS;gBACtB,MAAM,EAAE,SAAS;aAClB,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,IACE,IAAI,CAAC,sBAAsB;YAC3B,IAAI,CAAC,wBAAwB,CAAC,mBAAmB,EAAE,EACnD,CAAC;YACD,IAAI,CAAC,aAAa,CAAC;gBACjB,IAAI,EAAE,iBAAiB;aACxB,CAAC,CAAC;YACH,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,aAAa,CAAC;YACjB,IAAI,EAAE,2BAA2B;SAClC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -14,6 +14,13 @@ import type { ApiKey, RealtimeTransportLayer } from './transportLayer';
14
14
  export type RealtimeContextData<TContext = unknown> = TContext & {
15
15
  history: RealtimeItem[];
16
16
  };
17
+ export type RealtimeToolExecutionConfig = {
18
+ /**
19
+ * Runs function tool input guardrails before emitting a pending human approval interruption.
20
+ * The same guardrails still run again immediately before tool execution after approval.
21
+ */
22
+ preApprovalInputGuardrails?: boolean;
23
+ };
17
24
  export type RealtimeSessionOptions<TContext = unknown> = {
18
25
  /**
19
26
  * The API key to use for the connection. Pass a function to lazily load the API key
@@ -43,6 +50,10 @@ export type RealtimeSessionOptions<TContext = unknown> = {
43
50
  * Additional session config options. Overrides default client options.
44
51
  */
45
52
  config?: Partial<RealtimeSessionConfig>;
53
+ /**
54
+ * SDK-side execution settings for local realtime tool calls.
55
+ */
56
+ toolExecution?: RealtimeToolExecutionConfig;
46
57
  /**
47
58
  * Whether the history copy should include a local copy of the audio data. By default it is not
48
59
  * included in the history to save runtime memory on the client. If you wish to keep this data
@@ -11,6 +11,7 @@ const guardrail_1 = require("./guardrail.js");
11
11
  const openaiRealtimeBase_1 = require("./openaiRealtimeBase.js");
12
12
  const openaiRealtimeWebRtc_1 = require("./openaiRealtimeWebRtc.js");
13
13
  const openaiRealtimeWebsocket_1 = require("./openaiRealtimeWebsocket.js");
14
+ const realtimeAgent_1 = require("./realtimeAgent.js");
14
15
  const utils_2 = require("./utils.js");
15
16
  const logger_1 = __importDefault(require("./logger.js"));
16
17
  const tool_1 = require("./tool.js");
@@ -18,7 +19,26 @@ const agents_core_2 = require("@openai/agents-core");
18
19
  function cloneDefaultSessionConfig() {
19
20
  return JSON.parse(JSON.stringify(openaiRealtimeBase_1.DEFAULT_OPENAI_REALTIME_SESSION_CONFIG));
20
21
  }
22
+ function validateRealtimeToolExecutionConfig(config) {
23
+ if (typeof config?.preApprovalInputGuardrails !== 'undefined' &&
24
+ typeof config.preApprovalInputGuardrails !== 'boolean') {
25
+ throw new agents_core_1.UserError('toolExecution.preApprovalInputGuardrails must be a boolean when provided.');
26
+ }
27
+ return config;
28
+ }
21
29
  const TOOL_APPROVAL_REJECTION_MESSAGE = 'Tool execution was not approved.';
30
+ function normalizeRealtimeFunctionCallId(toolCall) {
31
+ const callId = toolCall.callId || toolCall.id || '';
32
+ return callId === toolCall.callId ? toolCall : { ...toolCall, callId };
33
+ }
34
+ function getStartedResponseId(event) {
35
+ const response = event.providerData?.response;
36
+ if (typeof response !== 'object' || response === null) {
37
+ return undefined;
38
+ }
39
+ const responseId = response.id;
40
+ return typeof responseId === 'string' ? responseId : undefined;
41
+ }
22
42
  function toErrorMessage(error) {
23
43
  return error instanceof Error ? error.message : String(error);
24
44
  }
@@ -61,6 +81,9 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
61
81
  #transport;
62
82
  #currentAgent;
63
83
  #currentTools;
84
+ #currentDispatchSnapshot;
85
+ #responseDispatchSnapshots = new Map();
86
+ #pendingFunctionCalls = new Map();
64
87
  #context;
65
88
  #outputGuardrails = [];
66
89
  #outputGuardrailSettings;
@@ -81,6 +104,7 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
81
104
  // transport defaults causing issues for integrations like Twilio.
82
105
  #lastSessionConfig = cloneDefaultSessionConfig();
83
106
  #automaticallyTriggerResponseForMcpToolCalls = true;
107
+ #toolExecution;
84
108
  #eventListenersAttached = false;
85
109
  constructor(initialAgent, options = {}) {
86
110
  super();
@@ -107,6 +131,7 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
107
131
  this.#shouldIncludeAudioData = options.historyStoreAudio ?? false;
108
132
  this.#automaticallyTriggerResponseForMcpToolCalls =
109
133
  options.automaticallyTriggerResponseForMcpToolCalls ?? true;
134
+ this.#toolExecution = validateRealtimeToolExecutionConfig(options.toolExecution);
110
135
  }
111
136
  /**
112
137
  * The transport layer used by the session.
@@ -148,23 +173,52 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
148
173
  get availableMcpTools() {
149
174
  return this.#availableMcpTools;
150
175
  }
151
- async #setCurrentAgent(agent) {
152
- this.#currentAgent = agent;
153
- const handoffs = await this.#currentAgent.getEnabledHandoffs(this.#context);
176
+ async #prepareAgent(agent) {
177
+ const [handoffs, agentTools] = await Promise.all([
178
+ agent.getEnabledHandoffs(this.#context),
179
+ agent.getAllTools(this.#context),
180
+ ]);
154
181
  const handoffTools = handoffs.map((handoff) => handoff.getHandoffAsFunctionTool());
155
- const allTools = (await this.#currentAgent.getAllTools(this.#context))
156
- .filter(tool_1.isValidRealtimeTool)
157
- .map(tool_1.toRealtimeToolDefinition);
158
- const hasToolsDefined = typeof this.#currentAgent.tools !== 'undefined' ||
159
- typeof this.#currentAgent.mcpServers !== 'undefined';
182
+ const realtimeTools = agentTools.filter(tool_1.isValidRealtimeTool);
183
+ const functionTools = realtimeTools.filter((tool) => tool.type === 'function');
184
+ (0, tool_1.validateRealtimeToolNames)(functionTools, handoffs);
185
+ const hasToolsDefined = typeof agent.tools !== 'undefined' ||
186
+ typeof agent.mcpServers !== 'undefined';
160
187
  const hasHandoffsDefined = handoffs.length > 0;
161
- this.#currentTools =
162
- hasToolsDefined || hasHandoffsDefined
163
- ? [...allTools, ...handoffTools]
164
- : undefined;
188
+ return {
189
+ agent,
190
+ toolDefinitions: hasToolsDefined || hasHandoffsDefined
191
+ ? [...realtimeTools.map(tool_1.toRealtimeToolDefinition), ...handoffTools]
192
+ : undefined,
193
+ dispatchSnapshot: {
194
+ agent,
195
+ functionTools,
196
+ handoffs,
197
+ },
198
+ };
199
+ }
200
+ #applyPreparedAgent(prepared) {
201
+ this.#currentAgent = prepared.agent;
202
+ this.#currentTools = prepared.toolDefinitions;
203
+ this.#currentDispatchSnapshot = prepared.dispatchSnapshot;
165
204
  // Recompute currently available MCP tools based on the new agent's active server labels.
166
205
  this.#updateAvailableMcpTools();
167
206
  }
207
+ async #setCurrentAgent(agent) {
208
+ const prepared = await this.#prepareAgent(agent);
209
+ this.#applyPreparedAgent(prepared);
210
+ }
211
+ #captureResponseDispatchSnapshot(responseId) {
212
+ const existingSnapshot = this.#responseDispatchSnapshots.get(responseId);
213
+ if (existingSnapshot) {
214
+ return existingSnapshot;
215
+ }
216
+ const snapshot = this.#currentDispatchSnapshot;
217
+ if (snapshot) {
218
+ this.#responseDispatchSnapshots.set(responseId, snapshot);
219
+ }
220
+ return snapshot;
221
+ }
168
222
  async #getSessionConfig(additionalConfig = {}) {
169
223
  const overridesConfig = additionalConfig ?? {};
170
224
  const optionsConfig = this.options.config ?? {};
@@ -271,18 +325,20 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
271
325
  }
272
326
  }
273
327
  async updateAgent(newAgent) {
328
+ const prepared = await this.#prepareAgent(newAgent);
274
329
  this.#currentAgent.emit('agent_handoff', this.#context, newAgent);
275
330
  this.emit('agent_handoff', this.#context, this.#currentAgent, newAgent);
276
- await this.#setCurrentAgent(newAgent);
331
+ this.#applyPreparedAgent(prepared);
277
332
  await this.#transport.updateSessionConfig(await this.#getSessionConfig());
278
333
  return newAgent;
279
334
  }
280
- async #handleHandoff(toolCall, handoff) {
335
+ async #handleHandoff(toolCall, handoff, sourceAgent) {
281
336
  const newAgent = (await handoff.onInvokeHandoff(this.#context, toolCall.arguments));
282
- this.#currentAgent.emit('agent_handoff', this.#context, newAgent);
283
- this.emit('agent_handoff', this.#context, this.#currentAgent, newAgent);
337
+ const prepared = await this.#prepareAgent(newAgent);
338
+ sourceAgent.emit('agent_handoff', this.#context, newAgent);
339
+ this.emit('agent_handoff', this.#context, sourceAgent, newAgent);
284
340
  // update session with new agent
285
- await this.#setCurrentAgent(newAgent);
341
+ this.#applyPreparedAgent(prepared);
286
342
  await this.#transport.updateSessionConfig(await this.#getSessionConfig());
287
343
  const output = (0, agents_core_1.getTransferMessage)(newAgent);
288
344
  this.#transport.sendFunctionCallOutput(toolCall, output, true);
@@ -319,7 +375,8 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
319
375
  }
320
376
  return TOOL_APPROVAL_REJECTION_MESSAGE;
321
377
  }
322
- async #handleFunctionToolCall(toolCall, tool) {
378
+ async #handleFunctionToolCall(incomingToolCall, tool, agent, dispatchSnapshot) {
379
+ const toolCall = normalizeRealtimeFunctionCallId(incomingToolCall);
323
380
  this.#context.context.history = JSON.parse(JSON.stringify(this.#history)); // deep copy of the history
324
381
  let parsedArgs = toolCall.arguments;
325
382
  if (tool.parameters) {
@@ -337,39 +394,63 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
337
394
  callId: toolCall.callId,
338
395
  });
339
396
  if (approval === false) {
340
- this.emit('agent_tool_start', this.#context, this.#currentAgent, tool, {
397
+ this.#pendingFunctionCalls.delete(toolCall.callId);
398
+ this.emit('agent_tool_start', this.#context, agent, tool, {
341
399
  toolCall,
342
400
  });
343
- this.#currentAgent.emit('agent_tool_start', this.#context, tool, {
401
+ agent.emit('agent_tool_start', this.#context, tool, {
344
402
  toolCall,
345
403
  });
346
404
  const result = await this.#resolveApprovalRejectionMessage(tool.name, toolCall.callId);
347
405
  this.#transport.sendFunctionCallOutput(toolCall, result, true);
348
- this.emit('agent_tool_end', this.#context, this.#currentAgent, tool, result, { toolCall });
349
- this.#currentAgent.emit('agent_tool_end', this.#context, tool, result, {
406
+ this.emit('agent_tool_end', this.#context, agent, tool, result, {
407
+ toolCall,
408
+ });
409
+ agent.emit('agent_tool_end', this.#context, tool, result, {
350
410
  toolCall,
351
411
  });
352
412
  return;
353
413
  }
354
414
  else if (typeof approval === 'undefined') {
355
- this.emit('tool_approval_requested', this.#context, this.#currentAgent, {
415
+ if (this.#toolExecution?.preApprovalInputGuardrails === true) {
416
+ const inputGuardrailResult = await (0, agents_core_2.runToolInputGuardrails)({
417
+ guardrails: tool.inputGuardrails,
418
+ context: this.#context,
419
+ agent,
420
+ toolCall: toolCall,
421
+ });
422
+ if (inputGuardrailResult.type === 'reject') {
423
+ this.#transport.sendFunctionCallOutput(toolCall, inputGuardrailResult.message, true);
424
+ return;
425
+ }
426
+ }
427
+ const approvalItem = new agents_core_1.RunToolApprovalItem(toolCall, agent);
428
+ this.#pendingFunctionCalls.set(toolCall.callId, {
429
+ toolCall,
430
+ tool,
431
+ agent,
432
+ dispatchSnapshot,
433
+ approvalItem,
434
+ });
435
+ this.emit('tool_approval_requested', this.#context, agent, {
356
436
  type: 'function_approval',
357
437
  tool,
358
- approvalItem: new agents_core_1.RunToolApprovalItem(toolCall, this.#currentAgent),
438
+ approvalItem,
359
439
  });
360
440
  return;
361
441
  }
362
442
  }
443
+ this.#pendingFunctionCalls.delete(toolCall.callId);
363
444
  const inputGuardrailResult = await (0, agents_core_2.runToolInputGuardrails)({
364
445
  guardrails: tool.inputGuardrails,
365
446
  context: this.#context,
366
- agent: this.#currentAgent,
447
+ agent,
367
448
  toolCall: toolCall,
368
449
  });
369
- this.emit('agent_tool_start', this.#context, this.#currentAgent, tool, {
450
+ this.emit('agent_tool_start', this.#context, agent, tool, {
370
451
  toolCall,
371
452
  });
372
- this.#currentAgent.emit('agent_tool_start', this.#context, tool, {
453
+ agent.emit('agent_tool_start', this.#context, tool, {
373
454
  toolCall,
374
455
  });
375
456
  this.#context.context.history = JSON.parse(JSON.stringify(this.#history)); // deep copy of the history
@@ -388,7 +469,7 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
388
469
  : await (0, agents_core_2.runToolOutputGuardrails)({
389
470
  guardrails: tool.outputGuardrails,
390
471
  context: this.#context,
391
- agent: this.#currentAgent,
472
+ agent,
392
473
  toolCall: toolCall,
393
474
  toolOutput: result,
394
475
  });
@@ -402,32 +483,45 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
402
483
  stringResult = (0, utils_1.toSmartString)(guardedResult);
403
484
  this.#transport.sendFunctionCallOutput(toolCall, stringResult, true);
404
485
  }
405
- this.emit('agent_tool_end', this.#context, this.#currentAgent, tool, stringResult, { toolCall });
406
- this.#currentAgent.emit('agent_tool_end', this.#context, tool, stringResult, { toolCall });
486
+ this.emit('agent_tool_end', this.#context, agent, tool, stringResult, {
487
+ toolCall,
488
+ });
489
+ agent.emit('agent_tool_end', this.#context, tool, stringResult, {
490
+ toolCall,
491
+ });
407
492
  }
408
- async #handleFunctionCall(toolCall) {
409
- const enabledHandoffs = await this.#currentAgent.getEnabledHandoffs(this.#context);
410
- const handoffMap = new Map(enabledHandoffs.map((handoff) => [handoff.toolName, handoff]));
411
- const allTools = await this.#currentAgent.getAllTools(this.#context);
412
- const functionToolMap = new Map(allTools.map((tool) => [tool.name, tool]));
493
+ async #handleFunctionCall(toolCall, dispatchSnapshot) {
494
+ const [toolEnabled, handoffEnabled] = await Promise.all([
495
+ Promise.all(dispatchSnapshot.functionTools.map((tool) => tool.isEnabled(this.#context, dispatchSnapshot.agent))),
496
+ Promise.all(dispatchSnapshot.handoffs.map((handoff) => handoff.isEnabled({
497
+ runContext: this.#context,
498
+ agent: dispatchSnapshot.agent,
499
+ }))),
500
+ ]);
501
+ const filteredSnapshot = {
502
+ agent: dispatchSnapshot.agent,
503
+ functionTools: dispatchSnapshot.functionTools.filter((_tool, index) => toolEnabled[index]),
504
+ handoffs: dispatchSnapshot.handoffs.filter((_handoff, index) => handoffEnabled[index]),
505
+ };
506
+ (0, tool_1.validateRealtimeToolNames)(filteredSnapshot.functionTools, filteredSnapshot.handoffs);
507
+ const functionToolMap = new Map(filteredSnapshot.functionTools.map((tool) => [tool.name, tool]));
508
+ const handoffMap = new Map(filteredSnapshot.handoffs.map((handoff) => [handoff.toolName, handoff]));
509
+ const functionTool = functionToolMap.get(toolCall.name);
510
+ if (functionTool) {
511
+ await this.#handleFunctionToolCall(toolCall, functionTool, filteredSnapshot.agent, filteredSnapshot);
512
+ return;
513
+ }
413
514
  const possibleHandoff = handoffMap.get(toolCall.name);
414
515
  if (possibleHandoff) {
415
- await this.#handleHandoff(toolCall, possibleHandoff);
416
- }
417
- else {
418
- const functionTool = functionToolMap.get(toolCall.name);
419
- if (functionTool && functionTool.type === 'function') {
420
- await this.#handleFunctionToolCall(toolCall, functionTool);
421
- }
422
- else {
423
- const message = `Tool ${toolCall.name} not found`;
424
- this.#transport.sendFunctionCallOutput(toolCall, message, false);
425
- this.emit('error', {
426
- type: 'error',
427
- error: new agents_core_1.ModelBehaviorError(message),
428
- });
429
- }
516
+ await this.#handleHandoff(toolCall, possibleHandoff, filteredSnapshot.agent);
517
+ return;
430
518
  }
519
+ const message = `Tool ${toolCall.name} not found`;
520
+ this.#transport.sendFunctionCallOutput(toolCall, message, false);
521
+ this.emit('error', {
522
+ type: 'error',
523
+ error: new agents_core_1.ModelBehaviorError(message),
524
+ });
431
525
  }
432
526
  async #runOutputGuardrails(output, responseId, itemId) {
433
527
  if (this.#outputGuardrails.length === 0) {
@@ -492,8 +586,12 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
492
586
  }
493
587
  this.emit('audio', event);
494
588
  });
495
- this.#transport.on('turn_started', () => {
589
+ this.#transport.on('turn_started', (event) => {
496
590
  this.#audioStarted = false;
591
+ const responseId = getStartedResponseId(event);
592
+ if (responseId) {
593
+ this.#captureResponseDispatchSnapshot(responseId);
594
+ }
497
595
  this.emit('agent_start', this.#context, this.#currentAgent);
498
596
  this.#currentAgent.emit('agent_start', this.#context, this.#currentAgent);
499
597
  });
@@ -518,6 +616,7 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
518
616
  this.emit('agent_end', this.#context, this.#currentAgent, textOutput);
519
617
  this.#currentAgent.emit('agent_end', this.#context, textOutput);
520
618
  this.#runOutputGuardrails(textOutput, event.response.id, itemId);
619
+ this.#responseDispatchSnapshots.delete(event.response.id);
521
620
  });
522
621
  this.#transport.on('audio_done', () => {
523
622
  if (this.#audioStarted) {
@@ -593,7 +692,14 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
593
692
  });
594
693
  this.#transport.on('function_call', async (event) => {
595
694
  try {
596
- await this.#handleFunctionCall(event);
695
+ if (!event.responseId) {
696
+ throw new agents_core_1.ModelBehaviorError('Realtime function call is missing a responseId and cannot be dispatched safely.');
697
+ }
698
+ const dispatchSnapshot = this.#captureResponseDispatchSnapshot(event.responseId);
699
+ if (!dispatchSnapshot) {
700
+ throw new agents_core_1.ModelBehaviorError('Realtime tool dispatch is unavailable before the session tool configuration is resolved.');
701
+ }
702
+ await this.#handleFunctionCall(event, dispatchSnapshot);
597
703
  }
598
704
  catch (error) {
599
705
  logger_1.default.error('Error handling function call', error);
@@ -684,6 +790,7 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
684
790
  * @param options - The options for the connection.
685
791
  */
686
792
  async connect(options) {
793
+ this.#responseDispatchSnapshots.clear();
687
794
  // makes sure the current agent is correctly set and loads the tools
688
795
  await this.#setCurrentAgent(this.initialAgent);
689
796
  if (!this.#eventListenersAttached) {
@@ -744,6 +851,8 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
744
851
  */
745
852
  close() {
746
853
  this.#interruptedByGuardrail = {};
854
+ this.#pendingFunctionCalls.clear();
855
+ this.#responseDispatchSnapshots.clear();
747
856
  this.#transport.close();
748
857
  }
749
858
  /**
@@ -762,6 +871,40 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
762
871
  interrupt() {
763
872
  this.#transport.interrupt();
764
873
  }
874
+ #resolvePendingFunctionCall(approvalItem) {
875
+ if (approvalItem.rawItem.type !== 'function_call') {
876
+ return undefined;
877
+ }
878
+ const rawToolCall = approvalItem.rawItem;
879
+ if (typeof rawToolCall.responseId !== 'string') {
880
+ return undefined;
881
+ }
882
+ const toolCall = normalizeRealtimeFunctionCallId(rawToolCall);
883
+ const pending = this.#pendingFunctionCalls.get(toolCall.callId);
884
+ if (pending) {
885
+ return pending;
886
+ }
887
+ const agent = approvalItem.agent instanceof realtimeAgent_1.RealtimeAgent
888
+ ? approvalItem.agent
889
+ : this.#currentAgent;
890
+ const toolName = approvalItem.toolName ?? approvalItem.rawItem.name;
891
+ const tool = agent.tools.find((candidate) => candidate.type === 'function' && candidate.name === toolName);
892
+ if (!tool) {
893
+ return undefined;
894
+ }
895
+ const dispatchSnapshot = this.#currentDispatchSnapshot?.agent === agent
896
+ ? this.#currentDispatchSnapshot
897
+ : { agent, functionTools: [tool], handoffs: [] };
898
+ return {
899
+ toolCall,
900
+ tool,
901
+ agent,
902
+ dispatchSnapshot,
903
+ approvalItem: toolCall === approvalItem.rawItem
904
+ ? approvalItem
905
+ : new agents_core_1.RunToolApprovalItem(toolCall, approvalItem.agent, approvalItem.toolName),
906
+ };
907
+ }
765
908
  /**
766
909
  * Approve a tool call. This will also trigger the tool call to the agent.
767
910
  * @param approvalItem - The approval item to approve.
@@ -769,13 +912,12 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
769
912
  * @param options.alwaysApprove - Whether to always approve the tool call.
770
913
  */
771
914
  async approve(approvalItem, options = { alwaysApprove: false }) {
772
- this.#context.approveTool(approvalItem, options);
915
+ const pending = this.#resolvePendingFunctionCall(approvalItem);
916
+ this.#context.approveTool(pending?.approvalItem ?? approvalItem, options);
773
917
  const toolName = approvalItem.toolName ?? approvalItem.rawItem.name;
774
- const tool = this.#currentAgent.tools.find((tool) => tool.name === toolName);
775
- if (tool &&
776
- tool.type === 'function' &&
777
- approvalItem.rawItem.type === 'function_call') {
778
- await this.#handleFunctionToolCall(approvalItem.rawItem, tool);
918
+ if (pending) {
919
+ this.#pendingFunctionCalls.delete(pending.toolCall.callId);
920
+ await this.#handleFunctionToolCall(pending.toolCall, pending.tool, pending.agent, pending.dispatchSnapshot);
779
921
  }
780
922
  else if (approvalItem.rawItem.type === 'hosted_tool_call') {
781
923
  if (options.alwaysApprove) {
@@ -799,14 +941,13 @@ class RealtimeSession extends _shims_1.RuntimeEventEmitter {
799
941
  async reject(approvalItem, options = {
800
942
  alwaysReject: false,
801
943
  }) {
802
- this.#context.rejectTool(approvalItem, options);
944
+ const pending = this.#resolvePendingFunctionCall(approvalItem);
945
+ this.#context.rejectTool(pending?.approvalItem ?? approvalItem, options);
803
946
  // we still need to simulate a tool call to the agent to let the agent know
804
947
  const toolName = approvalItem.toolName ?? approvalItem.rawItem.name;
805
- const tool = this.#currentAgent.tools.find((tool) => tool.name === toolName);
806
- if (tool &&
807
- tool.type === 'function' &&
808
- approvalItem.rawItem.type === 'function_call') {
809
- await this.#handleFunctionToolCall(approvalItem.rawItem, tool);
948
+ if (pending) {
949
+ this.#pendingFunctionCalls.delete(pending.toolCall.callId);
950
+ await this.#handleFunctionToolCall(pending.toolCall, pending.tool, pending.agent, pending.dispatchSnapshot);
810
951
  }
811
952
  else if (approvalItem.rawItem.type === 'hosted_tool_call') {
812
953
  if (options.alwaysReject) {