Prev Next

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 TypeHow It WorksBest For
ConversationBufferMemoryStores every message verbatimShort conversations where full context matters
ConversationBufferWindowMemoryKeeps only the last k messagesLong conversations; avoids context overflow
ConversationSummaryMemoryUses an LLM to summarise older messagesVery long sessions; quality over token savings
ConversationSummaryBufferMemorySummarises messages beyond a token limit; keeps recent messages verbatimBalance between detail and cost
VectorStoreRetrieverMemoryStores messages as embeddings; retrieves semantically relevant past contextLong-running assistants that need to recall specific facts
ConversationEntityMemoryExtracts and tracks named entities (people, places, concepts) from conversationPersonal 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.

Which memory type keeps only the last k conversation messages to avoid context overflow?
When would VectorStoreRetrieverMemory be more useful than ConversationBufferMemory?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

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...

Show more question and Answers...

Database

Comments & Discussions