Conversation State is the “notepad” that your AI agent carries throughout a conversation. It remembers what was said, what files were uploaded, what decisions were made, and where the conversation is heading.
CN: Conversation State 就是 AI Agent 在整个对话过程中随身携带的“记事本”。它记住了说过什么、上传了什么文件、做了什么决定、对话正在往哪个方向走。
Imagine you’re a waiter at a busy restaurant. You have a small notepad for each table. Table 3 ordered appetizers, Table 7 has a gluten allergy, Table 5 is celebrating a birthday. You don’t memorize everything—you write it down. That notepad is your “state.” When you come back to Table 3 later, you check your notepad to remember what they ordered and what they need next. LangGraph’s Conversation State is exactly that notepad—but for your AI agent.
CN (比喻): 想象你是一个繁忙餐厅的服务员。你为每一桌客人准备了一个小记事本。3号桌点了前菜,7号桌有麸质过敏,5号桌在过生日。你不会把一切都记在脑子里——你写下来。那个记事本就是你的“状态”。当你后来回到3号桌时,你查看记事本,记起他们点了什么、下一步需要什么。LangGraph 的 Conversation State 就是那个记事本——不过是给 AI Agent 用的。
Core Contents
3.1 State(状态)—— 数据容器
State is a shared data structure passed between nodes in a LangGraph. Every node reads the current state and returns updates (partial state). The graph accumulates these updates over time.
CN: State 是在 LangGraph 的节点之间传递的共享数据结构。每个节点读取当前状态并返回更新(部分状态)。图会随时间累积这些更新。
3.2 Reducers(归约器)—— 如何合并更新
EN: When multiple nodes return updates to the same state key, how should those updates be merged? Reducers define this logic. For example, operator.add appends new messages to the existing list rather than replacing it.
CN: 当多个节点对同一个 state key 返回更新时,这些更新应该如何合并?Reducer(归约器)定义了这种逻辑。例如,operator.add 将新消息追加到现有列表中,而不是替换它。
This is critical: without reducers, later nodes would overwrite previous state. With reducers, state accumulates intelligently.
CN: 这点很关键:没有 reducer,后面的节点会覆盖之前的状态。有了 reducer,状态就能智能地累积。
3.3 Checkpointer(检查点器)—— 持久化机制
EN: A checkpointer saves a snapshot of the entire graph state at each step. Think of it like Git for your agent’s memory. It enables:
- Persistence: State survives across invocations
- Recovery: Resume from where you left off if something crashes
- Multi-thread: Each conversation thread has its own isolated state
CN: Checkpointer 在每一步都保存整个图状态的快照。可以把它想象成 Agent 记忆的 Git。它实现了:
3.4 Thread(线程)—— 对话隔离
EN: A thread is a unique conversation identifier (like a thread_id). Each thread maintains its own independent state. This allows your agent to handle thousands of concurrent conversations without mixing them up.
CN: Thread 是唯一的对话标识符(类似 thread_id)。每个线程维护自己独立的状态。这使得你的 Agent 可以处理成千上万的并发对话而不会混淆.
EN: Think of threads like different chat windows in a messaging app. Each window has its own history, and they don’t interfere with each other.
CN: 可以把 Thread 想象成通讯 App 中的不同聊天窗口。每个窗口都有自己的历史记录,互不干扰。

