AI / LangGraph LangChain Interview questions II
What are the different memory types in LangChain?
LangChain provides several memory classes that differ in how they store and compress conversation history. Choosing the right one involves balancing context quality, token cost, and retrieval precision.
| Memory Type | How It Works | Best For |
|---|---|---|
| ConversationBufferMemory | Stores every message verbatim | Short conversations where full context matters |
| ConversationBufferWindowMemory | Keeps only the last k messages | Long conversations; avoids context overflow |
| ConversationSummaryMemory | Uses an LLM to summarise older messages | Very long sessions; quality over token savings |
| ConversationSummaryBufferMemory | Summarises messages beyond a token limit; keeps recent messages verbatim | Balance between detail and cost |
| VectorStoreRetrieverMemory | Stores messages as embeddings; retrieves semantically relevant past context | Long-running assistants that need to recall specific facts |
| ConversationEntityMemory | Extracts and tracks named entities (people, places, concepts) from conversation | Personal assistants that must remember facts about people/topics |
In LCEL-based applications, the memory pattern has shifted from these classes towards explicitly managing a messages list in chain state (with RunnableWithMessageHistory for automatic persistence per session ID), or using LangGraph's checkpointing for full state persistence.
More Related questions...