LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Graphs
  • Functional API
  • Pregel
  • Checkpointing
  • Storage
  • Caching
  • Types
  • Runtime
  • Config
  • Errors
  • Constants
  • Channels
  • Agents
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 CLI
LangGraph SDK
LangGraph Supervisor
LangGraph Swarm
Language
Theme
PythonlanggraphgraphmessageMessageGraph
Class●Since v0.1Deprecated

MessageGraph

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.

Copy
MessageGraph(
    self,
)

Bases

StateGraph

Constructors

constructor
__init__

Inherited fromStateGraph

Attributes

Aedges: set[tuple[str, str]]Anodes: dict[str, StateNodeSpec[Any, ContextT]]Abranches: defaultdict[str, dict[str, BranchSpec]]Achannels: dict[str, BaseChannel]Amanaged: dict[str, ManagedValueSpec]Aschemas: dict[type[Any], dict[str, BaseChannel | ManagedValueSpec]]Awaiting_edges: set[tuple[tuple[str, ...], str]]Acompiled: boolAstate_schema: type[StateT]Acontext_schema: type[ContextT] | NoneAinput_schema: type[InputT]Aoutput_schema: type[OutputT]

Methods

Madd_node
—

Add a new node to the StateGraph.

Madd_edge
—

Add a directed edge from the start node (or list of start nodes) to the end node.

Madd_conditional_edges
—

Add a conditional edge from the starting node to any number of destination nodes.

Madd_sequence
—

Add a sequence of nodes that will be executed in the provided order.

Mset_entry_point
—

Specifies the first node to be called in the graph.

Mset_conditional_entry_point
—

Sets a conditional entry point in the graph.

Mset_finish_point
—

Marks a node as a finish point of the graph.

MvalidateMcompile
—

Compiles the StateGraph into a CompiledStateGraph object.

View source on GitHub