Skip to content

fix: Enhanced error handling for tool not found errors (v1.3)#1041

Closed
gdeyoung wants to merge 2 commits intoagent0ai:mainfrom
gdeyoung:fix/enhanced-error-handling-v1.3
Closed

fix: Enhanced error handling for tool not found errors (v1.3)#1041
gdeyoung wants to merge 2 commits intoagent0ai:mainfrom
gdeyoung:fix/enhanced-error-handling-v1.3

Conversation

@gdeyoung
Copy link
Copy Markdown
Contributor

Summary

This PR adds enhanced error handling for when a tool is not found in agent.py.

Changes

  • Added code to build a list of available tools before generating the error message
  • Improved error message now shows available tools to help users debug tool-related issues

Testing

This is v1.3 of the patch series. Previous patches:

  • v1.0: JSON malformation fixes
  • v1.1: tool_args TypeError fix
  • v1.2: HandledException shadowing fix

Notes

This fix helps users understand which tools are available when they encounter a tool not found error, making debugging easier.

gdeyoung and others added 2 commits February 14, 2026 18:30
- 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.
@longman391
Copy link
Copy Markdown

+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.

@gdeyoung gdeyoung closed this Apr 6, 2026
@gdeyoung gdeyoung deleted the fix/enhanced-error-handling-v1.3 branch April 6, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants