{"record":{"id":"e9bc8b7cb4ed61be","repo":"huggingface/smolagents","slug":"argument-key-is-not-in-the-tool-s-input-schema","errorCode":null,"errorMessage":"Argument {key} is not in the tool's input schema","messagePattern":"Argument (.+?) is not in the tool's input schema","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/smolagents/tools.py","lineNumber":1388,"sourceCode":"        arguments (`Any`): Arguments to validate. Can be a dictionary mapping\n            argument names to values, or a single value for tools with one input.\n\n\n    Raises:\n        ValueError: If an argument is not in the tool's input schema, if a required\n            argument is missing, or if the argument value doesn't match the expected type.\n        TypeError: If an argument has an incorrect type that cannot be converted\n            (e.g., string instead of number, excluding integer to number conversion).\n\n    Note:\n        - Supports type coercion from integer to number\n        - Handles nullable parameters when explicitly marked in the schema\n        - Accepts \"any\" type as a wildcard that matches all types\n    \"\"\"\n    if isinstance(arguments, dict):\n        for key, value in arguments.items():\n            if key not in tool.inputs:\n                raise ValueError(f\"Argument {key} is not in the tool's input schema\")\n\n            actual_type = _get_json_schema_type(type(value))[\"type\"]\n            expected_type = tool.inputs[key][\"type\"]\n            expected_type_is_nullable = tool.inputs[key].get(\"nullable\", False)\n\n            # Type is valid if it matches, is \"any\", or is null for nullable parameters\n            if (\n                (actual_type != expected_type if isinstance(expected_type, str) else actual_type not in expected_type)\n                and expected_type != \"any\"\n                and not (actual_type == \"null\" and expected_type_is_nullable)\n            ):\n                if actual_type == \"integer\" and expected_type == \"number\":\n                    continue\n                raise TypeError(f\"Argument {key} has type '{actual_type}' but should be '{tool.inputs[key]['type']}'\")\n\n        for key, schema in tool.inputs.items():\n            key_is_nullable = schema.get(\"nullable\", False)\n            if key not in arguments and not key_is_nullable:","sourceCodeStart":1370,"sourceCodeEnd":1406,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/tools.py#L1370-L1406","documentation":"validate_tool_arguments checks the arguments dict against tool.inputs (the tool's JSON-schema input definition) before execution. Any key not present in the schema raises ValueError, since the tool has no such parameter to bind.","triggerScenarios":"Calling a tool (or agent execute_tool_call) with an arguments dict containing an extra key, e.g. `tool(arguments={'q': 'x', 'context': 'y'})` when 'context' is not in the tool's input schema. Often caused by an LLM hallucinating a parameter name in the tool-call JSON.","commonSituations":"Agents generating plausible-but-wrong parameter names (e.g. 'query' vs 'search_term'); schema drift after editing a tool's signature without regenerating descriptions; passing camelCase where the schema uses snake_case.","solutions":["Log the tool's actual `tool.inputs` keys and align the arguments dict exactly","Regenerate/update tool descriptions and type hints after changing a tool signature so the LLM sees the current parameter names","Add a pre-call filter that drops or renames unknown keys before invoking the tool"],"exampleFix":"# before\nresult = search_tool(arguments={\"query\": \"cats\", \"limit\": 5})  # 'query' not in schema\n# after\nresult = search_tool(arguments={\"search_term\": \"cats\", \"limit\": 5})  # matches tool.inputs keys","handlingStrategy":"validation","validationCode":"valid = set(tool.inputs)\nsafe_args = {k: v for k, v in raw_arguments.items() if k in valid}\ndropped = set(raw_arguments) - valid\nif dropped:\n    logging.warning(\"dropping unknown tool args: %s; valid: %s\", dropped, sorted(valid))\nresult = tool(**safe_args)  # or execute_tool_call with safe_args","typeGuard":"def arguments_match_schema(args: dict, tool) -> bool:\n    return set(args).issubset(set(tool.inputs))","tryCatchPattern":"from smolagents.tools import validate_tool_arguments\ntry:\n    validate_tool_arguments(tool, arguments)\nexcept ValueError as e:\n    if \"not in the tool's input schema\" in str(e):\n        arguments = {k: v for k, v in arguments.items() if k in tool.inputs}\n        validate_tool_arguments(tool, arguments)\n    else:\n        raise","preventionTips":["Regenerate tool descriptions after signature changes so LLMs see current parameter names","Filter hallucinated keys out of LLM tool-call arguments before execution","Log tool.inputs alongside arguments on failure to speed debugging"],"tags":["tool-call","schema-validation","arguments"],"backgroundTag":"schema-validation-failed","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}