#9072·langgraph

ToolNode silently drops Command.update when a tool returns Command(graph=PARENT, goto=[Send(...)])

Author: elizandropachecoCreated Sep 24, 2026Updated Sep 30, 2026
Labelsexternal

Checked other resources

  • I searched existing issues and the docs on Command.PARENT handoffs.
  • The same code is present on main at the time of writing (libs/prebuilt/langgraph/prebuilt/tool_node.py, ToolNode._combine_tool_outputs).

Description

When a tool returns a Command whose graph is Command.PARENT and whose goto is a list of Send objects, ToolNode._combine_tool_outputs rebuilds the command to merge fan-outs from sibling tool calls, but the rebuilt command only carries graph and goto:

python
# libs/prebuilt/langgraph/prebuilt/tool_node.py — ToolNode._combine_tool_outputs
if (
    output.graph is Command.PARENT
    and isinstance(output.goto, list)
    and all(isinstance(send, Send) for send in output.goto)
):
    if parent_command:
        parent_command = replace(parent_command, goto=parent_command.goto + output.goto)
    else:
        parent_command = Command(graph=Command.PARENT, goto=output.goto)   # update/resume dropped
else:
    combined_outputs.append(output)                                        # passes through intact

update (and resume) are discarded without any warning. The parent graph receives the Sends but never the ToolMessage (nor the AIMessage with the tool call) that the handoff tool put in update. Because the same tool returning goto="node_name" takes the else branch, the behaviour differs only by the type of goto, which is surprising and undocumented.

Practical consequence in a supervisor/handoff architecture (the pattern in the multi-agent docs): the parent state has no record that a delegation happened, so any guard that counts prior delegations from the message history never fires. In our production agent this produced an unbounded delegate → reply → delegate loop until GraphRecursionError (60 delegations, ~1 hour, 15M tokens).

Minimal reproduction

python
import asyncio
from typing import Annotated

from langchain.agents import create_agent
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from langchain_core.tools import InjectedToolCallId, tool
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import InjectedState
from langgraph.types import Command, Send


class FakeModel(GenericFakeChatModel):
    def bind_tools(self, tools, **kwargs):
        return self


def run(goto_as_send: bool):
    @tool("delegate_x", description="hand off to x")
    def handoff(
        task: str,
        state: Annotated[MessagesState, InjectedState],
        tool_call_id: Annotated[str, InjectedToolCallId],
    ):
        tm = ToolMessage(content="forwarded", name="delegate_x", tool_call_id=tool_call_id)
        goto = [Send("x", {"messages": [HumanMessage(content=task)]})] if goto_as_send else "x"
        return Command(goto=goto, update={"messages": state["messages"] + [tm]}, graph=Command.PARENT)

    llm = FakeModel(messages=iter([
        AIMessage(content="", tool_calls=[{"name": "delegate_x", "args": {"task": "t1"}, "id": "c1"}]),
        AIMessage(content="done"),
    ]))
    supervisor = create_agent(llm, tools=[handoff], name="sup")

    b = StateGraph(MessagesState)
    b.add_node("sup", supervisor, destinations=("x",))
    b.add_edge(START, "sup")
    b.add_node("x", lambda s: {"messages": [HumanMessage(content="reply from x", name="x")]})
    b.add_edge("x", "sup")
    out = asyncio.run(b.compile().ainvoke({"messages": [HumanMessage(content="hi")]}))
    print("goto as Send list" if goto_as_send else "goto as str      ",
          [f"{type(m).__name__}:{getattr(m, 'name', None)}" for m in out["messages"]])


run(goto_as_send=False)
run(goto_as_send=True)

Output:

goto as str       ['HumanMessage:None', 'AIMessage:sup', 'ToolMessage:delegate_x', 'HumanMessage:x', 'AIMessage:sup']
goto as Send list ['HumanMessage:None', 'HumanMessage:x', 'AIMessage:sup']

With goto as a list of Send, the parent's final state lacks both the AIMessage carrying the tool call and the ToolMessage that were in Command.update. The Send itself is honoured (node x runs).

The same happens with create_react_agent, and with update={"messages": [tm]} only.

Expected behaviour

Either the merged parent command should preserve update (merging updates from sibling commands the same way it merges goto), or the docs for Command.PARENT should state that update is ignored when goto is a list of Send, and ideally ToolNode should raise or warn instead of silently dropping it.

Our workaround: the handoff tool returns goto="<dispatcher node>" (a plain node name, so the update survives) with the fan-out plan stored in ToolMessage.additional_kwargs, and a small node in the parent graph turns that plan into the Sends.

System info

  • langgraph 1.2.9, langgraph-prebuilt 1.1.0, langchain 1.3.14, langchain-core 1.4.9
  • Python 3.13, macOS and Linux (Docker)