LangChain deprecated its memory classes (ConversationBufferMemory etc.). What replaced them and why?
Quick Answer
Conversation state moved to LangGraph's persistence model: a checkpointer stores each conversation thread's state in a real backend (Postgres/Redis/SQLite), keyed by thread ID. The old memory classes held state in process RAM — lost on restart, unshareable across replicas, and unsafe for multi-user apps.
Detailed Answer
ConversationBufferMemory and friends were fine for demos but structurally wrong for production: state lived in the Python process, so a pod restart wiped every conversation, horizontal scaling broke session affinity, and there was no per-user isolation story. The replacement pattern treats chat history as externally persisted state: LangGraph compiles your agent/chain into a graph with a checkpointer (e.g., PostgresSaver); each turn loads the thread's state, runs the graph, and persists the new state atomically. This gives restart-safety, multi-replica correctness, time-travel debugging over past states, and a clean place for retention policies. On top of raw history, long-term memory (facts that persist across threads) is handled separately — e.g., a store the agent reads/writes deliberately — which also forces you to confront fact-conflict problems (a user changing a stated preference must overwrite, not coexist with, the old fact). For interviews: in-process memory = demo; checkpointer-backed thread state = production.
Code Example
from langgraph.checkpoint.postgres import PostgresSaver
from langgraph.prebuilt import create_react_agent
checkpointer = PostgresSaver.from_conn_string(PG_URI)
agent = create_react_agent(model, tools, checkpointer=checkpointer)
agent.invoke({'messages': [msg]},
config={'configurable': {'thread_id': f'user-{uid}'}})Interview Tip
Frame it as a stateless-service principle: conversation state is data, and data belongs in a datastore, not in process RAM. That's an ops answer, not just a LangChain answer.