Glossary
Conversation buffer memory
Conversation buffer memory is a chatbot memory pattern that stores every message in a conversation and sends the full history back to the model with each new request.
Conversation buffer memory is the simplest form of chatbot memory: the application keeps every message in the conversation, in order, and sends the whole list back to the language model with each new request. Nothing is summarised, filtered or dropped, so the model sees exactly what was said. The name comes from LangChain, whose ConversationBufferMemory class made the pattern a common default for early chat applications, but the idea is framework-independent and appears in almost every chat product in some form. It is accurate and easy to build. Its limits are cost and size: every turn makes the next request longer, and a long enough conversation no longer fits in the model’s context window.
How conversation buffer memory works
A language model has no memory between calls. To give the impression of an ongoing conversation, the application stores the history and replays it. With a buffer, the flow for each user message is the same.
Append. The new user message is added to the end of the stored list of messages.
Assemble. The system prompt, the full message list and the new message are combined into one request.
Call. The model generates a reply using everything in that request.
Store. The reply is appended to the list, ready for the next turn.
In LangChain’s original implementation, the buffer was exposed to the prompt under a key such as “history”, either as one formatted string or as a list of message objects. Other frameworks and most chat APIs do the same thing with a messages array. The buffer is a form of short-term memory: it lives for one conversation thread and is usually discarded or archived when the session ends.
What it does well
Buffer memory is lossless within its window. Because the model sees every word, it can answer questions about anything said earlier, follow references such as “the second option you mentioned”, and keep track of corrections the user made along the way. There is no extraction step that might misread a statement, and no summary that might drop a detail. For short conversations, which make up a large share of real chat traffic, this is the most accurate approach available and also the cheapest to build.
It is also easy to debug. What the model saw is exactly the stored history plus the system prompt, so reproducing a bad answer means replaying the same list.
Where it breaks down
The problems all come from growth. Each exchange adds tokens, and every later request pays for all of them again.
Exchanges so far | Approximate input tokens per request | Cumulative input tokens across the session |
|---|---|---|
5 | 3,500 | 11,500 |
10 | 6,500 | 38,000 |
20 | 12,500 | 136,000 |
40 | 24,500 | 512,000 |
The table assumes a 500-token system prompt and about 600 tokens per exchange of user message and reply. Input per request grows linearly, so the total cost of a session grows roughly with the square of its length. A 40-exchange support conversation can consume well over half a million input tokens before anyone looks at the bill. Input vs output tokens explains why input usually dominates, and where your tokens go breaks down a typical request.
Agents make this worse. When an agent calls tools, the results usually enter the same message list: a search result, a database row, a page of a PDF. One tool call can add thousands of tokens that are resent on every later turn, long after they stopped being useful. Teams building AI agents with tool use often find that tool output fills the buffer faster than the conversation itself, and that trimming old tool results is the first and easiest saving.
Size is the second limit. Once the buffer exceeds the context window, the request fails or the application has to cut messages. Accuracy degrades before that point: models handle long inputs less reliably, a pattern described as context rot, and facts buried in the middle of a long history are the most likely to be missed, which is the lost in the middle effect.
The third limit is scope. A buffer only covers the current session. When the user comes back tomorrow, the buffer is empty unless the application reloads old transcripts, and reloading them brings back all of the cost and size problems at once. Cross-session continuity needs long-term memory.
Variants that bound the buffer
Several variants keep the buffer idea but limit its growth.
Window buffer. Only the last k exchanges are kept. In LangChain this was ConversationBufferWindowMemory. Cost per request becomes constant, but anything outside the window is forgotten, including the context the user gave at the start.
Token buffer. Messages are dropped from the oldest end once the buffer exceeds a token limit. This targets the context window directly and handles messages of uneven length better than a fixed count.
Summary buffer. Recent messages stay verbatim and older ones are compressed into a running summary, combining a buffer with conversation summary memory. This keeps immediate context exact while bounding cost, at the price of losing detail from the summarised part. Summarization vs memory covers why that loss is permanent.
Related techniques work on the prompt instead of the history, such as context compression and context pruning, which remove redundant or irrelevant content before the call. Prompt caching can make the static part of each request cheaper, though the growing history still changes on every turn.
Conversation buffer memory and other memory types
Memory type | What it stores | Survives the session | Cost as conversation grows |
|---|---|---|---|
Buffer | Every message verbatim | No | Grows linearly per request |
Window buffer | Last k messages | No | Constant |
Summary | A running summary | Sometimes | Roughly constant |
Facts per person, product or project | Often | Roughly constant | |
Long-term extracted memory | Facts, preferences and events | Yes | Roughly constant, retrieved per request |
Buffer memory is one end of a spectrum covered under conversational memory. At the other end are systems that extract durable facts and retrieve them with memory retrieval, so that each request carries only what is relevant. Memory vs context window explains why a larger context window postpones the buffer’s problems without removing them.
Framework support today
Agent frameworks have moved away from standalone memory classes. LangChain has deprecated its legacy memory classes, including ConversationBufferMemory, and points developers to LangGraph, where conversation state is persisted per thread through checkpointing. The behaviour is the same buffer underneath: the thread’s messages are saved after each step and loaded before the next. Trimming, summarising or filtering the messages is left to the developer. The comparisons Exabase vs LangChain and Exabase vs LangGraph memory look at where a dedicated memory layer fits alongside these tools, and the agent framework entry covers the wider landscape.
A worked example
A small team builds a customer support agent with buffer memory. In testing, conversations run five or six exchanges and answers are excellent. In production, a minority of tickets run past 30 exchanges as customers paste logs and the agent asks follow-up questions. Those long tickets end up accounting for most of the team’s token spend, and in a few of them the agent contradicts what the customer said near the start, because the key detail now sits deep in a 20,000-token history.
The fix keeps the buffer for the last eight exchanges, which preserves exact recent context, and moves everything else into long-term memory. Facts such as the customer’s plan, the affected order and the troubleshooting steps already tried are extracted as the conversation goes and retrieved when relevant. Input per request stops growing with ticket length, and the agent stops losing the early details. The same customer returning a week later now gets an agent that remembers the ticket. How to cut token costs describes this pattern more generally, and the token cost calculator estimates savings for a given traffic profile.
When to use it
Buffer memory is a sensible default when conversations are short, sessions do not need to connect to each other, and the cost per conversation is small. Prototypes, internal tools and single-question assistants fall into this group. Move to a bounded buffer once sessions regularly exceed a dozen exchanges, and add long-term memory once users expect the agent to remember them between sessions or once spend grows faster than usage. When to outgrow your framework’s built-in memory lists the signals in more detail. A quick check is to log input tokens per request against the turn number: if the line keeps rising through a session, the buffer is driving cost.
Where Exabase fits
Exabase does not replace the session buffer, which stays in your application; it provides the long-term layer that lets you keep the buffer short. You send conversations or raw text to Exabase Memory, and its M-1 engine extracts facts, preferences and events, resolves contradictions as facts change and consolidates related memories over time. Before each model call, memory search returns the few relevant memories, using semantic and keyword retrieval with recency bias, so the prompt carries a few hundred tokens of facts instead of the full history. In Exabase’s illustrative example, a request drops from about 15,100 input tokens to about 2,800, roughly 81% fewer, with the agent logic and model unchanged.
The about memories and creating memories guides cover setup, and memory can be scoped per user or customer with Bases. The reduce token costs and agent memory solutions explain the approach in full.
Frequently asked questions
What is conversation buffer memory?
It is a memory pattern in which the full list of messages in a conversation is stored and sent back to the model with every new request, so the model sees the entire conversation verbatim.
Is ConversationBufferMemory deprecated in LangChain?
Yes. LangChain has deprecated its legacy memory classes, including ConversationBufferMemory, and recommends LangGraph persistence, which stores a thread’s messages through checkpointing.
What is the difference between buffer memory and window buffer memory?
Buffer memory keeps every message. Window buffer memory keeps only the last k exchanges, which caps cost but forgets earlier context.
When does conversation buffer memory stop working well?
When conversations grow long. Each request gets larger and more expensive, accuracy drops on long inputs, and eventually the history exceeds the context window.
Does buffer memory persist between sessions?
Not by itself. It covers one conversation thread. Remembering users across sessions needs long-term memory that stores and retrieves durable facts.
How can I reduce the cost of buffer memory?
Bound the buffer with a window or token limit, summarise or extract older content, and retrieve only the facts relevant to each request instead of resending everything.
Related pages: Conversational memory, Conversation summary memory, Short-term memory, Context window, Checkpointing, Memory vs context window, LangChain alternatives, What a 200-message conversation really costs, Reduce token costs, Exabase Memory