Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance tool error handling to allow agent recovery #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hiromesh
Copy link

feat: Enhance tool error handling to allow agent recovery

Summary

This PR enhances the tool error handling mechanism to allow agents to detect and respond to tool call failures instead of having executions terminate on errors.

Changes

  • Add is_error flag to ToolCallOutputItem class to indicate when a tool call failed
  • Modify run_single_tool function to catch exceptions and return error information instead of propagating exceptions
  • Ensure error information is included in agent's conversation history for LLM context
  • Add comprehensive test coverage for error handling functionality

Benefits

  • Agents can now continue execution after tool failures
  • LLMs can learn from error messages and attempt alternative approaches
  • Improves agent resilience by allowing recovery from transient tool errors
  • Enables more sophisticated error handling patterns in agent workflows

Testing

Added a new test case that verifies:

  • Tool errors are properly caught and flagged
  • Error messages are correctly returned to the agent

This change is backward compatible and all existing tests pass.

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.

1 participant