@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.
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/inference/utils.cjs +2 -15
- package/dist/inference/utils.cjs.map +1 -1
- package/dist/inference/utils.d.cts +0 -1
- package/dist/inference/utils.d.ts +0 -1
- package/dist/inference/utils.d.ts.map +1 -1
- package/dist/inference/utils.js +1 -13
- package/dist/inference/utils.js.map +1 -1
- package/dist/stream/stream_channel.cjs +0 -3
- package/dist/stream/stream_channel.cjs.map +1 -1
- package/dist/stream/stream_channel.d.cts +2 -3
- package/dist/stream/stream_channel.d.ts +2 -3
- package/dist/stream/stream_channel.d.ts.map +1 -1
- package/dist/stream/stream_channel.js +0 -3
- package/dist/stream/stream_channel.js.map +1 -1
- package/dist/telemetry/trace_types.cjs +0 -15
- package/dist/telemetry/trace_types.cjs.map +1 -1
- package/dist/telemetry/trace_types.d.cts +0 -5
- package/dist/telemetry/trace_types.d.ts +0 -5
- package/dist/telemetry/trace_types.d.ts.map +1 -1
- package/dist/telemetry/trace_types.js +0 -10
- package/dist/telemetry/trace_types.js.map +1 -1
- package/dist/voice/agent_activity.cjs +19 -68
- package/dist/voice/agent_activity.cjs.map +1 -1
- package/dist/voice/agent_activity.d.cts +0 -14
- package/dist/voice/agent_activity.d.ts +0 -14
- package/dist/voice/agent_activity.d.ts.map +1 -1
- package/dist/voice/agent_activity.js +19 -68
- package/dist/voice/agent_activity.js.map +1 -1
- package/dist/voice/agent_session.cjs +65 -37
- package/dist/voice/agent_session.cjs.map +1 -1
- package/dist/voice/agent_session.d.cts +25 -4
- package/dist/voice/agent_session.d.ts +25 -4
- package/dist/voice/agent_session.d.ts.map +1 -1
- package/dist/voice/agent_session.js +65 -37
- package/dist/voice/agent_session.js.map +1 -1
- package/dist/voice/audio_recognition.cjs +2 -124
- package/dist/voice/audio_recognition.cjs.map +1 -1
- package/dist/voice/audio_recognition.d.cts +1 -32
- package/dist/voice/audio_recognition.d.ts +1 -32
- package/dist/voice/audio_recognition.d.ts.map +1 -1
- package/dist/voice/audio_recognition.js +2 -127
- package/dist/voice/audio_recognition.js.map +1 -1
- package/dist/voice/index.cjs +14 -1
- package/dist/voice/index.cjs.map +1 -1
- package/dist/voice/index.d.cts +1 -0
- package/dist/voice/index.d.ts +1 -0
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +3 -1
- package/dist/voice/index.js.map +1 -1
- package/dist/voice/room_io/room_io.cjs +1 -0
- package/dist/voice/room_io/room_io.cjs.map +1 -1
- package/dist/voice/room_io/room_io.d.ts.map +1 -1
- package/dist/voice/room_io/room_io.js +1 -0
- package/dist/voice/room_io/room_io.js.map +1 -1
- package/dist/voice/speech_handle.cjs +12 -3
- package/dist/voice/speech_handle.cjs.map +1 -1
- package/dist/voice/speech_handle.d.cts +12 -2
- package/dist/voice/speech_handle.d.ts +12 -2
- package/dist/voice/speech_handle.d.ts.map +1 -1
- package/dist/voice/speech_handle.js +10 -2
- package/dist/voice/speech_handle.js.map +1 -1
- package/dist/voice/testing/index.cjs +54 -0
- package/dist/voice/testing/index.cjs.map +1 -0
- package/dist/voice/testing/index.d.cts +20 -0
- package/dist/voice/testing/index.d.ts +20 -0
- package/dist/voice/testing/index.d.ts.map +1 -0
- package/dist/voice/testing/index.js +33 -0
- package/dist/voice/testing/index.js.map +1 -0
- package/dist/voice/testing/run_result.cjs +766 -0
- package/dist/voice/testing/run_result.cjs.map +1 -0
- package/dist/voice/testing/run_result.d.cts +374 -0
- package/dist/voice/testing/run_result.d.ts +374 -0
- package/dist/voice/testing/run_result.d.ts.map +1 -0
- package/dist/voice/testing/run_result.js +739 -0
- package/dist/voice/testing/run_result.js.map +1 -0
- package/dist/{inference/interruption/index.cjs → voice/testing/types.cjs} +24 -12
- package/dist/voice/testing/types.cjs.map +1 -0
- package/dist/voice/testing/types.d.cts +83 -0
- package/dist/voice/testing/types.d.ts +83 -0
- package/dist/voice/testing/types.d.ts.map +1 -0
- package/dist/voice/testing/types.js +19 -0
- package/dist/voice/testing/types.js.map +1 -0
- package/package.json +3 -4
- package/src/index.ts +0 -2
- package/src/inference/utils.ts +0 -15
- package/src/stream/stream_channel.ts +2 -6
- package/src/telemetry/trace_types.ts +0 -7
- package/src/voice/agent_activity.ts +24 -83
- package/src/voice/agent_session.ts +74 -49
- package/src/voice/audio_recognition.ts +1 -161
- package/src/voice/index.ts +1 -0
- package/src/voice/room_io/room_io.ts +1 -0
- package/src/voice/speech_handle.ts +24 -4
- package/src/voice/testing/index.ts +50 -0
- package/src/voice/testing/run_result.ts +937 -0
- package/src/voice/testing/types.ts +118 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs +0 -152
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs.map +0 -1
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.cts +0 -50
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts +0 -50
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts.map +0 -1
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js +0 -125
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js.map +0 -1
- package/dist/inference/interruption/InterruptionStream.cjs +0 -310
- package/dist/inference/interruption/InterruptionStream.cjs.map +0 -1
- package/dist/inference/interruption/InterruptionStream.d.cts +0 -57
- package/dist/inference/interruption/InterruptionStream.d.ts +0 -57
- package/dist/inference/interruption/InterruptionStream.d.ts.map +0 -1
- package/dist/inference/interruption/InterruptionStream.js +0 -288
- package/dist/inference/interruption/InterruptionStream.js.map +0 -1
- package/dist/inference/interruption/defaults.cjs +0 -76
- package/dist/inference/interruption/defaults.cjs.map +0 -1
- package/dist/inference/interruption/defaults.d.cts +0 -14
- package/dist/inference/interruption/defaults.d.ts +0 -14
- package/dist/inference/interruption/defaults.d.ts.map +0 -1
- package/dist/inference/interruption/defaults.js +0 -42
- package/dist/inference/interruption/defaults.js.map +0 -1
- package/dist/inference/interruption/errors.cjs +0 -2
- package/dist/inference/interruption/errors.cjs.map +0 -1
- package/dist/inference/interruption/errors.d.cts +0 -2
- package/dist/inference/interruption/errors.d.ts +0 -2
- package/dist/inference/interruption/errors.d.ts.map +0 -1
- package/dist/inference/interruption/errors.js +0 -1
- package/dist/inference/interruption/errors.js.map +0 -1
- package/dist/inference/interruption/http_transport.cjs +0 -57
- package/dist/inference/interruption/http_transport.cjs.map +0 -1
- package/dist/inference/interruption/http_transport.d.cts +0 -23
- package/dist/inference/interruption/http_transport.d.ts +0 -23
- package/dist/inference/interruption/http_transport.d.ts.map +0 -1
- package/dist/inference/interruption/http_transport.js +0 -33
- package/dist/inference/interruption/http_transport.js.map +0 -1
- package/dist/inference/interruption/index.cjs.map +0 -1
- package/dist/inference/interruption/index.d.cts +0 -5
- package/dist/inference/interruption/index.d.ts +0 -5
- package/dist/inference/interruption/index.d.ts.map +0 -1
- package/dist/inference/interruption/index.js +0 -7
- package/dist/inference/interruption/index.js.map +0 -1
- package/dist/inference/interruption/interruption.cjs +0 -85
- package/dist/inference/interruption/interruption.cjs.map +0 -1
- package/dist/inference/interruption/interruption.d.cts +0 -48
- package/dist/inference/interruption/interruption.d.ts +0 -48
- package/dist/inference/interruption/interruption.d.ts.map +0 -1
- package/dist/inference/interruption/interruption.js +0 -59
- package/dist/inference/interruption/interruption.js.map +0 -1
- package/dist/inference/utils.test.cjs +0 -20
- package/dist/inference/utils.test.cjs.map +0 -1
- package/dist/inference/utils.test.js +0 -19
- package/dist/inference/utils.test.js.map +0 -1
- package/dist/utils/ws_transport.cjs +0 -51
- package/dist/utils/ws_transport.cjs.map +0 -1
- package/dist/utils/ws_transport.d.cts +0 -9
- package/dist/utils/ws_transport.d.ts +0 -9
- package/dist/utils/ws_transport.d.ts.map +0 -1
- package/dist/utils/ws_transport.js +0 -17
- package/dist/utils/ws_transport.js.map +0 -1
- package/dist/utils/ws_transport.test.cjs +0 -212
- package/dist/utils/ws_transport.test.cjs.map +0 -1
- package/dist/utils/ws_transport.test.js +0 -211
- package/dist/utils/ws_transport.test.js.map +0 -1
- package/src/inference/interruption/AdaptiveInterruptionDetector.ts +0 -166
- package/src/inference/interruption/InterruptionStream.ts +0 -397
- package/src/inference/interruption/defaults.ts +0 -33
- package/src/inference/interruption/errors.ts +0 -0
- package/src/inference/interruption/http_transport.ts +0 -61
- package/src/inference/interruption/index.ts +0 -4
- package/src/inference/interruption/interruption.ts +0 -88
- package/src/inference/utils.test.ts +0 -31
- package/src/utils/ws_transport.test.ts +0 -282
- 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,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,IAAI,EAA0B,MAAM,aAAa,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"agent_activity.d.ts","sourceRoot":"","sources":["../../src/voice/agent_activity.ts"],"names":[],"mappings":";A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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
|
-
|
|
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
|
-
|
|
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:
|
|
1211
|
+
ownedSpeechHandle: speechHandle,
|
|
1261
1212
|
name: "AgentActivity.pipelineReply"
|
|
1262
1213
|
});
|
|
1263
1214
|
toolResponseTask.finally(() => this.onPipelineReplyDone());
|
|
1264
|
-
this.scheduleSpeech(
|
|
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;
|