langchain-ai/langgraph · error · ValueError

No messages found in input state to tool_edge: {state}

Error message

No messages found in input state to tool_edge: {state}

What it means

Error "No messages found in input state to tool_edge: {state}" thrown in langchain-ai/langgraph.

Source

Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1656

        def custom_condition(state):
            return tools_condition(state, messages_key="chat_history")
        ```

    !!! note
        This function is designed to work seamlessly with `ToolNode` and standard
        LangGraph patterns. It expects the last message to be an `AIMessage` when
        tool calls are present, which is the standard output format for tool-calling
        language models.
    """
    if isinstance(state, list):
        ai_message = state[-1]
    elif (isinstance(state, dict) and (messages := state.get(messages_key, []))) or (
        messages := getattr(state, messages_key, [])
    ):
        ai_message = messages[-1]
    else:
        msg = f"No messages found in input state to tool_edge: {state}"
        raise ValueError(msg)
    if hasattr(ai_message, "tool_calls") and len(ai_message.tool_calls) > 0:
        return "tools"
    return "__end__"


@dataclass
class ToolRuntime(_DirectlyInjectedToolArg, Generic[ContextT, StateT]):
    """Runtime context automatically injected into tools.

    !!! note

        This is distinct from `Runtime` (from `langgraph.runtime`), which is injected
        into graph nodes and middleware. `ToolRuntime` includes additional tool-specific
        attributes like `config`, `state`, and `tool_call_id` that `Runtime` does not
        have.

    When a tool function has a parameter named `runtime` with type hint
    `ToolRuntime`, the tool execution system will automatically inject an instance

View on GitHub (pinned to 38031739e5)

When it happens

Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1656 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/a06db3132f3a6eb0. Report an issue: GitHub.