{"record":{"id":"b124d5e53afd81dd","repo":"langchain-ai/langgraph","slug":"invalid-input-to-toolnode-tool-name-requires-gr","errorCode":null,"errorMessage":"Invalid input to ToolNode. Tool {name} requires graph state dict as input.","messagePattern":"Invalid input to ToolNode\\. Tool (.+?) requires graph state dict as input\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/tool_node.py","lineNumber":1387,"sourceCode":"            # Handle list state by converting to dict\n            if isinstance(state, list):\n                required_fields = list(injected.state.values())\n                if (\n                    len(required_fields) == 1\n                    and required_fields[0] == self._messages_key\n                ) or required_fields[0] is None:\n                    state = {self._messages_key: state}\n                else:\n                    err_msg = (\n                        f\"Invalid input to ToolNode. Tool {tool_call['name']} requires \"\n                        f\"graph state dict as input.\"\n                    )\n                    if any(state_field for state_field in injected.state.values()):\n                        required_fields_str = \", \".join(f for f in required_fields if f)\n                        err_msg += (\n                            f\" State should contain fields {required_fields_str}.\"\n                        )\n                    raise ValueError(err_msg)\n\n            # Extract state values\n            if isinstance(state, dict):\n                for tool_arg, state_field in injected.state.items():\n                    if not state_field:\n                        injected_args[tool_arg] = state\n                    elif state_field in state:\n                        injected_args[tool_arg] = state[state_field]\n                    elif tool_arg not in injected._optional_state_args:\n                        raise KeyError(state_field)\n            else:\n                for tool_arg, state_field in injected.state.items():\n                    if not state_field:\n                        injected_args[tool_arg] = state\n                    elif hasattr(state, state_field):\n                        injected_args[tool_arg] = getattr(state, state_field)\n                    elif tool_arg not in injected._optional_state_args:\n                        raise AttributeError(state_field)","sourceCodeStart":1369,"sourceCodeEnd":1405,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/tool_node.py#L1369-L1405","documentation":"State-injection guard in _inject_tool_args: a tool declares InjectedState annotations requiring specific graph state fields, but ToolNode received a plain list of messages (or a list that cannot be coerced to the required state dict). The tool needs the full state dict to inject its arguments.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1387 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke ToolNode with the graph state dict (containing the injected fields) instead of a bare message list","If only one state field is needed, ensure the injected annotation maps to the messages key so list input can be coerced","Remove InjectedState annotations if the tool should work on plain message lists"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}