{"record":{"id":"5da401dece940c9d","repo":"langchain-ai/langchain","slug":"too-many-arguments-to-single-input-tool-self-name","errorCode":null,"errorMessage":"Too many arguments to single-input tool {self.name}.\n                Consider using StructuredTool instead. Args: {all_args}","messagePattern":"Too many arguments to single-input tool (.+?)\\.\n                Consider using StructuredTool instead\\. Args: (.+?)","errorType":"exception","errorClass":"ToolException","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/tools/simple.py","lineNumber":96,"sourceCode":"            tool_input: The input to the tool.\n            tool_call_id: The ID of the tool call.\n\n        Raises:\n            ToolException: If the tool input is invalid.\n\n        Returns:\n            The Pydantic model args and kwargs.\n        \"\"\"\n        args, kwargs = super()._to_args_and_kwargs(tool_input, tool_call_id)\n        # For backwards compatibility. The tool must be run with a single input\n        all_args = list(args) + list(kwargs.values())\n        if len(all_args) != 1:\n            msg = (\n                f\"\"\"Too many arguments to single-input tool {self.name}.\n                Consider using StructuredTool instead.\"\"\"\n                f\" Args: {all_args}\"\n            )\n            raise ToolException(msg)\n        return tuple(all_args), {}\n\n    def _run(\n        self,\n        *args: Any,\n        config: RunnableConfig,\n        run_manager: CallbackManagerForToolRun | None = None,\n        **kwargs: Any,\n    ) -> Any:\n        \"\"\"Use the tool.\n\n        Args:\n            *args: Positional arguments to pass to the tool\n            config: Configuration for the run\n            run_manager: Optional callback manager to use for the run\n            **kwargs: Keyword arguments to pass to the tool\n\n        Returns:","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/tools/simple.py#L78-L114","documentation":"Tool (the single-input tool class) accepts exactly one argument per invocation. After converting the input to args/kwargs, more than one value was present, so it raises ToolException (runtime, model-visible) suggesting StructuredTool for multi-argument tools.","triggerScenarios":"Tool(func).invoke({'a': 1, 'b': 2}); a single-input tool invoked by a model that generated multiple arguments; tool.run('x', 'y').","commonSituations":"An LLM hallucinating extra parameters for a string-input tool; schemas not constrained so the model passes dicts with several keys; using Tool where the underlying function really needs multiple parameters.","solutions":["Switch to StructuredTool / @tool with a typed function for multi-argument tools","Make the tool's input schema explicit (args_schema with a single field) so the model only sends one argument","If extra args come from the model, tighten the tool description/schema so only the expected argument is produced"],"exampleFix":"# before\nmy_tool = Tool(name=\"search\", func=lambda q: search(q), description=\"Search\")\nmy_tool.invoke({\"query\": \"cats\", \"limit\": 5})   # ToolException\n\n# after\n@tool\ndef search(query: str, limit: int = 5) -> str:\n    \"\"\"Search with an optional limit.\"\"\"\n    return _search(query, limit)","handlingStrategy":"validation","validationCode":"def invoke_single_input_tool(tool, tool_input):\n    \"\"\"Coerce to exactly one value before invoking a single-input Tool.\"\"\"\n    if isinstance(tool_input, dict):\n        values = list(tool_input.values())\n        if len(values) != 1:\n            msg = f\"Expected exactly 1 argument, got {len(values)}: {tool_input}\"\n            raise ValueError(msg)\n        tool_input = values[0]\n    return tool.invoke(tool_input)","typeGuard":"def is_single_value_input(x: object) -> bool:\n    return not isinstance(x, dict) or len(x) == 1","tryCatchPattern":"from langchain_core.tools import ToolException\n\ntry:\n    out = tool.invoke(payload)\nexcept ToolException as e:\n    if \"Too many arguments\" in str(e):\n        out = structured_tool.invoke(payload)  # retry via multi-arg tool\n    else:\n        raise","preventionTips":["Prefer @tool-decorated typed functions over bare Tool for anything beyond string in/out","Give single-input Tools an explicit args_schema with one field to constrain the model","Watch agent traces for models inventing extra arguments; fix descriptions/schemas, not the harness"],"tags":["langchain","tools","arguments","schema"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}