LangGraph's checkpointing mechanism allows saving agent state at any node, enabling resume and context preservation across conversations. This guide covers checkpoint configuration, state persistence strategies, and production applications.
LangGraph's checkpointing mechanism is key to building reliable agents, enabling state saving at any point for resume and error recovery.
from langgraph.checkpoint.memory import MemorySaver
checkpointer = MemorySaver()
app = graph.compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "session-123"}}
result = app.invoke({"messages": ["hello"]}, config)
config = {"configurable": {"thread_id": "session-123"}}
history = list(app.get_state(config))
app.update_state(config, {"messages": ["new message"]})
状态保存和恢复验证通过
检查点机制工作正常