Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Agents · Const

Send

Send routes execution to a named graph node with custom input state. Returning multiple Send objects from conditional edges enables dynamic fan-out and map-reduce workflows.

How it works

Send is a routing packet used from conditional edges to invoke a named graph node with custom input state. The input can differ from the graph’s main state, enabling dynamic fan-out patterns such as parallel map-reduce workflows.

Syntax

new Send<Node extends string = string, Args = any>(node: Node, args: Args)

Parameters

NameTypeDescription
nodeNode extends stringName of the node to invoke.
argsArgsCustom state or arguments passed to the node invocation.

Returns

A Send instance representing a message or packet addressed to a graph node.

Key points

  • Each Send instance identifies the destination node and carries the input that node should receive.
  • Use Send when routing decisions need to construct per-invocation state dynamically.
  • The destination node can receive state tailored to the particular branch or item being processed.
  • A common pattern is mapping multiple inputs to repeated node executions and reducing their outputs afterward.
  • Mapping an array to Send objects can schedule multiple executions of one node with distinct states.
  • Use a reducer on the aggregate field when collecting results from parallel Send executions.

Common mistakes

  • The payload is the node’s custom input, not necessarily the graph-wide state shape.
  • Return Send instances from conditional-edge routing logic rather than treating Send as a normal node result.

Example: Fan out work with Send

import { Annotation, Send, StateGraph } from "@langchain/langgraph";

const State = Annotation.Root({
  subjects: Annotation<string[]>(),
  jokes: Annotation<string[]>({ reducer: (a, b) => a.concat(b) }),
});

const fanOut = (state: typeof State.State) =>
  state.subjects.map(
    (subject) => new Send("generate_joke", { subjects: [subject] }),
  );

const graph = new StateGraph(State)
  .addNode("generate_joke", (state) => ({
    jokes: [`Joke about ${state.subjects}`],
  }))
  .addConditionalEdges("__start__", fanOut)
  .addEdge("generate_joke", "__end__")
  .compile();

const result = await graph.invoke({ subjects: ["cats", "dogs"] });
console.log(result);

Returns one Send object per subject so the same node runs with separate input states.

When to use it

Dynamic fan-out

Map each item in a collection to a separate invocation of the same node.

Map-reduce workflows

Run repeated node executions concurrently and collect their outputs with a reducer.

Custom per-branch state

Pass a node a state shape tailored to a branch rather than the graph’s central state.

  • StateGraph
  • Annotation
  • SendInterface

Source: Send | LangGraph.js API Reference. Checked 2026-10-15.