fix: always emit tool events
This commit is contained in:
@@ -513,10 +513,9 @@ export async function runCommandReply(
|
|||||||
let pendingMetas: string[] = [];
|
let pendingMetas: string[] = [];
|
||||||
let pendingTimer: NodeJS.Timeout | null = null;
|
let pendingTimer: NodeJS.Timeout | null = null;
|
||||||
let streamedAny = false;
|
let streamedAny = false;
|
||||||
const enableToolStreaming = verboseLevel === "on";
|
|
||||||
const toolMetaById = new Map<string, string | undefined>();
|
const toolMetaById = new Map<string, string | undefined>();
|
||||||
const flushPendingTool = () => {
|
const flushPendingTool = () => {
|
||||||
if (!onPartialReply || !enableToolStreaming) return;
|
if (!onPartialReply) return;
|
||||||
if (!pendingToolName && pendingMetas.length === 0) return;
|
if (!pendingToolName && pendingMetas.length === 0) return;
|
||||||
const text = formatToolAggregate(pendingToolName, pendingMetas);
|
const text = formatToolAggregate(pendingToolName, pendingMetas);
|
||||||
const { text: cleanedText, mediaUrls: mediaFound } =
|
const { text: cleanedText, mediaUrls: mediaFound } =
|
||||||
@@ -603,7 +602,7 @@ export async function runCommandReply(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forward tool lifecycle events to the agent bus.
|
// Forward tool lifecycle events to the agent bus.
|
||||||
if (enableToolStreaming && ev.type === "tool_execution_start") {
|
if (ev.type === "tool_execution_start") {
|
||||||
emitAgentEvent({
|
emitAgentEvent({
|
||||||
runId,
|
runId,
|
||||||
stream: "tool",
|
stream: "tool",
|
||||||
@@ -625,7 +624,6 @@ export async function runCommandReply(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
enableToolStreaming &&
|
|
||||||
(ev.type === "message" || ev.type === "message_end") &&
|
(ev.type === "message" || ev.type === "message_end") &&
|
||||||
ev.message?.role === "tool_result" &&
|
ev.message?.role === "tool_result" &&
|
||||||
Array.isArray(ev.message.content)
|
Array.isArray(ev.message.content)
|
||||||
|
|||||||
Reference in New Issue
Block a user