From 611588613db90587e7599d32892ab63cd55d41ce Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Tue, 10 Dec 2024 15:16:02 -0500 Subject: [PATCH] docs: add an FAQ note for command vs cond edge (#2697) --- docs/docs/concepts/low_level.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docs/concepts/low_level.md b/docs/docs/concepts/low_level.md index a3ab96bf1..86bc0879d 100644 --- a/docs/docs/concepts/low_level.md +++ b/docs/docs/concepts/low_level.md @@ -353,6 +353,12 @@ def my_node(state: State) -> Command[Literal["my_other_node"]]: Check out this [how-to guide](../how-tos/command.ipynb) for an end-to-end example of how to use `Command`. +### When should I use Command instead of conditional edges? + +Use `Command` when you need to **both** update the graph state **and** route to a different node. For example, when implementing [multi-agent handoffs](./multi_agent.md#handoffs) where it's important to route to a different agent and pass some information to that agent. + +Use [conditional edges](#conditional-edges) to route between nodes conditionally without updating the state. + ### Using inside tools A common use case is updating graph state from inside a tool. For example, in a customer support application you might want to look up customer information based on their account number or ID in the beginning of the conversation. To update the graph state from the tool, you can return `Command(update={"my_custom_key": "foo", "messages": [...]})` from the tool: