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
    Pythonlanggraphgraphmessage
    Moduleā—Since v0.1

    message

    Attributes

    Functions

    Classes

    Type Aliases

    View source on GitHub
    attribute
    CONF
    attribute
    CONFIG_KEY_SEND
    attribute
    NS_SEP
    attribute
    REMOVE_ALL_MESSAGES: str
    function
    add_messages
    function
    push_message
    class
    StateGraph
    class
    LangGraphDeprecatedSinceV10
    class
    MessagesState
    deprecatedclass
    MessageGraph
    typeAlias
    Messages: list[MessageLikeRepresentation] | MessageLikeRepresentation

    Merges two lists of messages, updating existing messages by ID.

    By default, this ensures the state is "append-only", unless the new message has the same ID as an existing message.

    Write a message manually to the messages / messages-tuple stream mode.

    Will automatically write to the channel specified in the state_key unless state_key is None.

    A graph whose nodes communicate by reading and writing to a shared state.

    The signature of each node is State -> Partial<State>.

    Each state key can optionally be annotated with a reducer function that will be used to aggregate the values of that key received from multiple nodes. The signature of a reducer function is (Value, Value) -> Value.

    Warning

    StateGraph is a builder class and cannot be used directly for execution. You must first call .compile() to create an executable graph that supports methods like invoke(), stream(), astream(), and ainvoke(). See the CompiledStateGraph documentation for more details.

    A specific LangGraphDeprecationWarning subclass defining functionality deprecated since LangGraph v1.0.0

    A StateGraph where every node receives a list of messages as input and returns one or more messages as output.

    MessageGraph is a subclass of StateGraph whose entire state is a single, append-only* list of messages. Each node in a MessageGraph takes a list of messages as input and returns zero or more messages as output. The add_messages function is used to merge the output messages from each node into the existing list of messages in the graph's state.