Send and parallel fan-out
Send creates a dynamic call to a node with its own input. Return several Send objects to fan work out in parallel, then merge results through a reducer.1
Tiny example
Section titled “Tiny example”import operatorfrom typing import Annotatedfrom langgraph.types import Send
class ResearchState(TypedDict): urls: list[str] summaries: Annotated[list[str], operator.add]
def fan_out(state: ResearchState): return [Send("summarize", {"url": url}) for url in state["urls"]]
def summarize(state: dict) -> dict: return {"summaries": [fetch_summary(state["url"])]}- Router sees three URLs.
- It returns three
Send("summarize", ...)values. - Three node calls run concurrently.
- The reducer combines their summaries.
Failure note
Section titled “Failure note”Cap fan-out and invocation concurrency. Parallel calls can overload an API, and results should not rely on completion order. Side-effecting workers need idempotency keys.
Related
Section titled “Related”Footnotes
Section titled “Footnotes”-
LangChain, Use the graph API — Map-reduce and the Send API. ↩