Command
object that allows you to combine both control flow and state updates:
alice
and bob
(subgraph nodes in a parent graph), and alice
needs to navigate to bob
, you can set graph=Command.PARENT
in the Command
object:
Command(graph=Command.PARENT)
you would need to wrap them in a node function with Command
annotation:
Instead of this:Command
, you can use the prebuilt create_react_agent
/ ToolNode
components, or else implement your own logic:Command
to route execution to the appropriate agent node based on supervisor’s decision. This architecture also lends itself well to running multiple agents in parallel or using map-reduce pattern.
Command
. A special case of this is a supervisor tool-calling architecture. In that case, the tool-calling LLM powering the supervisor agent will make decisions about the order in which the tools (agents) are being called.messages
). When communicating via a shared message list, there is an additional consideration: should the agents share the full history of their thought process or only the final result?
name
parameter to messages — you can use that to attach the agent name to the message. If that is not supported, you can consider manually injecting the agent name into the message content, e.g., <agent>alice</agent><message>message from alice</message>
.
alice_messages
) in the subagent’s graph state. This would be their “view” of what the message history looks like.