{"record":{"id":"a06db3132f3a6eb0","repo":"langchain-ai/langgraph","slug":"no-messages-found-in-input-state-to-tool-edge-st","errorCode":null,"errorMessage":"No messages found in input state to tool_edge: {state}","messagePattern":"No messages found in input state to tool_edge: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/tool_node.py","lineNumber":1656,"sourceCode":"        def custom_condition(state):\n            return tools_condition(state, messages_key=\"chat_history\")\n        ```\n\n    !!! note\n        This function is designed to work seamlessly with `ToolNode` and standard\n        LangGraph patterns. It expects the last message to be an `AIMessage` when\n        tool calls are present, which is the standard output format for tool-calling\n        language models.\n    \"\"\"\n    if isinstance(state, list):\n        ai_message = state[-1]\n    elif (isinstance(state, dict) and (messages := state.get(messages_key, []))) or (\n        messages := getattr(state, messages_key, [])\n    ):\n        ai_message = messages[-1]\n    else:\n        msg = f\"No messages found in input state to tool_edge: {state}\"\n        raise ValueError(msg)\n    if hasattr(ai_message, \"tool_calls\") and len(ai_message.tool_calls) > 0:\n        return \"tools\"\n    return \"__end__\"\n\n\n@dataclass\nclass ToolRuntime(_DirectlyInjectedToolArg, Generic[ContextT, StateT]):\n    \"\"\"Runtime context automatically injected into tools.\n\n    !!! note\n\n        This is distinct from `Runtime` (from `langgraph.runtime`), which is injected\n        into graph nodes and middleware. `ToolRuntime` includes additional tool-specific\n        attributes like `config`, `state`, and `tool_call_id` that `Runtime` does not\n        have.\n\n    When a tool function has a parameter named `runtime` with type hint\n    `ToolRuntime`, the tool execution system will automatically inject an instance","sourceCodeStart":1638,"sourceCodeEnd":1674,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/tool_node.py#L1638-L1674","documentation":"Error \"No messages found in input state to tool_edge: {state}\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1656 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"}