fix(core): check for "toolCall" type in hasToolUse() to match pi-ai types

The hasToolUse() function was checking for "tool_use" (raw Anthropic format)
but pi-ai normalizes tool call blocks to type "toolCall". This made tool
narration non-functional in the ChannelManager (Desktop/embedded) path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-02-14 03:32:16 +08:00
parent d1570698ac
commit ef8b38899a

View file

@ -16,7 +16,7 @@ export function hasToolUse(message: AgentMessage | undefined): boolean {
if (!message || typeof message !== "object" || !("content" in message)) return false;
const content = (message as { content?: Array<{ type: string }> }).content;
if (!Array.isArray(content)) return false;
return content.some((c) => c.type === "tool_use");
return content.some((c) => c.type === "toolCall" || c.type === "tool_use");
}
/** Extract thinking/reasoning content from an AgentMessage */