LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    PythonlanggraphtypesSend
    Class●Since v0.2

    Send

    Copy
    Send(
      self,
      ,
      node: str,
      arg: Any,
      *,
      timeout: float

    Used in Docs

    • Build a multi-source knowledge base with routing
    • Fault tolerance
    • Graph API overview
    • Router
    • Use the graph API

    Constructors

    Attributes

    View source on GitHub
    |
    timedelta
    |
    TimeoutPolicy
    |
    None
    =
    None
    )

    Parameters

    NameTypeDescription
    node*str

    The name of the target node to send the message to.

    arg*Any

    The state or message to send to the target node.

    timeoutfloat | timedelta | TimeoutPolicy | None
    Default:None
    constructor
    __init__
    NameType
    nodestr
    argAny
    timeoutfloat | timedelta | TimeoutPolicy | None
    attribute
    node: str
    attribute
    arg: Any
    attribute
    timeout: TimeoutPolicy | None

    A message or packet to send to a specific node in the graph.

    The Send class is used within a StateGraph's conditional edges to dynamically invoke a node with a custom state at the next step.

    Importantly, the sent state can differ from the core graph's state, allowing for flexible and dynamic workflow management.

    One such example is a "map-reduce" workflow where your graph invokes the same node multiple times in parallel with different states, before aggregating the results back into the main graph's state.

    from typing import Annotated
    from langgraph.types import Send
    from langgraph.graph import END, START
    from langgraph.graph import StateGraph
    import operator
    
    class OverallState(TypedDict):
        subjects: list[str]
        jokes: Annotated[list[str], operator.add]
    
    def continue_to_jokes(state: OverallState):
        return [Send("generate_joke", {"subject": s}) for s in state["subjects"]]
    
    builder = StateGraph(OverallState)
    builder.add_node("generate_joke", lambda state: {"jokes": [f"Joke about {state['subject']}"]})
    builder.add_conditional_edges(START, continue_to_jokes)
    builder.add_edge("generate_joke", END)
    graph = builder.compile()
    
    # Invoking with two subjects results in a generated joke for each
    graph.invoke({"subjects": ["cats", "dogs"]})
    # {'subjects': ['cats', 'dogs'], 'jokes': ['Joke about cats', 'Joke about dogs']}

    Optional timeout policy for this specific pushed task. A number or timedelta is treated as a hard run_timeout.

    Advertisement
    Advertisement