huggingface/smolagents · error · ValueError

Argument {key} is not in the tool's input schema

Error message

Argument {key} is not in the tool's input schema

What it means

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.

Source

Thrown at src/smolagents/tools.py:1388

        arguments (`Any`): Arguments to validate. Can be a dictionary mapping
            argument names to values, or a single value for tools with one input.


    Raises:
        ValueError: If an argument is not in the tool's input schema, if a required
            argument is missing, or if the argument value doesn't match the expected type.
        TypeError: If an argument has an incorrect type that cannot be converted
            (e.g., string instead of number, excluding integer to number conversion).

    Note:
        - Supports type coercion from integer to number
        - Handles nullable parameters when explicitly marked in the schema
        - Accepts "any" type as a wildcard that matches all types
    """
    if isinstance(arguments, dict):
        for key, value in arguments.items():
            if key not in tool.inputs:
                raise ValueError(f"Argument {key} is not in the tool's input schema")

            actual_type = _get_json_schema_type(type(value))["type"]
            expected_type = tool.inputs[key]["type"]
            expected_type_is_nullable = tool.inputs[key].get("nullable", False)

            # Type is valid if it matches, is "any", or is null for nullable parameters
            if (
                (actual_type != expected_type if isinstance(expected_type, str) else actual_type not in expected_type)
                and expected_type != "any"
                and not (actual_type == "null" and expected_type_is_nullable)
            ):
                if actual_type == "integer" and expected_type == "number":
                    continue
                raise TypeError(f"Argument {key} has type '{actual_type}' but should be '{tool.inputs[key]['type']}'")

        for key, schema in tool.inputs.items():
            key_is_nullable = schema.get("nullable", False)
            if key not in arguments and not key_is_nullable:

View on GitHub (pinned to 30bb116109)

Solutions

  1. Log the tool's actual `tool.inputs` keys and align the arguments dict exactly
  2. Regenerate/update tool descriptions and type hints after changing a tool signature so the LLM sees the current parameter names
  3. Add a pre-call filter that drops or renames unknown keys before invoking the tool

Example fix

# before
result = search_tool(arguments={"query": "cats", "limit": 5})  # 'query' not in schema
# after
result = search_tool(arguments={"search_term": "cats", "limit": 5})  # matches tool.inputs keys
Defensive patterns

Strategy: validation

Validate before calling

valid = set(tool.inputs)
safe_args = {k: v for k, v in raw_arguments.items() if k in valid}
dropped = set(raw_arguments) - valid
if dropped:
    logging.warning("dropping unknown tool args: %s; valid: %s", dropped, sorted(valid))
result = tool(**safe_args)  # or execute_tool_call with safe_args

Type guard

def arguments_match_schema(args: dict, tool) -> bool:
    return set(args).issubset(set(tool.inputs))

Try / catch

from smolagents.tools import validate_tool_arguments
try:
    validate_tool_arguments(tool, arguments)
except ValueError as e:
    if "not in the tool's input schema" in str(e):
        arguments = {k: v for k, v in arguments.items() if k in tool.inputs}
        validate_tool_arguments(tool, arguments)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.


AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28). Data as JSON: /api/errors/e9bc8b7cb4ed61be. Report an issue: GitHub.