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)
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
