From 27b334aceb74d291fe70c5bfa63a6691f3140334 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Tue, 19 May 2026 15:25:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=98=B2=E6=AD=A2=20MCP=20=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E7=94=A8=E5=A4=B1=E8=B4=A5=E5=90=8E=E7=9A=84?= =?UTF-8?q?=20SearchExtraTools/ExecuteExtraTool=20=E6=AD=BB=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/builtin-tools/src/tools/ExecuteTool/prompt.ts | 9 ++++++++- .../src/tools/SearchExtraToolsTool/prompt.ts | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/builtin-tools/src/tools/ExecuteTool/prompt.ts b/packages/builtin-tools/src/tools/ExecuteTool/prompt.ts index 0a3e7bfa2..f4604e9e9 100644 --- a/packages/builtin-tools/src/tools/ExecuteTool/prompt.ts +++ b/packages/builtin-tools/src/tools/ExecuteTool/prompt.ts @@ -15,5 +15,12 @@ Inputs: - tool_name: The exact name of the target tool (string) - params: The parameters to pass to the target tool (object) -If the tool is not found, an error message will be returned suggesting to use SearchExtraTools to discover available tools.` +If the tool is not found, an error message will be returned suggesting to use SearchExtraTools to discover available tools. + +FAILURE HANDLING — CRITICAL: +If ExecuteExtraTool returns an error (missing parameters, validation error, permission denied, tool not found, or any other failure), you MUST: +1. Stop immediately — do NOT retry the same tool. +2. Do NOT call SearchExtraTools again for the same tool name. +3. Inform the user about the failure and suggest alternatives. +Never enter a SearchExtraTools → ExecuteExtraTool retry loop for the same tool.` } diff --git a/packages/builtin-tools/src/tools/SearchExtraToolsTool/prompt.ts b/packages/builtin-tools/src/tools/SearchExtraToolsTool/prompt.ts index 6f66c192a..298f9f2b0 100644 --- a/packages/builtin-tools/src/tools/SearchExtraToolsTool/prompt.ts +++ b/packages/builtin-tools/src/tools/SearchExtraToolsTool/prompt.ts @@ -27,6 +27,9 @@ const PROMPT_TAIL = ` Returns matching tool names. IMPORTANT: ExecuteExtraTool is always available in your tool list. After this search returns tool names, you MUST call ExecuteExtraTool with {"tool_name": "", "params": {...}} to invoke the deferred tool. This is the ONLY way to execute deferred tools — do not read source code or analyze whether the tool is callable, just use ExecuteExtraTool directly. +FAILURE RETRY POLICY: +If ExecuteExtraTool fails for a tool, do NOT search for that same tool again. Searching again will not fix the failure — it will only repeat the same error in a loop. Stop immediately and inform the user about the failure. + Query forms: - "select:CronCreate,Snip" — fetch these exact tools by name - "discover:schedule cron job" — pure discovery, returns tool info (name, description) without loading. Use when you want to understand available tools before deciding which to invoke.