AI / LangGraph LangChain Interview questions
What are persistence patterns in LangGraph?
Persistence in LangGraph means saving graph state so it survives process restarts, can be resumed after interrupts, and can be inspected or replayed at any past checkpoint. All persistence goes through the checkpointer interface, so the storage backend is swappable without changing application code.
| Checkpointer | Storage | Use Case |
|---|---|---|
| MemorySaver | Python dict, in-process | Development, unit tests |
| SqliteSaver | SQLite file | Single-process apps, CLI tools |
| AsyncSqliteSaver | SQLite file (async) | Async single-process servers |
| PostgresSaver | PostgreSQL | Multi-process production (sync) |
| AsyncPostgresSaver | PostgreSQL (async) | Multi-process production (async FastAPI) |
from langgraph.checkpoint.sqlite import SqliteSaver import sqlite3 conn = sqlite3.connect("checkpoints.db", check_same_thread=False) saver = SqliteSaver(conn) graph = graph_builder.compile(checkpointer=saver) # Retrieve past state for a thread state = graph.get_state({"configurable": {"thread_id": "user-1"}}) # List all past checkpoints for checkpoint in graph.get_state_history({"configurable": {"thread_id": "user-1"}}): print(checkpoint.config, checkpoint.created_at)
More Related questions...