Back to series
· 12 min read

LangGraph's State Management Mechanism


I. What Is LangGraph State Management

In traditional programs, functions usually receive input through parameters and output results through return values. Data must be passed explicitly between functions.

But in Agent workflows, a task often cannot be completed with a single function call; instead, it is an execution graph made up of multiple nodes. Information must be shared continuously between nodes, such as:

  • The question the user initially asked.
  • The current execution stage of the task.
  • Reasoning and analysis results the Agent has already produced.
  • Tool call records.
  • Intermediate execution results.
  • Error messages and retry counts.
  • Whether human review is required.
  • The final generated answer.

If each node maintained its own data separately, it would create a large amount of redundant passing and state synchronization work.

LangGraph uses a unified State to manage the shared data within a workflow.

LangGraph can be understood as a graph execution framework driven by state:

  • State: defines the data structure that the entire workflow needs to share.
  • Node: reads the current state and returns the fields that need to be updated.
  • Edge: determines the execution relationships between nodes.
  • Reducer: defines how multiple state updates are merged.
  • Checkpointer: saves state snapshots during execution.
  • Store: saves data that needs to be reused across threads, sessions, or tasks.

Among these, State is the core of the entire state management mechanism.

1. Why LangGraph Needs State Management

Consider a simple Agent workflow:

  1. The user submits a question.
  2. The Planner analyzes the task.
  3. The Researcher collects materials.
  4. The Analyst analyzes the materials.
  5. The Reviewer checks the results.
  6. The Agent returns the final answer.

Each stage needs to read the information produced by the preceding stages.

If ordinary functions are used to organize this:

def planner(user_input):
    return {"plan": "研究技术方案"}

def researcher(plan):
    return {"research": "收集到的技术资料"}

def analyst(research):
    return {"analysis": "技术分析结果"}

def reviewer(analysis):
    return {"review": "审核通过"}

This approach works fine when there are few steps, but as workflow complexity increases, the following problems appear:

  • More and more parameters have to be passed explicitly between functions.
  • Multiple nodes need to access the same piece of data.
  • Parallel nodes need to merge their execution results.
  • Loop execution requires continuously maintained state.
  • Long-running tasks need to save and restore progress.

LangGraph places this data uniformly in State, and the graph execution engine is responsible for passing and updating it between nodes.

II. The Basic Structure of LangGraph State

LangGraph State is usually defined using Python's TypedDict, though other supported structured types can also be used.

For example:

from typing import TypedDict


class AgentState(TypedDict):
    user_input: str
    plan: str
    research: str
    analysis: str
    final_answer: str

This State defines the five fields that need to be shared in the workflow.

Each node can read and update these fields according to its own responsibilities.

For example:

def planner(state: AgentState):
    return {
        "plan": f"分析用户需求:{state['user_input']}"
    }


def researcher(state: AgentState):
    return {
        "research": "收集到相关技术资料"
    }


def analyst(state: AgentState):
    return {
        "analysis": f"基于资料进行分析:{state['research']}"
    }

Nodes usually do not need to return the entire State; they only need to return the fields that need to be updated in this execution.

LangGraph applies the updates returned by a node to the current state according to the field definitions and reduction rules of the State.

1. Initial Values of State

When executing the graph, an initial State can be passed to the graph:

initial_state = {
    "user_input": "解释 LangGraph 的状态管理机制",
    "plan": "",
    "research": "",
    "analysis": "",
    "final_answer": ""
}

The initial state represents the data at the moment the workflow begins execution.

As nodes continue to execute, the State is continuously updated.

2. Reading State

A node receives the current State through its parameters:

def planner(state: AgentState):
    user_input = state["user_input"]

    return {
        "plan": f"围绕以下问题制定计划:{user_input}"
    }

A node can read the fields it needs and does not need to care how other nodes execute.

This approach gives nodes relatively independent responsibility boundaries.

3. State Updates

A node returns a dictionary representing the state update produced by this execution:

def planner(state: AgentState):
    return {
        "plan": "1. 收集资料 2. 分析机制 3. 总结结果"
    }

What is returned here is only the update content, not the complete State.

Suppose the current state is:

{
    "user_input": "研究 LangGraph",
    "plan": "",
    "research": "",
    "analysis": "",
    "final_answer": ""
}

After planner executes, the state is logically updated to:

{
    "user_input": "研究 LangGraph",
    "plan": "1. 收集资料 2. 分析机制 3. 总结结果",
    "research": "",
    "analysis": "",
    "final_answer": ""
}

Fields that are not updated retain their original values.

4. The Complete State Update Process

flowchart TD
    A["Create initial State"] --> B["Node reads current State"]
    B --> C["Execute node logic"]
    C --> D["Return partial field updates"]
    D --> E["Apply field reducer rules"]
    E --> F["Generate updated State"]
    F --> G{"Are there subsequent nodes?"}
    G -->|"Yes"| B
    G -->|"No"| H["Output final State"]

    style A fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style B fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style C fill:#EAF3EC,stroke:#83A995,color:#315D49
    style D fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style E fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style F fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style G fill:#F7F4E8,stroke:#C7B77A,color:#675A2D
    style H fill:#DCEFE5,stroke:#4F8B70,color:#24563F

III. State Schema and Type Definitions

State Schema is the definition of a LangGraph state structure.

It determines which fields exist in the workflow, what data types the fields use, and what rules are used when fields are updated.

1. Defining State with TypedDict

TypedDict is a common way to define State in LangGraph.

from typing import TypedDict


class AgentState(TypedDict):
    question: str
    plan: str
    documents: list[str]
    answer: str

Advantages:

  • Intuitive definition.
  • Clear type hints.
  • Suitable for describing structured state.
  • Works with Python type checking tools.

2. Defining a Reducer with Annotated

Some fields are not simply overwritten but require a merge operation.

For example, multiple nodes may append data to the same list separately.

In this case, you can use Annotated to specify a Reducer for the field.

import operator
from typing import Annotated, TypedDict


class AgentState(TypedDict):
    question: str
    documents: Annotated[list[str], operator.add]

Here, operator.add indicates that list updates use additive merging.

For example:

current = ["文档 A"]
update = ["文档 B"]

result = current + update

print(result)

Output:

['文档 A', '文档 B']

If no Reducer is specified, ordinary fields usually use overwrite update semantics.

3. Using Optional and NotRequired

In real-world business scenarios, not all fields exist when the workflow starts.

You can use NotRequired or total=False to describe non-required fields.

from typing import TypedDict, NotRequired


class AgentState(TypedDict):
    question: str
    answer: NotRequired[str]
    error: NotRequired[str]
    retry_count: NotRequired[int]

This can express:

  • question is a required field.
  • answer can be produced when subsequent nodes execute.
  • error is produced only when an exception occurs.
  • retry_count can be updated during retries.

It is necessary to distinguish type definitions from runtime validation: TypedDict mainly provides static type information and does not automatically guarantee that all runtime inputs conform to the definition. When strict validation is needed, you can use data validation tools such as Pydantic.

4. Defining State with Pydantic

For scenarios that require strict data validation, you can use a Pydantic model to define State.

from pydantic import BaseModel


class AgentState(BaseModel):
    question: str
    plan: str = ""
    answer: str = ""
    retry_count: int = 0

Pydantic can provide:

  • Field type validation.
  • Default value management.
  • Data conversion.
  • Structured data validation.

The choice between TypedDict and Pydantic should depend on the workflow's type constraints, validation requirements, and support in the specific version.

IV. Reducer: State Reduction Mechanism

Reducer is a very important concept in LangGraph state management.

It determines how the updates returned by a node should be merged with the current State.

Without understanding Reducer, it is difficult to correctly handle parallel nodes, list appends, and shared state updates.

1. Default Update Rule: Overwrite

For ordinary fields without a specified Reducer, LangGraph usually uses overwrite updates.

For example:

from typing import TypedDict


class AgentState(TypedDict):
    answer: str

Current state:

{
    "answer": "初始答案"
}

Node returns:

{
    "answer": "更新后的答案"
}

State after update:

{
    "answer": "更新后的答案"
}

The old value is replaced by the new value.

This approach is suitable for:

  • Current task stage.
  • Final answer.
  • Current executor.
  • Current review status.
  • A single configuration value.

2. Using operator.add to Append to a List

When multiple nodes need to append content to the same list, you can define a list Reducer.

import operator
from typing import Annotated, TypedDict


class AgentState(TypedDict):
    documents: Annotated[list[str], operator.add]

Suppose the current state is:

{
    "documents": ["文档 A"]
}

Node returns:

{
    "documents": ["文档 B"]
}

Update result:

{
    "documents": ["文档 A", "文档 B"]
}

Note that the merge semantics of a Reducer depend on the field type and the specified function; not all fields should use operator.add.

3. Custom Reducer

For more complex states, you can define your own reduction function.

For example, when you need to merge the analysis results of multiple Agents and retain all results:

from typing import Annotated, TypedDict


def merge_results(current, update):
    return current + update


class AgentState(TypedDict):
    results: Annotated[list[dict], merge_results]

The reducer takes two parameters:

  • current: the value currently stored in the field.
  • update: the new value submitted by the node.

The return value is the reduced field value.

A custom reducer can implement:

  • List merging.
  • Dictionary merging.
  • Deduplication.
  • Result aggregation.
  • Version comparison.
  • Conflict handling.

For example, merging dictionaries:

def merge_metadata(current, update):
    return {
        **current,
        **update
    }

Note that plain dictionary merging uses the semantics of the latter overwriting the former. If multiple nodes update the same key at the same time, you still need to define explicit conflict-resolution rules.

4. The Core Execution Mechanism of the Reducer

flowchart TD
    A["Current State"] --> C["Reducer"]
    B["Node Returns Update"] --> C
    C --> D["Run Merge Logic"]
    D --> E["Produce Reduced Result"]
    E --> F["Write Back Updated State"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style C fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style D fill:#EAF3EC,stroke:#83A995,color:#315D49
    style E fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style F fill:#DCEFE5,stroke:#4F8B70,color:#24563F

The reducer deals with how state updates are merged, not with how nodes are scheduled.

These two concepts need to be kept distinct:

  • Node scheduling determines which nodes execute.
  • The reducer determines how node updates are applied to the state.

V. Parallel Nodes and State Merging

LangGraph supports multiple nodes running in parallel during the same execution phase.

Parallel nodes may read the same State at the same time and each return a different update.

This raises a key question: how do multiple nodes update the same state field?

1. Parallel Nodes Updating Different Fields

For example:

  • The Research Agent updates research.
  • The Analysis Agent updates analysis.
from typing import TypedDict


class AgentState(TypedDict):
    question: str
    research: str
    analysis: str


def research_agent(state):
    return {
        "research": "收集到技术资料"
    }


def analysis_agent(state):
    return {
        "analysis": "完成初步分析"
    }

The two nodes update different fields, so no field-overwrite conflict occurs.

2. Parallel Nodes Updating the Same Field

If two nodes update the same plain field at the same time, for example:

class AgentState(TypedDict):
    result: str

The Research Agent returns:

{
    "result": "研究结果"
}

The Analysis Agent returns:

{
    "result": "分析结果"
}

Because plain fields use overwrite semantics by default, multiple parallel updates may produce update conflicts.

In LangGraph, when multiple nodes within the same super-step produce updates to the same channel, an InvalidUpdateError may be triggered if that channel has no reducer capable of handling multiple updates.

The correct approach is to define a reducer based on the business semantics.

3. Using a List Reducer to Merge Parallel Results

import operator
from typing import Annotated, TypedDict


class AgentState(TypedDict):
    results: Annotated[list[str], operator.add]


def research_agent(state):
    return {
        "results": ["研究结果"]
    }


def analysis_agent(state):
    return {
        "results": ["分析结果"]
    }

In this way, multiple nodes can submit updates to results, and the Reducer merges them.

Parallel execution process:

flowchart TD
    A["Shared Initial State"] --> B["Parallel Node Scheduling"]

    B --> C["Research Agent"]
    B --> D["Analysis Agent"]
    B --> E["Security Agent"]

    C --> F["Return Results"]
    D --> G["Return Results"]
    E --> H["Return Results"]

    F --> I["Reducer Merge"]
    G --> I
    H --> I

    I --> J["Update Shared State"]

    style A fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style B fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style C fill:#EAF3EC,stroke:#83A995,color:#315D49
    style D fill:#EAF3EC,stroke:#83A995,color:#315D49
    style E fill:#EAF3EC,stroke:#83A995,color:#315D49
    style F fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style G fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style H fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style I fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style J fill:#DCEFE5,stroke:#4F8B70,color:#24563F

4. Ordering Issues with Parallel Results

Parallel nodes may complete in different orders, so you cannot casually assume that the order of the result list always meets business requirements.

If result order is important, you can include the following in each result:

  • Task ID.
  • Node name.
  • Sort order number.
  • Creation time.
  • Result version.

Then a dedicated aggregation node sorts them according to business rules.

For example:

def merge_results(current, update):
    merged = current + update

    return sorted(
        merged,
        key=lambda item: item["order"]
    )

This is more reliable than relying on node completion times.

6. Relationship Between State, Nodes, and Edges

State, Node, and Edge are the three fundamental components of the LangGraph graph execution model.

1. State: Store Shared Data

State describes the data that the entire workflow needs to manage.

For example:

class AgentState(TypedDict):
    question: str
    plan: str
    result: str

2. Node: Execute Tasks and Update State

Node is the execution unit in the graph.

def planner(state):
    return {
        "plan": "先分析需求,再生成答案"
    }

A Node can call:

  • LLMs.
  • External tools.
  • Databases.
  • Retrieval systems.
  • Other Agents.

3. Edge: Control Execution Path

Edge determines how nodes are connected.

A normal edge represents a fixed subsequent node:

graph.add_edge("planner", "researcher")

A conditional edge determines which node to execute next based on the current State:

def route_task(state):
    if state["task_type"] == "research":
        return "researcher"

    return "analyst"

4. Relationship Among the Three

flowchart TD
    A["State: shared state"] --> B["Node reads state"]
    B --> C["Execute node logic"]
    C --> D["Return state update"]
    D --> A

    C --> E["Edge determines execution path"]
    E --> F["Select next Node"]
    F --> B

    style A fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style B fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style C fill:#EAF3EC,stroke:#83A995,color:#315D49
    style D fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style E fill:#F7F4E8,stroke:#C7B77A,color:#675A2D
    style F fill:#E0F0FE,stroke:#93BCE8,color:#1E4976

State is responsible for data, Node for execution, and Edge for flow control.

Together, the three form a complete state-driven execution mechanism.

7. MessagesState and Message State Management

In conversational agents, messages are usually the most important state data.

LangGraph provides MessagesState for managing message lists.

Essentially, it is a predefined state structure that contains a messages field and uses message reducer logic to handle message updates.

1. Using MessagesState

from langgraph.graph import MessagesState


class AgentState(MessagesState):
    user_name: str
    task_status: str

This allows you to manage all of the following at the same time:

  • Conversation messages.
  • User information.
  • Current task status.

2. Using add_messages

Message fields usually require special merge rules.

For example:

from typing import Annotated
from typing_extensions import TypedDict

from langgraph.graph.message import add_messages
from langchain_core.messages import AnyMessage


class AgentState(TypedDict):
    messages: Annotated[
        list[AnyMessage],
        add_messages
    ]

add_messages does more than simply append messages; it also handles updates based on message ID.

Typical behaviors include:

  • New messages are appended to the list.
  • Messages with the same ID can be updated.
  • Message deletion markers are supported.
  • The structure of the message list is maintained.

3. Why Not Simply Use operator.add

For a regular text list:

["消息 A"] + ["消息 B"]

This usually satisfies the need to append.

However, conversation messages may also contain:

  • HumanMessage.
  • AIMessage.
  • SystemMessage.
  • ToolMessage.
  • Tool call information.
  • Message ID.
  • Multimodal content.

Therefore, simply concatenating ordinary lists cannot fully express the semantics of message updates and deletions.

add_messages is better suited for managing LangChain message objects.

4. Update Process for Conversation Message State

flowchart TD
    A["Current Messages"] --> C["add_messages"]
    B["New message or message update"] --> C

    C --> D{"Does message ID already exist?"}

    D -->|"No"| E["Append new message"]
    D -->|"Yes"| F["Update corresponding message"]

    E --> G["Generate new message list"]
    F --> G

    G --> H["Write to State"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style C fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style D fill:#F7F4E8,stroke:#C7B77A,color:#675A2D
    style E fill:#EAF3EC,stroke:#83A995,color:#315D49
    style F fill:#EAF3EC,stroke:#83A995,color:#315D49
    style G fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style H fill:#DCEFE5,stroke:#4F8B70,color:#24563F

8. Input Schema, Output Schema, and Private State

In real applications, a workflow's internal state is often much more complex than what users need to see.

For example, a research Agent may need to store the following internally:

  • The original user request.
  • Task plan.
  • Retrieved documents.
  • Intermediate analysis.
  • Invocation logs.
  • Review comments.
  • Final answer.

But the user only needs the final answer.

LangGraph can use different Schemas to distinguish input, output, and internal state.

1. Input Schema

The Input Schema describes the data structure allowed to be passed in when invoking the workflow.

from typing_extensions import TypedDict


class InputState(TypedDict):
    question: str

2. Output Schema

The Output Schema describes the data structure that the workflow ultimately exposes externally.

class OutputState(TypedDict):
    answer: str

3. Internal State

The internal state contains the data needed during workflow execution.

class OverallState(TypedDict):
    question: str
    plan: str
    research: str
    analysis: str
    answer: str

4. Complete Example

from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END


class InputState(TypedDict):
    question: str


class OutputState(TypedDict):
    answer: str


class OverallState(TypedDict):
    question: str
    plan: str
    research: str
    analysis: str
    answer: str


def planner(state: OverallState):
    return {
        "plan": "制定研究计划"
    }


def researcher(state: OverallState):
    return {
        "research": "收集相关技术资料"
    }


def analyst(state: OverallState):
    return {
        "analysis": "完成技术分析"
    }


def writer(state: OverallState):
    return {
        "answer": (
            f"问题:{state['question']};"
            f"分析:{state['analysis']}"
        )
    }


builder = StateGraph(
    OverallState,
    input_schema=InputState,
    output_schema=OutputState
)

builder.add_node("planner", planner)
builder.add_node("researcher", researcher)
builder.add_node("analyst", analyst)
builder.add_node("writer", writer)

builder.add_edge(START, "planner")
builder.add_edge("planner", "researcher")
builder.add_edge("researcher", "analyst")
builder.add_edge("analyst", "writer")
builder.add_edge("writer", END)

graph = builder.compile()

result = graph.invoke({
    "question": "LangGraph 如何管理状态?"
})

print(result)

This example shows the relationship between the three Schemas:

  • InputState: constrains external input.
  • OverallState: manages the workflow's internal state.
  • OutputState: constrains the final output.

Private State can also be organized through a separate internal Schema or node-specific state fields. Note that whether internal fields are externally visible depends on the graph's input/output Schema and the specific API design; you cannot assume a field automatically gains security isolation just because it is called private.

9. Checkpoint: State Persistence Mechanism

State is responsible for managing data during the current execution, but if the program exits or the service crashes, the in-memory state may also be lost.

LangGraph uses a Checkpointer to save state snapshots during execution.

A Checkpoint is a record of the state at a certain point in execution.

It usually includes:

  • The current graph state.
  • Execution configuration.
  • Task thread identifier.
  • Checkpoint ID.
  • Parent checkpoint information.
  • Pending execution tasks and related metadata.

1. Role of Checkpoint

Checkpoint primarily solves three problems:

State persistence

Save execution state to persistent storage, avoiding complete reliance on memory.

Interruption recovery

After the workflow is paused or exits unexpectedly, execution can continue from a previous checkpoint.

Execution history management

Save state snapshots from multiple execution stages, supporting viewing historical states and performing time travel operations.

2. Difference Between Checkpoint and State

Comparison State Checkpoint
Definition Current workflow state State snapshot at a specific point in time
Lifecycle Changes continuously as the workflow executes Multiple versions are produced over the course of execution
Primary purpose Share data between nodes State persistence and recovery
Whether persistence is guaranteed Not necessarily Saved by the Checkpointer
Typical use Data passing and flow control Recovery, backtracking, human intervention

This can be understood as:

State is the changing workflow state, while Checkpoint is the state record saved at a specific point in time.

3. Checkpoint Execution Process

flowchart TD
    A["Start Graph Execution"] --> B["Load current State"]
    B --> C["Execute a Super-step"]
    C --> D["Nodes commit state updates"]
    D --> E["Apply Reducer"]
    E --> F["Form new State"]
    F --> G["Save Checkpoint"]
    G --> H{"Is the workflow finished"}

    H -->|"No"| B
    H -->|"Yes"| I["Retain final execution state"]

    style A fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style B fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style C fill:#EAF3EC,stroke:#83A995,color:#315D49
    style D fill:#EAE8FA,stroke:#A49BD5,color:#51477D
    style E fill:#F5F8F4,stroke:#B5CBBB,color:#40594A
    style F fill:#DCEFE5,stroke:#4F8B70,color:#24563F
    style G fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style H fill:#F7F4E8,stroke:#C7B77A,color:#675A2D
    style I fill:#DCEFE5,stroke:#4F8B70,color:#24563F

At this point, it is important to understand the concept of a Super-step.

LangGraph uses a Pregel-style execution model to organize graph execution. A Super-step can contain multiple nodes executing in parallel.

Within a Super-step:

  1. Currently executable nodes read their corresponding state.
  2. Nodes run in parallel or according to the graph's execution rules.
  3. Nodes commit state updates.
  4. State updates are reduced through Reducers.
  5. After the current execution stage completes, a new state version is formed.

Checkpoints are usually saved at Super-step boundaries. The exact content and timing of saves are also affected by the execution mode and the Checkpointer implementation.

4. Using MemorySaver to Save State

The following demonstrates using an in-memory Checkpointer:

```python from typing_extensions import TypedDict from langgraph.graph import StateGraph, START, END from langgraph.checkpoint.memory import InMemorySaver class AgentState(TypedDict): question: str answer: str def answer_node(state): return { "answer": f"你提出的问题是:{state['question']}" } builder = StateGraph(AgentState) builder.add_node("answer", answer_node) builder.add_edge(START, "answer") builder.add_edge("answer", END) checkpointer = InMemorySaver() graph = builder.compile( checkpointer=checkpointer ) config = { "configurable": { "thread_id": "conversation_001" } } result = graph.invoke( { "question": "什么是 LangGraph?", "answer": "" }, config=config ) print(result) ```

There are two key concepts here:

  • InMemorySaver: stores checkpoints in memory, which is suitable for development and testing.
  • thread_id: identifies a continuously running workflow thread, and is used to distinguish different execution contexts.

Note that InMemorySaver is not suitable for scenarios that require surviving process restarts or production-grade persistence. Production environments should use a database Checkpointer that fits the deployment architecture.

5. The Role of Thread ID

Thread ID is an important identifier in LangGraph state persistence.

For example:

```python config_a = { "configurable": { "thread_id": "user_001" } } config_b = { "configurable": { "thread_id": "user_002" } } ```

Different thread_ids correspond to different execution threads and checkpoint histories.

This keeps the workflow states of multiple users isolated from one another.

However, note that thread_id itself is not an authentication mechanism. The system still needs to verify whether the caller has permission to access the corresponding thread, and must not allow users to read other users' state by guessing thread_ids.

10. Store: Long-Term Data Storage Across Threads

Checkpoint mainly saves execution state around a single workflow thread.

But in real applications, some information needs to be stored long-term across threads and sessions.

For example:

  • User preferences.
  • Long-term memory.
  • Summaries of historical tasks.
  • User configuration.
  • Reusable business knowledge.

This type of data can be managed through LangGraph Store.

1. Differences Between Checkpoint and Store