Skip to content

Commit a8da289

Browse files
committed
chore: add non chosen node clarification
1 parent 9bc5dae commit a8da289

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/user-guide/components/parallel-execution.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,33 @@ async def tool_a(input: dict):
214214
async def tool_b(input: dict):
215215
return {"b_result": 2}
216216

217+
@node(name="tool_c")
218+
async def tool_c(input: dict):
219+
return {"c_result": 3}
220+
217221
@node(end=True)
218222
async def end(input: dict):
219223
return {}
220224

221225
g = Graph()
222-
g.add_node(start).add_node(parallel_router).add_node(tool_a).add_node(tool_b).add_node(end)
226+
g.add_node(start).add_node(parallel_router).add_node(tool_a).add_node(tool_b).add_node(tool_c).add_node(end)
223227
g.add_edge(start, parallel_router)
224228
g.add_edge(parallel_router, tool_a)
225229
g.add_edge(parallel_router, tool_b)
230+
g.add_edge(parallel_router, tool_c) # tool_c has an edge but is not in choices
226231
g.add_join([tool_a, tool_b], end)
227232

228233
result = await g.execute({"input": {}})
229234

230235
# Results from parallel branches are merged into state
231236
assert result["a_result"] == 1
232237
assert result["b_result"] == 2
238+
# tool_c is NOT executed because it's not in the choices array
239+
assert "c_result" not in result
233240
```
234241

242+
> **Note**: When a parallel router shares an edge with a node that is not included in the router's `choices` array, that node will not be executed. Only nodes whose names appear in the returned `choices` list will run. In the example above, `tool_c` has an edge from the router but is not included in `choices`, so it does not execute.
243+
235244
### Router with Join (Iterative Patterns)
236245

237246
Use `add_join()` to control where execution continues after parallel branches complete. This enables iterative workflows where a router can evaluate results and decide whether to run more parallel branches:

0 commit comments

Comments
 (0)