fix: 防止 MCP 工具调用失败后的 SearchExtraTools/ExecuteExtraTool 死循环

This commit is contained in:
claude-code-best 2026-05-19 15:25:11 +08:00 committed by James Feng
parent 8f01d5cc59
commit b9fcd991cc
2 changed files with 9 additions and 3 deletions

View File

@ -32,6 +32,12 @@ Example — MCP tool:
- tool_name: Exact name of the target tool (string, e.g. "CronCreate", "mcp__slack__send_message")
- params: Object with the target tool's parameters. Check the tool's schema from SearchExtraTools discover: response.
## Failure handling
If this tool returns an error, do NOT retry or re-search. Tell the user what failed and suggest alternatives.`
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.`
}

View File

@ -57,7 +57,7 @@ If you don't know the exact tool name, use keyword search first:
- "+slack send" require "slack" in the name, rank by remaining terms
## Failure policy
If ExecuteExtraTool fails, do NOT re-search for the same tool it will loop. Stop and tell the user what failed.`
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.`
/**
* Check if a tool should be deferred (requires SearchExtraTools to load).