{"record":{"id":"ef65f767190d3ebb","repo":"huggingface/smolagents","slug":"error-executing-tool-tool-name-with-arguments","errorCode":null,"errorMessage":"Error executing tool '{tool_name}' with arguments {str(arguments)}: {type(e).__name__}: {e}","messagePattern":"Error executing tool '(.+?)' with arguments (.+?): (.+?): (.+?)","errorType":"exception","errorClass":"AgentToolExecutionError","httpStatus":null,"severity":"error","filePath":"src/smolagents/agents.py","lineNumber":1481,"sourceCode":"        # Check if the tool exists\n        available_tools = {**self.tools, **self.managed_agents}\n        if tool_name not in available_tools:\n            raise AgentToolExecutionError(\n                f\"Unknown tool {tool_name}, should be one of: {', '.join(available_tools)}.\", self.logger\n            )\n\n        # Get the tool and substitute state variables in arguments\n        tool = available_tools[tool_name]\n        arguments = self._substitute_state_variables(arguments)\n        is_managed_agent = tool_name in self.managed_agents\n\n        try:\n            validate_tool_arguments(tool, arguments)\n        except (ValueError, TypeError) as e:\n            raise AgentToolCallError(str(e), self.logger) from e\n        except Exception as e:\n            error_msg = f\"Error executing tool '{tool_name}' with arguments {str(arguments)}: {type(e).__name__}: {e}\"\n            raise AgentToolExecutionError(error_msg, self.logger) from e\n\n        try:\n            # Call tool with appropriate arguments\n            if isinstance(arguments, dict):\n                return tool(**arguments) if is_managed_agent else tool(**arguments, sanitize_inputs_outputs=True)\n            else:\n                return tool(arguments) if is_managed_agent else tool(arguments, sanitize_inputs_outputs=True)\n\n        except Exception as e:\n            # Handle execution errors\n            if is_managed_agent:\n                error_msg = (\n                    f\"Error executing request to team member '{tool_name}' with arguments {str(arguments)}: {e}\\n\"\n                    \"Please try again or request to another team member\"\n                )\n            else:\n                error_msg = (\n                    f\"Error executing tool '{tool_name}' with arguments {str(arguments)}: {type(e).__name__}: {e}\\n\"","sourceCodeStart":1463,"sourceCodeEnd":1499,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/agents.py#L1463-L1499","documentation":"If validate_tool_arguments raises anything other than ValueError/TypeError (e.g. an introspection error while building the JSON schema for the tool's signature), execute_tool_call wraps it into AgentToolExecutionError with a message naming the tool, arguments, and exception type. It signals the tool itself is not cleanly introspectable rather than the arguments being wrong.","triggerScenarios":"Passing a tool whose signature contains types that break schema generation (unresolvable forward references, exotic annotations) — the exception escapes validation as a non-ValueError/TypeError.","commonSituations":"Tools defined with `from __future__ import annotations` and unresolved string annotations; tools using custom classes as parameter types; version mismatches in the inspection layer.","solutions":["Read the exception type in the message; simplify the tool signature to plain builtin types (str, int, bool, list, dict).","Resolve forward references or move custom type imports to module level so introspection succeeds.","Wrap the raw function in smolagents' @tool decorator with simple annotations."],"exampleFix":"# before\ndef process(items: list[MyCustomType]) -> str: ...\n\n# after\ndef process(items_json: str) -> str:\n    items = json.loads(items_json)\n    ...","handlingStrategy":"validation","validationCode":"import inspect\nfrom smolagents.tool_validation import validate_tool_arguments\n\ntry:\n    validate_tool_arguments(tool, sample_args)\nexcept Exception as e:\n    if not isinstance(e, (ValueError, TypeError)):\n        print('tool signature not introspectable:', inspect.signature(tool))","typeGuard":null,"tryCatchPattern":"from smolagents.exceptions import AgentToolExecutionError\n\ntry:\n    result = agent.run(task)\nexcept AgentToolExecutionError as e:\n    if 'Error executing tool' in str(e):\n        # inspect type name in message; fix tool signature if introspection-related\n        raise","preventionTips":["Keep tool parameter annotations to builtin types.","Avoid unresolvable forward references in tool signatures.","Test each tool with validate_tool_arguments before wiring into an agent."],"tags":["smolagents","tool-introspection","schema-generation","type-annotations"],"backgroundTag":"tool-schema-generation-failed","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}