From 04fab7567e65f89820af9f240f11d14301d2995a Mon Sep 17 00:00:00 2001 From: g Date: Thu, 23 Apr 2026 16:47:00 +0800 Subject: [PATCH] fix: filter tool arguments to match schema parameters LLM may return extra parameters (e.g., 'description') that are not accepted by tool.execute(). Filter arguments to only include parameters defined in the tool's schema. Co-Authored-By: Claude Opus 4.7 --- mini_agent/agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mini_agent/agent.py b/mini_agent/agent.py index b7d7feab..c84ba882 100644 --- a/mini_agent/agent.py +++ b/mini_agent/agent.py @@ -460,7 +460,10 @@ async def run(self, cancel_event: Optional[asyncio.Event] = None) -> str: else: try: tool = self.tools[function_name] - result = await tool.execute(**arguments) + # Filter arguments to only include parameters defined in tool schema + valid_params = tool.parameters.get('properties', {}).keys() + filtered_args = {k: v for k, v in arguments.items() if k in valid_params} + result = await tool.execute(**filtered_args) except Exception as e: # Catch all exceptions during tool execution, convert to failed ToolResult import traceback