@livekit/agents 1.0.36-dev.0 → 1.0.37

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.
Files changed (176) hide show
  1. package/dist/index.cjs +1 -3
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +0 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +0 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/inference/utils.cjs +2 -15
  9. package/dist/inference/utils.cjs.map +1 -1
  10. package/dist/inference/utils.d.cts +0 -1
  11. package/dist/inference/utils.d.ts +0 -1
  12. package/dist/inference/utils.d.ts.map +1 -1
  13. package/dist/inference/utils.js +1 -13
  14. package/dist/inference/utils.js.map +1 -1
  15. package/dist/stream/stream_channel.cjs +0 -3
  16. package/dist/stream/stream_channel.cjs.map +1 -1
  17. package/dist/stream/stream_channel.d.cts +2 -3
  18. package/dist/stream/stream_channel.d.ts +2 -3
  19. package/dist/stream/stream_channel.d.ts.map +1 -1
  20. package/dist/stream/stream_channel.js +0 -3
  21. package/dist/stream/stream_channel.js.map +1 -1
  22. package/dist/telemetry/trace_types.cjs +0 -15
  23. package/dist/telemetry/trace_types.cjs.map +1 -1
  24. package/dist/telemetry/trace_types.d.cts +0 -5
  25. package/dist/telemetry/trace_types.d.ts +0 -5
  26. package/dist/telemetry/trace_types.d.ts.map +1 -1
  27. package/dist/telemetry/trace_types.js +0 -10
  28. package/dist/telemetry/trace_types.js.map +1 -1
  29. package/dist/voice/agent_activity.cjs +19 -68
  30. package/dist/voice/agent_activity.cjs.map +1 -1
  31. package/dist/voice/agent_activity.d.cts +0 -14
  32. package/dist/voice/agent_activity.d.ts +0 -14
  33. package/dist/voice/agent_activity.d.ts.map +1 -1
  34. package/dist/voice/agent_activity.js +19 -68
  35. package/dist/voice/agent_activity.js.map +1 -1
  36. package/dist/voice/agent_session.cjs +65 -37
  37. package/dist/voice/agent_session.cjs.map +1 -1
  38. package/dist/voice/agent_session.d.cts +25 -4
  39. package/dist/voice/agent_session.d.ts +25 -4
  40. package/dist/voice/agent_session.d.ts.map +1 -1
  41. package/dist/voice/agent_session.js +65 -37
  42. package/dist/voice/agent_session.js.map +1 -1
  43. package/dist/voice/audio_recognition.cjs +2 -124
  44. package/dist/voice/audio_recognition.cjs.map +1 -1
  45. package/dist/voice/audio_recognition.d.cts +1 -32
  46. package/dist/voice/audio_recognition.d.ts +1 -32
  47. package/dist/voice/audio_recognition.d.ts.map +1 -1
  48. package/dist/voice/audio_recognition.js +2 -127
  49. package/dist/voice/audio_recognition.js.map +1 -1
  50. package/dist/voice/index.cjs +14 -1
  51. package/dist/voice/index.cjs.map +1 -1
  52. package/dist/voice/index.d.cts +1 -0
  53. package/dist/voice/index.d.ts +1 -0
  54. package/dist/voice/index.d.ts.map +1 -1
  55. package/dist/voice/index.js +3 -1
  56. package/dist/voice/index.js.map +1 -1
  57. package/dist/voice/room_io/room_io.cjs +1 -0
  58. package/dist/voice/room_io/room_io.cjs.map +1 -1
  59. package/dist/voice/room_io/room_io.d.ts.map +1 -1
  60. package/dist/voice/room_io/room_io.js +1 -0
  61. package/dist/voice/room_io/room_io.js.map +1 -1
  62. package/dist/voice/speech_handle.cjs +12 -3
  63. package/dist/voice/speech_handle.cjs.map +1 -1
  64. package/dist/voice/speech_handle.d.cts +12 -2
  65. package/dist/voice/speech_handle.d.ts +12 -2
  66. package/dist/voice/speech_handle.d.ts.map +1 -1
  67. package/dist/voice/speech_handle.js +10 -2
  68. package/dist/voice/speech_handle.js.map +1 -1
  69. package/dist/voice/testing/index.cjs +54 -0
  70. package/dist/voice/testing/index.cjs.map +1 -0
  71. package/dist/voice/testing/index.d.cts +20 -0
  72. package/dist/voice/testing/index.d.ts +20 -0
  73. package/dist/voice/testing/index.d.ts.map +1 -0
  74. package/dist/voice/testing/index.js +33 -0
  75. package/dist/voice/testing/index.js.map +1 -0
  76. package/dist/voice/testing/run_result.cjs +766 -0
  77. package/dist/voice/testing/run_result.cjs.map +1 -0
  78. package/dist/voice/testing/run_result.d.cts +374 -0
  79. package/dist/voice/testing/run_result.d.ts +374 -0
  80. package/dist/voice/testing/run_result.d.ts.map +1 -0
  81. package/dist/voice/testing/run_result.js +739 -0
  82. package/dist/voice/testing/run_result.js.map +1 -0
  83. package/dist/{inference/interruption/index.cjs → voice/testing/types.cjs} +24 -12
  84. package/dist/voice/testing/types.cjs.map +1 -0
  85. package/dist/voice/testing/types.d.cts +83 -0
  86. package/dist/voice/testing/types.d.ts +83 -0
  87. package/dist/voice/testing/types.d.ts.map +1 -0
  88. package/dist/voice/testing/types.js +19 -0
  89. package/dist/voice/testing/types.js.map +1 -0
  90. package/package.json +3 -4
  91. package/src/index.ts +0 -2
  92. package/src/inference/utils.ts +0 -15
  93. package/src/stream/stream_channel.ts +2 -6
  94. package/src/telemetry/trace_types.ts +0 -7
  95. package/src/voice/agent_activity.ts +24 -83
  96. package/src/voice/agent_session.ts +74 -49
  97. package/src/voice/audio_recognition.ts +1 -161
  98. package/src/voice/index.ts +1 -0
  99. package/src/voice/room_io/room_io.ts +1 -0
  100. package/src/voice/speech_handle.ts +24 -4
  101. package/src/voice/testing/index.ts +50 -0
  102. package/src/voice/testing/run_result.ts +937 -0
  103. package/src/voice/testing/types.ts +118 -0
  104. package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs +0 -152
  105. package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs.map +0 -1
  106. package/dist/inference/interruption/AdaptiveInterruptionDetector.d.cts +0 -50
  107. package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts +0 -50
  108. package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts.map +0 -1
  109. package/dist/inference/interruption/AdaptiveInterruptionDetector.js +0 -125
  110. package/dist/inference/interruption/AdaptiveInterruptionDetector.js.map +0 -1
  111. package/dist/inference/interruption/InterruptionStream.cjs +0 -310
  112. package/dist/inference/interruption/InterruptionStream.cjs.map +0 -1
  113. package/dist/inference/interruption/InterruptionStream.d.cts +0 -57
  114. package/dist/inference/interruption/InterruptionStream.d.ts +0 -57
  115. package/dist/inference/interruption/InterruptionStream.d.ts.map +0 -1
  116. package/dist/inference/interruption/InterruptionStream.js +0 -288
  117. package/dist/inference/interruption/InterruptionStream.js.map +0 -1
  118. package/dist/inference/interruption/defaults.cjs +0 -76
  119. package/dist/inference/interruption/defaults.cjs.map +0 -1
  120. package/dist/inference/interruption/defaults.d.cts +0 -14
  121. package/dist/inference/interruption/defaults.d.ts +0 -14
  122. package/dist/inference/interruption/defaults.d.ts.map +0 -1
  123. package/dist/inference/interruption/defaults.js +0 -42
  124. package/dist/inference/interruption/defaults.js.map +0 -1
  125. package/dist/inference/interruption/errors.cjs +0 -2
  126. package/dist/inference/interruption/errors.cjs.map +0 -1
  127. package/dist/inference/interruption/errors.d.cts +0 -2
  128. package/dist/inference/interruption/errors.d.ts +0 -2
  129. package/dist/inference/interruption/errors.d.ts.map +0 -1
  130. package/dist/inference/interruption/errors.js +0 -1
  131. package/dist/inference/interruption/errors.js.map +0 -1
  132. package/dist/inference/interruption/http_transport.cjs +0 -57
  133. package/dist/inference/interruption/http_transport.cjs.map +0 -1
  134. package/dist/inference/interruption/http_transport.d.cts +0 -23
  135. package/dist/inference/interruption/http_transport.d.ts +0 -23
  136. package/dist/inference/interruption/http_transport.d.ts.map +0 -1
  137. package/dist/inference/interruption/http_transport.js +0 -33
  138. package/dist/inference/interruption/http_transport.js.map +0 -1
  139. package/dist/inference/interruption/index.cjs.map +0 -1
  140. package/dist/inference/interruption/index.d.cts +0 -5
  141. package/dist/inference/interruption/index.d.ts +0 -5
  142. package/dist/inference/interruption/index.d.ts.map +0 -1
  143. package/dist/inference/interruption/index.js +0 -7
  144. package/dist/inference/interruption/index.js.map +0 -1
  145. package/dist/inference/interruption/interruption.cjs +0 -85
  146. package/dist/inference/interruption/interruption.cjs.map +0 -1
  147. package/dist/inference/interruption/interruption.d.cts +0 -48
  148. package/dist/inference/interruption/interruption.d.ts +0 -48
  149. package/dist/inference/interruption/interruption.d.ts.map +0 -1
  150. package/dist/inference/interruption/interruption.js +0 -59
  151. package/dist/inference/interruption/interruption.js.map +0 -1
  152. package/dist/inference/utils.test.cjs +0 -20
  153. package/dist/inference/utils.test.cjs.map +0 -1
  154. package/dist/inference/utils.test.js +0 -19
  155. package/dist/inference/utils.test.js.map +0 -1
  156. package/dist/utils/ws_transport.cjs +0 -51
  157. package/dist/utils/ws_transport.cjs.map +0 -1
  158. package/dist/utils/ws_transport.d.cts +0 -9
  159. package/dist/utils/ws_transport.d.ts +0 -9
  160. package/dist/utils/ws_transport.d.ts.map +0 -1
  161. package/dist/utils/ws_transport.js +0 -17
  162. package/dist/utils/ws_transport.js.map +0 -1
  163. package/dist/utils/ws_transport.test.cjs +0 -212
  164. package/dist/utils/ws_transport.test.cjs.map +0 -1
  165. package/dist/utils/ws_transport.test.js +0 -211
  166. package/dist/utils/ws_transport.test.js.map +0 -1
  167. package/src/inference/interruption/AdaptiveInterruptionDetector.ts +0 -166
  168. package/src/inference/interruption/InterruptionStream.ts +0 -397
  169. package/src/inference/interruption/defaults.ts +0 -33
  170. package/src/inference/interruption/errors.ts +0 -0
  171. package/src/inference/interruption/http_transport.ts +0 -61
  172. package/src/inference/interruption/index.ts +0 -4
  173. package/src/inference/interruption/interruption.ts +0 -88
  174. package/src/inference/utils.test.ts +0 -31
  175. package/src/utils/ws_transport.test.ts +0 -282
  176. package/src/utils/ws_transport.ts +0 -22
@@ -6,7 +6,6 @@ import { type GenerationCreatedEvent, type InputSpeechStartedEvent, type InputSp
6
6
  import { STT, type SpeechEvent } from '../stt/stt.js';
7
7
  import { TTS } from '../tts/tts.js';
8
8
  import { Future, Task } from '../utils.js';
9
- import type { InterruptionEvent } from '../inference/interruption/interruption.js';
10
9
  import { VAD, type VADEvent } from '../vad.js';
11
10
  import type { Agent } from './agent.js';
12
11
  import { type AgentSession, type TurnDetectionMode } from './agent_session.js';
@@ -34,18 +33,6 @@ export declare class AgentActivity implements RecognitionHooks {
34
33
  /** @internal */
35
34
  _mainTask?: Task<void>;
36
35
  _userTurnCompletedTask?: Promise<void>;
37
- /**
38
- * Notify that agent started speaking.
39
- * This enables interruption detection in AudioRecognition.
40
- * @internal
41
- */
42
- notifyAgentSpeechStarted(): void;
43
- /**
44
- * Notify that agent stopped speaking.
45
- * This disables interruption detection in AudioRecognition.
46
- * @internal
47
- */
48
- notifyAgentSpeechEnded(): void;
49
36
  constructor(agent: Agent, agentSession: AgentSession);
50
37
  start(): Promise<void>;
51
38
  get currentSpeech(): SpeechHandle | undefined;
@@ -81,7 +68,6 @@ export declare class AgentActivity implements RecognitionHooks {
81
68
  onStartOfSpeech(_ev: VADEvent): void;
82
69
  onEndOfSpeech(ev: VADEvent): void;
83
70
  onVADInferenceDone(ev: VADEvent): void;
84
- onInterruption(ev: InterruptionEvent): void;
85
71
  onInterimTranscript(ev: SpeechEvent): void;
86
72
  onFinalTranscript(ev: SpeechEvent): void;
87
73
  onPreemptiveGeneration(info: PreemptiveGenerationInfo): void;
@@ -1 +1 @@
1
- {"version":3,"file":"agent_activity.d.ts","sourceRoot":"","sources":["../../src/voice/agent_activity.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,GAAG,EACH,aAAa,EAEb,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAazB,OAAO,EAAE,GAAG,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,GAAG,EAAiB,MAAM,e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,IAAI;IAiB1C,iBAAiB,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI;IAiBxC,sBAAsB,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI;IA0C5D,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,gBAAgB;IA4BlB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IA0CxD,eAAe,IAAI,WAAW;YAIhB,QAAQ;IAuCtB,OAAO,CAAC,cAAc;IAItB,aAAa,CAAC,OAAO,EAAE;QACrB,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,GAAG,YAAY;IAuGhB,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC;IA0BzB,OAAO,CAAC,mBAAmB;YAMb,iBAAiB;YAyHjB,OAAO;IA0HrB,OAAO,CAAC,sBAAsB,CAyX5B;IAEF,OAAO,CAAC,iBAAiB,CA2BrB;YAEU,sBAAsB;YAsBtB,2BAA2B;YAkc3B,iBAAiB;IAqD/B,OAAO,CAAC,cAAc;IAiBhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAQd,UAAU;IA2BlB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAyC7B"}
@@ -16,7 +16,6 @@ import { recordRealtimeMetrics, traceTypes, tracer } from "../telemetry/index.js
16
16
  import { splitWords } from "../tokenize/basic/word.js";
17
17
  import { TTS } from "../tts/tts.js";
18
18
  import { Future, Task, cancelAndWait, waitFor } from "../utils.js";
19
- import { InterruptionEventType } from "../inference/interruption/interruption.js";
20
19
  import { VAD } from "../vad.js";
21
20
  import { StopResponse, asyncLocalStorage } from "./agent.js";
22
21
  import {} from "./agent_session.js";
@@ -67,24 +66,6 @@ class AgentActivity {
67
66
  /** @internal */
68
67
  _mainTask;
69
68
  _userTurnCompletedTask;
70
- /**
71
- * Notify that agent started speaking.
72
- * This enables interruption detection in AudioRecognition.
73
- * @internal
74
- */
75
- notifyAgentSpeechStarted() {
76
- var _a;
77
- (_a = this.audioRecognition) == null ? void 0 : _a.onStartOfAgentSpeech();
78
- }
79
- /**
80
- * Notify that agent stopped speaking.
81
- * This disables interruption detection in AudioRecognition.
82
- * @internal
83
- */
84
- notifyAgentSpeechEnded() {
85
- var _a;
86
- (_a = this.audioRecognition) == null ? void 0 : _a.onEndOfAgentSpeech();
87
- }
88
69
  constructor(agent, agentSession) {
89
70
  this.agent = agent;
90
71
  this.agentSession = agentSession;
@@ -217,7 +198,6 @@ class AgentActivity {
217
198
  // Disable stt node if stt is not provided
218
199
  stt: this.stt ? (...args) => this.agent.sttNode(...args) : void 0,
219
200
  vad: this.vad,
220
- interruptionDetector: this.agentSession.interruptionDetector,
221
201
  turnDetector: typeof this.turnDetection === "string" ? void 0 : this.turnDetection,
222
202
  turnDetectionMode: this.turnDetectionMode,
223
203
  minEndpointingDelay: this.agentSession.options.minEndpointingDelay,
@@ -511,35 +491,6 @@ class AgentActivity {
511
491
  this._currentSpeech.interrupt();
512
492
  }
513
493
  }
514
- onInterruption(ev) {
515
- var _a, _b;
516
- if (ev.type !== InterruptionEventType.INTERRUPTION) {
517
- return;
518
- }
519
- this.logger.info(
520
- {
521
- probability: ev.probability,
522
- detectionDelay: ev.detectionDelay,
523
- totalDuration: ev.totalDuration
524
- },
525
- "adaptive interruption detected"
526
- );
527
- if (this.turnDetection === "manual" || this.turnDetection === "realtime_llm") {
528
- return;
529
- }
530
- if (this.llm instanceof RealtimeModel && this.llm.capabilities.turnDetection) {
531
- return;
532
- }
533
- (_a = this.realtimeSession) == null ? void 0 : _a.startUserActivity();
534
- if (this._currentSpeech && !this._currentSpeech.interrupted && this._currentSpeech.allowInterruptions) {
535
- this.logger.info(
536
- { "speech id": this._currentSpeech.id },
537
- "speech interrupted by adaptive interruption detector"
538
- );
539
- (_b = this.realtimeSession) == null ? void 0 : _b.interrupt();
540
- this._currentSpeech.interrupt();
541
- }
542
- }
543
494
  onInterimTranscript(ev) {
544
495
  if (this.llm instanceof RealtimeModel && this.llm.capabilities.userTranscription) {
545
496
  return;
@@ -1020,10 +971,12 @@ ${instructions}` : instructions,
1020
971
  replyAbortController
1021
972
  );
1022
973
  tasks.push(llmTask);
1023
- const [ttsTextInput, llmOutput] = llmGenData.textStream.tee();
1024
974
  let ttsTask = null;
1025
975
  let ttsStream = null;
976
+ let llmOutput;
1026
977
  if (audioOutput) {
978
+ const [ttsTextInput, textOutput] = llmGenData.textStream.tee();
979
+ llmOutput = textOutput;
1027
980
  [ttsTask, ttsStream] = performTTSInference(
1028
981
  (...args) => this.agent.ttsNode(...args),
1029
982
  ttsTextInput,
@@ -1031,6 +984,8 @@ ${instructions}` : instructions,
1031
984
  replyAbortController
1032
985
  );
1033
986
  tasks.push(ttsTask);
987
+ } else {
988
+ llmOutput = llmGenData.textStream;
1034
989
  }
1035
990
  await speechHandle.waitIfNotInterrupted([speechHandle._waitForScheduled()]);
1036
991
  if (newMessage && speechHandle.scheduled) {
@@ -1077,9 +1032,15 @@ ${instructions}` : instructions,
1077
1032
  } else {
1078
1033
  textOut == null ? void 0 : textOut.firstTextFut.await.finally(onFirstFrame);
1079
1034
  }
1080
- const onToolExecutionStarted = (_) => {
1035
+ const onToolExecutionStarted = (f) => {
1036
+ speechHandle._itemAdded([f]);
1037
+ this.agent._chatCtx.items.push(f);
1038
+ this.agentSession._toolItemsAdded([f]);
1081
1039
  };
1082
- const onToolExecutionCompleted = (_) => {
1040
+ const onToolExecutionCompleted = (out) => {
1041
+ if (out.toolCallOutput) {
1042
+ speechHandle._itemAdded([out.toolCallOutput]);
1043
+ }
1083
1044
  };
1084
1045
  const [executeToolsTask, toolOutput] = performToolExecutions({
1085
1046
  session: this.agentSession,
@@ -1139,6 +1100,7 @@ ${instructions}` : instructions,
1139
1100
  });
1140
1101
  chatCtx.insert(message);
1141
1102
  this.agent._chatCtx.insert(message);
1103
+ speechHandle._itemAdded([message]);
1142
1104
  this.agentSession._conversationItemAdded(message);
1143
1105
  }
1144
1106
  if (this.agentSession.agentState === "speaking") {
@@ -1162,6 +1124,7 @@ ${instructions}` : instructions,
1162
1124
  });
1163
1125
  chatCtx.insert(message);
1164
1126
  this.agent._chatCtx.insert(message);
1127
+ speechHandle._itemAdded([message]);
1165
1128
  this.agentSession._conversationItemAdded(message);
1166
1129
  this.logger.info(
1167
1130
  { speech_id: speechHandle.id, message: textOut.text },
@@ -1230,24 +1193,12 @@ ${instructions}` : instructions,
1230
1193
  ];
1231
1194
  if (shouldGenerateToolReply) {
1232
1195
  chatCtx.insert(toolMessages);
1233
- const handle = SpeechHandle.create({
1234
- allowInterruptions: speechHandle.allowInterruptions,
1235
- stepIndex: speechHandle._stepIndex + 1,
1236
- parent: speechHandle
1237
- });
1238
- this.agentSession.emit(
1239
- AgentSessionEventTypes.SpeechCreated,
1240
- createSpeechCreatedEvent({
1241
- userInitiated: false,
1242
- source: "tool_response",
1243
- speechHandle: handle
1244
- })
1245
- );
1196
+ speechHandle._numSteps += 1;
1246
1197
  const respondToolChoice = draining || modelSettings.toolChoice === "none" ? "none" : "auto";
1247
1198
  const toolResponseTask = this.createSpeechTask({
1248
1199
  task: Task.from(
1249
1200
  () => this.pipelineReplyTask(
1250
- handle,
1201
+ speechHandle,
1251
1202
  chatCtx,
1252
1203
  toolCtx,
1253
1204
  { toolChoice: respondToolChoice },
@@ -1257,11 +1208,11 @@ ${instructions}` : instructions,
1257
1208
  toolMessages
1258
1209
  )
1259
1210
  ),
1260
- ownedSpeechHandle: handle,
1211
+ ownedSpeechHandle: speechHandle,
1261
1212
  name: "AgentActivity.pipelineReply"
1262
1213
  });
1263
1214
  toolResponseTask.finally(() => this.onPipelineReplyDone());
1264
- this.scheduleSpeech(handle, SpeechHandle.SPEECH_PRIORITY_NORMAL, true);
1215
+ this.scheduleSpeech(speechHandle, SpeechHandle.SPEECH_PRIORITY_NORMAL, true);
1265
1216
  } else if (functionToolsExecutedEvent.functionCallOutputs.length > 0) {
1266
1217
  for (const msg of toolMessages) {
1267
1218
  msg.createdAt = replyStartedAt;