LangGraph/Advanced
Advanced10 min

Send API & Map-Reduce

Fan out to parallel node executions with Send(), then collect and reduce the results.

Quick Reference

  • Send(node_name, state): dynamically spawn a node execution with a custom state payload
  • Return a list of Send() from a conditional edge to fan out to multiple parallel executions
  • Map phase: each Send() runs the target node independently with its own input state
  • Reduce phase: use a reducer (e.g., operator.add on a list) to collect all parallel results
  • Dynamic parallelism: the number of Send() calls can depend on runtime state (e.g., number of documents)

Dynamic Fan-Out with Send()

Process N documents in parallel

Each Send() spawns an independent execution of the target node with its own state payload. The number of Send() calls is determined at runtime -- if state['documents'] has 3 items, 3 parallel executions are spawned. If it has 100, 100 are spawned. The conditional edge function returns a list of Send objects instead of a string node name, and LangGraph handles the parallel dispatch.