{"record":{"id":"e7cbf5622d93a66e","repo":"langchain-ai/langgraph","slug":"no-aimessage-found-in-input","errorCode":null,"errorMessage":"No AIMessage found in input","messagePattern":"No AIMessage found in input","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/tool_node.py","lineNumber":1263,"sourceCode":"            return [input_with_ctx[\"tool_call\"]], input_type\n        elif isinstance(input, dict) and (\n            messages := input.get(self._messages_key, [])\n        ):\n            input_type = \"dict\"\n        elif messages := getattr(input, self._messages_key, []):\n            # Assume dataclass-like state that can coerce from dict\n            input_type = \"dict\"\n        else:\n            msg = \"No message found in input\"\n            raise ValueError(msg)\n\n        try:\n            latest_ai_message = next(\n                m for m in reversed(messages) if isinstance(m, AIMessage)\n            )\n        except StopIteration:\n            msg = \"No AIMessage found in input\"\n            raise ValueError(msg)\n\n        tool_calls = list(latest_ai_message.tool_calls)\n        return tool_calls, input_type\n\n    def _validate_tool_call(self, call: ToolCall) -> ToolMessage | None:\n        requested_tool = call[\"name\"]\n        if requested_tool not in self.tools_by_name:\n            all_tool_names = list(self.tools_by_name.keys())\n            content = INVALID_TOOL_NAME_ERROR_TEMPLATE.format(\n                requested_tool=requested_tool,\n                available_tools=\", \".join(all_tool_names),\n            )\n            return ToolMessage(\n                content, name=requested_tool, tool_call_id=call[\"id\"], status=\"error\"\n            )\n        return None\n\n    def _extract_state(","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/tool_node.py#L1245-L1281","documentation":"Error \"No AIMessage found in input\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1263 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}