subgraph_command_warningTier 1 · 70% confidence

ai-agents-subgraph-command-war-subgraph-node-returns-command-goto-end-with-a-stat-3c24725b

agent: ai_agents

When does this happen?

IF Subgraph node returns Command(goto=END) with a state update dictionary, producing the warning: 'Task <node_name> with path ... wrote to unknown channel branch:to:__end__, ignoring it.'

How others solved it

THEN Upgrade langgraph to a version that includes the fix (e.g., after commit that treats END channel writes as a special case in apply_writes). Alternatively, patch the source code in langgraph/pregel/algo.py to skip the warning when the unknown channel matches 'branch:to:__end__'.

from langgraph.graph import StateGraph, START, END
from langgraph.types import Command
from typing_extensions import TypedDict

class MessagesState(TypedDict):
    messages: list[dict[str, str]]

def call_model(state: MessagesState):
    response = {"role": "assistant", "content": "Hello"}
    return Command(goto=END, update={"messages": [state["messages"][-1], response]})

subgraph_builder = StateGraph(MessagesState)
subgraph_builder.add_node("call_model", call_model)
subgraph_builder.add_edge(START, "call_model")
subgraph_builder.add_edge("call_model", END)
subgraph = subgraph_builder.compile()

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics