fix(frontend): render all tool calls in the frontend #796 (#797)

This commit is contained in:
Willem Jiang
2026-01-05 22:24:52 +08:00
committed by GitHub
parent 275aab9d42
commit 7ebbb53b57

View File

@@ -104,21 +104,24 @@ const ActivityListItem = React.memo(({ messageId }: { messageId: string }) => {
const message = useMessage(messageId); const message = useMessage(messageId);
if (message) { if (message) {
if (!message.isStreaming && message.toolCalls?.length) { if (!message.isStreaming && message.toolCalls?.length) {
for (const toolCall of message.toolCalls) { const toolCallComponents = message.toolCalls
if (typeof toolCall.result === "string" && toolCall.result?.startsWith("Error")) { .filter(toolCall => !(typeof toolCall.result === "string" && toolCall.result?.startsWith("Error")))
return null; .map(toolCall => {
} if (toolCall.name === "web_search") {
if (toolCall.name === "web_search") { return <WebSearchToolCall key={toolCall.id} toolCall={toolCall} />;
return <WebSearchToolCall key={toolCall.id} toolCall={toolCall} />; } else if (toolCall.name === "crawl_tool") {
} else if (toolCall.name === "crawl_tool") { return <CrawlToolCall key={toolCall.id} toolCall={toolCall} />;
return <CrawlToolCall key={toolCall.id} toolCall={toolCall} />; } else if (toolCall.name === "python_repl_tool") {
} else if (toolCall.name === "python_repl_tool") { return <PythonToolCall key={toolCall.id} toolCall={toolCall} />;
return <PythonToolCall key={toolCall.id} toolCall={toolCall} />; } else if (toolCall.name === "local_search_tool") {
} else if (toolCall.name === "local_search_tool") { return <RetrieverToolCall key={toolCall.id} toolCall={toolCall} />;
return <RetrieverToolCall key={toolCall.id} toolCall={toolCall} />; } else {
} else { return <MCPToolCall key={toolCall.id} toolCall={toolCall} />;
return <MCPToolCall key={toolCall.id} toolCall={toolCall} />; }
} });
if (toolCallComponents.length > 0) {
return <>{toolCallComponents}</>;
} }
} }
} }