Some agent tasks are embarrassingly parallel: summarizing five documents, or scoring one candidate against several criteria, where each item is independent. LangGraph expresses this with the Send API: a conditional edge emits one Send per item, each branch runs the same node on its own item, and the results merge back. The merge depends on the reducer: a list-valued state key needs an append reducer, or the last branch to finish wins and the rest of the work is silently dropped.
What you need
- Python with langgraph installed and a graph that already runs
- A task with independent items, such as several documents to summarize
- A state key for the merged results with an append reducer
Step 1: Write the branch node for one item
Write a node that takes one item from the state, processes it, and returns its result. The node must only use the item it was given, not the whole list.
Step 2: Emit one Send per item from a conditional edge
Add a conditional edge that returns one Send per item, each addressed to the branch node with that item. The runtime runs the branches and merges their updates.
Step 3: Add a fan-in node and check nothing was lost
Add an aggregate node after the branches that combines the merged results, then run the graph and count the results: the count must match the number of items. If results are missing, the reducer on the results key is wrong.
Worked example: synthetic parallel summaries
The table below is a synthetic example. It shows the expected result of parallel branches; no graph was run.
| Check | Expected | Result |
|---|---|---|
| Documents sent | 5 | 5 branches |
| Summaries merged | 5 | Pass |
| Aggregate reads all 5 | Yes | Pass |
Expected result (UNTESTED). five branches run in parallel, all five summaries merge, and the aggregate reads all five. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Without an append reducer on the results key, the last branch to finish wins and the rest is silently dropped.
- Parallel branches that mutate shared external state, such as the same file, need explicit locking.
- Only branch on independent items; if one branch depends on another’s result, run them in sequence.
