You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**[Return from nodes](#return-from-nodes)**: Use `update`, `goto`, and `graph` to combine state updates with control flow.
1054
1054
-**[Input to `invoke`/`stream`](#input-to-invokestream)**: Use `resume` to continue execution after an interrupt.
1055
-
-**[Return from tools](#return-from-tools)**: Use `update`to modify graph state from inside a tool.
1055
+
-**[Return from tools](#return-from-tools)**: Similar to return from nodes, combine state updates and control flow from inside a tool.
1056
1056
1057
1057
### Return from nodes
1058
1058
@@ -1086,8 +1086,6 @@ Use @[`Command`] when you need to **both** update state **and** route to a diffe
1086
1086
1087
1087
When returning @[`Command`] in your node functions, you must add return type annotations with the list of node names the node is routing to, e.g. `Command[Literal["my_other_node"]]`. This is necessary for the graph rendering and tells LangGraph that `my_node` can navigate to `my_other_node`.
1088
1088
1089
-
@[`Command`] only adds dynamic edges β static edges defined with `add_edge` still execute. For example, if `node_a` returns `Command(goto="my_other_node")` and you also have `graph.add_edge("node_a", "node_b")`, both `node_b` and `my_other_node` will run.
@[`Command`] only adds dynamic edges β static edges defined with `addEdge` still execute. For example, if `nodeA` returns `new Command({ goto: "myOtherNode" })` and you also have `graph.addEdge("nodeA", "nodeB")`, both `nodeB` and `myOtherNode` will run.
1133
+
<Warning>
1136
1134
1137
-
</Note>
1135
+
@[`Command`] only adds dynamic edges β static edges defined with `add_edge` / `addEdge` still execute. For example, if `node_a` returns `Command(goto="my_other_node")` and you also have `graph.add_edge("node_a", "node_b")`, both `node_b` and `my_other_node` will run.
1138
1136
1139
-
:::
1137
+
</Warning>
1140
1138
1141
1139
Check out this [how-to guide](/oss/langgraph/use-graph-api#combine-control-flow-and-state-updates-with-command) for an end-to-end example of how to use @[`Command`].
1142
1140
@@ -1197,10 +1195,11 @@ This is particularly useful when implementing [multi-agent handoffs](/oss/langch
1197
1195
1198
1196
<Warning>
1199
1197
1200
-
`Command(resume=...)` is the **only**`Command` pattern intended as input to `invoke()`/`stream()`. Do not use `Command(update=...)` as input to continue multi-turn conversations β because passing any `Command` as input resumes from the last checkpoint position (skipping `__start__`), the graph will appear stuck. To continue a conversation on an existing thread, pass a plain input dict:
1198
+
`Command(resume=...)` is the **only**`Command` pattern intended as input to `invoke()`/`stream()`. Do not use `Command(update=...)` as input to continue multi-turn conversations β because passing any `Command` as input resumes from the latest checkpoint (i.e. the last step that ran, not `__start__`), the graph will appear stuck if it already finished. To continue a conversation on an existing thread, pass a plain input dict:
1201
1199
1202
1200
```python
1203
-
# WRONG β graph resumes from end state, appears stuck
1201
+
# WRONG β graph resumes from the latest checkpoint
`new Command({ resume: ... })` is the **only**`Command` pattern intended as input to `invoke()`/`stream()`. Do not use `new Command({ update: ... })` as input to continue multi-turn conversations β because passing any `Command` as input resumes from the last checkpoint position (skipping `__start__`), the graph will appear stuck. To continue a conversation on an existing thread, pass a plain input object:
1221
+
`new Command({ resume: ... })` is the **only**`Command` pattern intended as input to `invoke()`/`stream()`. Do not use `new Command({ update: ... })` as input to continue multi-turn conversations β because passing any `Command` as input resumes from the latest checkpoint (i.e. the last step that ran, not `__start__`), the graph will appear stuck if it already finished. To continue a conversation on an existing thread, pass a plain input object:
1223
1222
1224
1223
```typescript
1225
-
// WRONG β graph resumes from end state, appears stuck
1224
+
// WRONG β graph resumes from the latest checkpoint
// CORRECT β plain object restarts from __start__
@@ -1284,7 +1284,13 @@ Check out the [interrupts conceptual guide](/oss/langgraph/interrupts) for full
1284
1284
1285
1285
### Return from tools
1286
1286
1287
-
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.
1287
+
You can return @[`Command`] from tools to update graph state and control flow. Use `update` to modify state (e.g., saving customer information looked up during a conversation) and `goto` to route to a specific node after the tool completes.
1288
+
1289
+
<Warning>
1290
+
1291
+
When used inside tools, `goto` adds a dynamic edge β any static edges already defined on the node that called the tool will still execute.
1292
+
1293
+
</Warning>
1288
1294
1289
1295
Refer to [this guide](/oss/langgraph/use-graph-api#use-inside-tools) for detail.
0 commit comments