fix: Enhanced error handling for tool not found errors (v1.3)#1041
fix: Enhanced error handling for tool not found errors (v1.3)#1041gdeyoung wants to merge 2 commits intoagent0ai:mainfrom
Conversation
- Fixed rfind bug in extract_tools.py - proper nested brace tracking - Fixed escape handling for escaped quotes in JSON strings - Added HandledException class for graceful loop termination - Added consecutive_misformat counter (5 attempt limit) - Fixed tool_args TypeError - ensure dict before unpacking
Adds improved error message that lists available tools when a tool cannot be found, helping users debug tool-related issues more easily. This is v1.3 of the patch series.
|
+1 on this. The current Unknown tool handler in unknown.py calls get_tools_prompt() which only lists built-in tools — it doesn't include MCP tools. So when an MCP tool call fails, the error message tells the LLM 'here are your available tools' with MCP tools missing from that list, which reinforces the LLM's belief that MCP tools don't exist. This creates a negative feedback loop. This PR's approach of building a proper available tools list before generating the error would help, especially if it also includes MCP tools from MCPConfig.get_instance(). Confirmed this is a real issue — in my instance, MCP tools (Todoist, WorkIQ) are listed in the system prompt but the agent frequently fails to use them, falling through to Unknown and then receiving an error that only shows built-in tools. |
Summary
This PR adds enhanced error handling for when a tool is not found in agent.py.
Changes
Testing
This is v1.3 of the patch series. Previous patches:
Notes
This fix helps users understand which tools are available when they encounter a tool not found error, making debugging easier.