From 3350c3e2e52b470c78473dd49427644d32a613d9 Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 15:16:23 +0800 Subject: [PATCH] fix(GeminiAPIClient, mcp-tools): enhance tool call handling and lookup logic (#8009) * fix(GeminiAPIClient, mcp-tools): enhance tool call handling and lookup logic * fix: unuse log --- src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts | 7 +++++++ src/renderer/src/utils/mcp-tools.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts index 0f1bad0bf8..d32564d962 100644 --- a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts +++ b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts @@ -593,6 +593,13 @@ export class GeminiAPIClient extends BaseApiClient< } } as LLMWebSearchCompleteChunk) } + if (toolCalls.length > 0) { + controller.enqueue({ + type: ChunkType.MCP_TOOL_CREATED, + tool_calls: [...toolCalls] + }) + toolCalls.length = 0 + } controller.enqueue({ type: ChunkType.LLM_RESPONSE_COMPLETE, response: { diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index b39d9b6bc3..4b7a2e4735 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -391,7 +391,7 @@ export function geminiFunctionCallToMcpTool( ): MCPTool | undefined { if (!toolCall) return undefined if (!mcpTools) return undefined - const tool = mcpTools.find((tool) => tool.id === toolCall.name) + const tool = mcpTools.find((tool) => tool.id === toolCall.name || tool.name === toolCall.name) if (!tool) { return undefined }