Skip to content

Missing tool and tool exception handling #251

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions python/src/multi_agent_orchestrator/utils/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ async def tool_handler(self, provider_type, response: Any, _conversation: list[d
)

# Process the tool use
result = await self._process_tool(tool_name, input_data)
try:
result = await self._process_tool(tool_name, input_data)
except Exception as e:
result = str(e)

# Create tool result
tool_result = AgentToolResult(tool_id, result)
Expand Down Expand Up @@ -243,7 +246,9 @@ def _process_tool(self, tool_name, input_data):
tool = next(tool for tool in self.tools if tool.name == tool_name)
return tool.func(**input_data)
except StopIteration:
return (f"Tool '{tool_name}' not found")
raise ValueError(f"Tool '{tool_name}' not found")
except Exception as e:
raise Exception(f"Tool '{tool_name}' returned an error: {str(e)}")

def to_claude_format(self) -> list[dict[str, Any]]:
"""Convert all tools to Claude format"""
Expand Down