In July 2025 Chroma tested 18 language models and every one grew less reliable as its input got longer. A bigger context window is not AI memory. AI memory lets an AI agent store, recall and update user preferences and conversation history across sessions. This guide shows how AI memory works, which types of memory exist and where each one fails. It also explains how to choose between long term memory, short term memory and retrieval from a knowledge base.
What AI memory is and how it works, from model weights to persistent memory
AI memory defined: store, recall and update information across sessions
AI memory is a system that lets an AI model store, recall and update data across sessions. A memory layer saves key facts from previous interactions and injects the relevant ones into the next prompt. Memory systems combine machine learning models with semantic search over a vector database. Memory management decides what each system keeps. The model knows what it learned in training. The memory holds what the system learned about this user.
Why a model forgets everything between two requests
A language model is stateless. Each request starts from the text you send and nothing else. An AI agent built on that model starts every task with a blank page. The feeling of continuity in a chat comes from the application, which resends the chat history inside the context window with every call. When the session ends or the window fills up the history disappears. A user who returns the next day meets a model that has never heard of them.
AI memory and memory chips: two different topics
The same two words also name hardware: high bandwidth memory chips and the stocks of their makers dominate some search results. This guide covers the memory of AI systems: how a model keeps and recalls data for a user. It does not cover chip supply or storage hardware.
Layer 1: parameters, what the model learned during training
The first layer sits inside the model. During training the weights of the transformer architecture absorb patterns and facts from the training data through deep learning. A 2025 survey of memory in AI agents (Hu et al.) calls this the parametric form and names two others: token-level and latent. It works like general knowledge with no record of who asked what. Nobody can edit it at request time and it stops at a cutoff date.
Layer 2: the context window and the KV cache
The second layer is the context window: everything the model reads for one request. Inside it the transformer keeps a KV cache: the stored attention keys and values of tokens already processed. It does not recompute them for each new token. This is working memory for one call. It is fast and volatile. It also uses GPU memory. The vLLM team managed this cache in fixed blocks with PagedAttention. Serving throughput rose by 2 to 4 times at the same latency (Kwon et al., SOSP 2023).
Layer 3: retrieved memory with embeddings and a vector database
The third layer sits outside the model. Documents are split into passages and an embedding model converts each one into embeddings: lists of numbers that place similar meanings close together. A vector database provides the external storage. At request time the question in natural language becomes a vector. Vector search returns the closest passages and the retrieval step places them in the context. The model never learns them and reads them again at every call. The typical failure is a wrong recall: a passage that looks close but answers another question.
Layer 4: persistent memory written between sessions
The fourth layer is persistent memory. After a session the system writes selected facts to a store, such as a decision. It can capture a stated preference this way. At the next session it reads that fact back so the assistant can remember it as one of its long term memories. This memory layer is what ChatGPT memory and Claude memory offer in the consumer app and what an AI agent reads before a task. Its failure is a stale or contradictory memory: the user changed their mind and the store did not notice.
Did you know?
On 10 April 2025 OpenAI let ChatGPT reference all past conversations, starting with Pro and Plus users and excluding the EEA and the UK at launch. Anthropic added memory to Claude for Team and Enterprise on 11 September 2025 with a separate memory per project.
The AI memory stack: how the four layers fit together
The four layers are rarely drawn on one page. The map below stacks them from the model outward and shows the full memory architecture. For each layer it gives the content, the lifetime, the writer, the cost and the failure mode. A last line names the closest human analogue and where it stops working.
Each layer you add trades permanence for control and shifts the access pattern. Parameters are permanent and nobody can edit them. The persistent layer is editable but it needs rules to update and to delete.
Types of AI memory: what the human analogy explains and where it breaks
Short-term memory and long-term memory in AI
Short term memory is what the system holds during one session: the conversation so far and the tool results inside the context window. Long term memory is what survives the session in a store. Each memory type maps onto the layers above: short term onto layer 2 and long term onto layer 4. Layer 3 sits between them because it lasts but holds documents and not what happened with this user.
Working, episodic, semantic and procedural memory
Cognitive psychology describes four types of memory that engineers borrowed. Each one maps onto something concrete:
- Working memory: the active context window for the AI agent’s task in hand.
- Episodic memory: events from past sessions of an AI agent with this user, such as the chat history of a trip compared last week.
- Semantic memory: facts and general knowledge held in parameters or in a knowledge graph.
- Procedural memory: how to do things, held as instructions, rules and tool definitions.
The human taxonomy has no single agreed count. Treat the labels as a design aid and not as a standard.
Where the analogy to human memory breaks
Human memory is rebuilt at each recall and it fades. An AI store behaves differently. It writes a record once and copies it with no loss. It can be edited or deleted on demand. It does not fade unless someone designs a rule for it. A recalled item is plain text placed in the context window and not a reconstructed trace. Forgetting has to be designed.
Expert tip:
Write the forgetting rule before the writing rule. Decide what expires, what a newer fact overrides and what a user can erase.
Choosing a mechanism: context window, retrieval or memory layer
When a long context window is enough
If the information fits in the context window, does not change and does not need to outlive the session, send it in the prompt. The cost grows with every call and you accept the limits described in the next section. The main risk is drift: the longer the input the less reliably the model uses it.
When retrieval (RAG) fits
Use retrieval when the knowledge base is large and changes often or when answers must cite a source. A product catalog and a policy library are typical cases. The knowledge base stays outside the model and you update it without retraining. RAG is a memory of documents and not of people. It lets an AI agent cite a source for each answer. Its main risk is a passage that looks relevant but is not the right one.
Memory versus RAG: the difference that decides the design
People mix them up because both retrieve text. The difference is the direction of travel. Retrieval reads a corpus that already exists. A memory writes structured facts that the system learns about a user during use. Retrieval cannot know that a fact changed unless someone reindexes. A memory must handle updates and contradictions. The publisher of Mem0 reports that its memory layer cut p95 latency by 91% and saved over 90% of tokens. The baseline is processing the full context (Chhikara et al., arXiv, April 2025).
Did you know?
The 91% and 90% figures are measured against feeding the full context to the model and they come from the publisher itself. Check them against your own workload before you rely on them.
When you need a persistent memory layer
You need a persistent memory layer when the information must survive the session and can change and must be both explainable and erasable. Think of a client who explores a trip over three visits in a multi-session journey or compares two properties over two weeks. The system must recall what was said last time and which statement is current. It must also let the user or the company delete it. Privacy and access rules become part of the setup.
A five-question selector: context window, RAG or memory layer?
Five closed questions are enough to see which mechanism a case needs. The selector below asks them and returns a mechanism for your AI agent and the main risk to watch. It is an indicative tool and not a benchmark.
If the answer is a memory layer the next question is governance: who can read the memory, who can correct it and how it is erased. The last section shows how we answer it.
From concept to system: where agent frameworks start
Choosing the mechanism is half of the work. Building it is the other half: update policies, summaries, forgetting rules and the tools that a coding agent or any other AI agent uses to create and update memory. The setup is mostly code that decides what to capture and when to retrieve it. Our separate guide to agent memory covers those topics in practice. The Model Context Protocol (MCP) is the common interface. An MCP server exposes memory tools that an AI agent calls through an API. A framework handles the workflow around those calls. Our guides to AI agent platforms and to AI agent orchestration show where memory sits in an enterprise multi-agent setup.
What bigger context windows did not fix: the limits of AI memory (2023-2026)
Lost in the middle: why position inside the context matters
Liu and colleagues tested how language models use long inputs. Performance was highest when the relevant information sat at the beginning or at the end of the context. It dropped when the information sat in the middle (TACL, 2024). The effect is called lost in the middle and it appeared even in models built for long contexts. Performance also fell as the input grew longer. A larger window gives more room but it does not give uniform attention.
Context rot: longer input, less reliable output
Chroma extended the finding in July 2025. It evaluated 18 models including GPT-4.1, Claude 4 and Gemini 2.5. Every model grew less reliable as the input length increased even on basic tasks. The authors call it context rot. For a memory design it means that pushing the whole history into the prompt is not a safe default.
Announced context versus served context
Vendors advertise large windows. Meta announced on its AI blog a context window of 10 million tokens for Llama 4 Scout in April 2025. At launch several providers capped it at 128,000 tokens (Groq and Fireworks) or 328,000 (Together) as Simon Willison noted on 5 April 2025. A window that exists on paper is not a memory you can rely on in production. Check the limit your provider serves and test recall at that length.
Timeline 2023-2026: what changed and what did not
The table below dates each result and states what it means for the design of an AI memory.
Read the table as one argument. The 2023 work on the KV cache made long contexts cheaper to serve. The 2024 and 2025 studies showed that cheaper does not mean better used. A bigger window did not remove the need for a memory that is selective, weighted and governed.
Stale, wrong and private memories
A persistent memory can hold a fact that stopped being true. It can also hold two facts that contradict each other or a personal detail the user never agreed to keep. Each case needs a rule in the update process: an update policy, a state for doubtful facts and a way to delete. Under Article 17 of the GDPR a person can ask for the erasure of personal data. Log each write with its source so that a team can inspect a doubtful fact. Our guide to agentic AI covers the project-level risks.
How Kleio designs AI memory for high-consideration purchases
What a buying journey asks of a memory
A trip, a property or a car is bought over several visits and from several sources. The buyer states a budget in one session and clicks a higher price band in the next. The CRM holds a third version. A memory that treats those signals as equal will often be wrong. At enterprise scale that error repeats across every buying journey. Our Knowledge Engine keeps three purpose-built stores for product, document and memory data with a separate layer for configuration and governance. This section covers the memory store.
Weighting each memory by the reliability of its source
Our Memory Store weighs evidence. It turns every signal into an observation, then a claim and finally a belief. Each source carries a default weight. What the buyer said counts for 0.95 and the interface for 0.90. The CRM scores 0.70 and an inference 0.50. Observed behavior scores 0.30 and a default value 0.10. These are default priors that we tune per deployment. A click weighs less than a stated budget.
Contested beliefs: asking a question instead of guessing
When two sources disagree the belief enters a contested state. The AI agent then asks the buyer a question instead of guessing. The policy that weighs the sources is versioned and deterministic with no LLM in the loop. Each outcome is reproducible and auditable.
Expert tip:
Test any memory with a contradiction. Store two conflicting facts and see whether the system guesses or asks.
Governed memory: scoped, explainable and deletable
Memory in our platform is anonymous by default and scoped by deployment. Each belief links back to the observations behind it and a user can delete it in one gesture. Tenant isolation and SOC 2 compliance apply to this store like the rest of the platform. These properties let an AI agent handle the three risks of the previous section: stale facts, contradictions and erasure.







