feat: add realtime subagent status report

This commit is contained in:
Henry Li
2026-02-08 22:43:51 +08:00
parent 808e028338
commit 010aba1e28
8 changed files with 91 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
import type { ToolCall } from "@langchain/core/messages";
import type { AIMessage } from "@langchain/langgraph-sdk";
import type { Translations } from "../i18n";
import { hasToolCalls } from "../messages/utils";
export function explainLastToolCall(message: AIMessage, t: Translations) {
if (hasToolCalls(message)) {
const lastToolCall = message.tool_calls![message.tool_calls!.length - 1]!;
return explainToolCall(lastToolCall, t);
}
return t.common.thinking;
}
export function explainToolCall(toolCall: ToolCall, t: Translations) {
if (toolCall.name === "web_search" || toolCall.name === "image_search") {
return t.toolCalls.searchFor(toolCall.args.query);
} else if (toolCall.name === "web_fetch") {
return t.toolCalls.viewWebPage;
} else if (toolCall.name === "present_files") {
return t.toolCalls.presentFiles;
} else if (toolCall.name === "write_todos") {
return t.toolCalls.writeTodos;
} else if (toolCall.args.description) {
return toolCall.args.description;
} else {
return t.toolCalls.useTool(toolCall.name);
}
}