{"record":{"id":"46ecf4a20bbc55b7","repo":"huggingface/smolagents","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"AgentToolCallError","httpStatus":null,"severity":"error","filePath":"src/smolagents/agents.py","lineNumber":1478,"sourceCode":"            tool_name (`str`): Name of the tool or managed agent to execute.\n            arguments (dict[str, str] | str): Arguments passed to the tool call.\n        \"\"\"\n        # 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                )","sourceCodeStart":1460,"sourceCodeEnd":1496,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/agents.py#L1460-L1496","documentation":"execute_tool_call first validates arguments via validate_tool_arguments. ValueError/TypeError from validation (missing required args, wrong types) are re-raised as AgentToolCallError with the validator's message; any other exception during validation becomes AgentToolExecutionError. These are fed back to the model so it can correct its arguments.","triggerScenarios":"The model calls a tool with a missing required parameter, an extra parameter, or wrongly typed arguments (e.g. passing a string where an int is declared), and validate_tool_arguments raises ValueError/TypeError.","commonSituations":"Tool signatures with required params the model doesn't reliably fill; type-annotated tools (forward refs, Pydantic types) the validator can't introspect; models with weak schema adherence.","solutions":["Read the message — it states which argument failed validation; adjust the tool's defaults/types so the model can succeed.","Give required parameters sensible defaults or make the docstring examples explicit about format.","Retry the run — the AgentToolCallError observation is appended to memory and the model usually corrects the call."],"exampleFix":"# before\ndef get_weather(city: str, units: str): ...  # model omits 'units'\n\n# after\ndef get_weather(city: str, units: str = 'celsius'): ...","handlingStrategy":"validation","validationCode":"from smolagents.tool_validation import validate_tool_arguments\n\n# dry-run validation before the agent loop (tool + sample args)\ntry:\n    validate_tool_arguments(tool, expected_args)\nexcept (ValueError, TypeError) as e:\n    print('adjust defaults:', e)","typeGuard":null,"tryCatchPattern":"from smolagents.exceptions import AgentToolCallError\n\ntry:\n    result = agent.run(task)\nexcept AgentToolCallError:\n    result = agent.run(task)  # model retries with corrected arguments","preventionTips":["Give required tool parameters safe defaults when possible.","Document expected formats in tool docstrings (the model reads them).","Use simple, primitive type annotations on tool parameters."],"tags":["smolagents","tool-arguments","validation","type-error"],"backgroundTag":"tool-argument-validation-failed","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}