Conversation Buffer Memory

1. What is Conversation Buffer Memory?

ConversationBufferMemory is LangChain’s simplest memory type. It stores the entire chat history (user + AI messages) and sends it back to the model on every new request.

In short:

It lets the AI remember what was said earlier in the conversation.


2. Why does it exist?

LLMs are stateless by default.

Without memory:

User: My name is John
User: What is my name?
AI: I don’t know

With buffer memory:

AI: Your name is John

So memory solves context loss.


3. Real-world analogy

Think of:

  • ❌ No memory → talking to a person with amnesia

  • ✅ Buffer memory → a person who remembers everything you said so far

But note:

  • It remembers everything, even irrelevant parts

  • That can become expensive and noisy


4. Minimal working example (Gemini)

What happens internally?

  • First call → memory stores: “My name is John”

  • Second call → full history is injected into the prompt

  • Model answers correctly


5. What does the memory actually store?

Output (roughly):

It’s plain text, not embeddings or summaries.


6. Key characteristics (important)

Feature
ConversationBufferMemory

Stores

Full conversation

Grows over time

Yes

Token usage

High

Summarization

❌ No

Best for

Short conversations


7. Common beginner mistakes

❌ Using it for long chats → token explosion ❌ Assuming it’s smart memory (it’s just text) ❌ Using it in production without limits


8. When NOT to use it

Avoid ConversationBufferMemory if:

  • Chat is long-running

  • Cost/token usage matters

  • Only recent context is needed

Use instead:

  • ConversationBufferWindowMemory

  • ConversationSummaryMemory


9. One-line mental model

ConversationBufferMemory = append entire chat history to every prompt

Last updated