AI Memory: How Neural Network Remembers Like the Human Brain

What type of memory does AI use? Four kinds: weights, context window, retrieval store and agent state. Each fails differently, so choose by workload.

AI Memory: How Neural Network Remembers Like the Human Brain
Written by TechnoLynx Published on 11 Oct 2024

AI does not have one memory. Asking what type of memory AI uses gets you four answers, because information can sit in four places: the model’s parameter weights, the context window it reads during a call, an external retrieval store, and persistent agent state that is written down between sessions. Each is written differently, holds different things and breaks in its own way. That makes the choice between a longer context, a retrieval (RAG) layer and durable agent memory an architecture decision, not a product feature you switch on.

One clarification first. None of this is about hardware memory. GPU VRAM and system RAM decide what fits on the device, which is a separate question. This article is about where a model keeps information and how it gets that information back.

Does AI actually have memory, and what type of memory does AI use?

Yes, in the engineering sense: information that was stored earlier affects behaviour later. The four locations differ in who writes to them and when.

  • Parameter weights. Knowledge is learned during training. Geva et al. (EMNLP 2021) showed that transformer feed-forward layers, which make up two-thirds of a model’s parameters, work as key-value memories: each key matches textual patterns in the training data and each value shifts the probabilities over the next token. The same work found that lower layers capture shallow patterns and upper layers capture more semantic ones.
  • The context window. This is the text the model reads on a single call: the prompt, the conversation so far and any retrieved documents. The CoALA authors (Sumers, Yao et al.) note that language models on their own do not persist information across calls.
  • A retrieval store. This is an external index the system queries and copies into the context. In CoALA’s terms, retrieval reads from long-term memory into working memory, and it can be rule-based, sparse or dense.
  • Persistent agent state. These are facts, preferences, logs and progress notes that the application writes during use and reads back in later sessions. LangGraph’s documentation calls this long-term memory: data stored across sessions and shared between conversation threads.

Older recurrent networks hold memory in a different way. An LSTM carries a cell state, and forget, input and output gates control what is kept, added and emitted at each timestep. The aim was a short-term memory that could last thousands of timesteps. In language modelling, Transformers have been shown to scale better than LSTMs on text. Our explainer on NLP algorithms and how models process text covers that shift in more detail.

How AI memory works inside a neural network, and where the human comparison stops

Inside the network, memory is either fixed (weights) or temporary (activations and the attention context for the current input). A model’s weights do not change during a conversation. It conditions on the input in its context. Between conversations with the same deployed model, anything that looks like “learning” happens because a program outside the model chose to write something down and feed it back later.

Agent design borrows its memory vocabulary from cognitive science. CoALA draws on cognitive architectures such as Soar, where working memory holds current perceptions, goals and intermediate reasoning, and long-term memory splits into procedural, semantic and episodic stores. An agent learns by writing experiences to long-term memory, through read and write access its designers define. That is why agent memory can be inspected and audited, and also why it only knows what it was built to save.

What does “limited memory AI” mean in the textbook taxonomy of AI types, and how does that label relate to today’s LLM memory architectures?

“Limited memory AI” is Type II in Arend Hintze’s taxonomy of AI types. In that scheme, Type I reactive machines such as IBM’s Deep Blue form no memories and respond only to the current board. Type II limited-memory machines look a little way into the past. Hintze’s example is a self-driving car that tracks other vehicles’ speed and direction over time, but those observations are transient and are never saved as experience the car can learn from.

The label describes how a system behaves, not how it is built, so it maps onto today’s systems only loosely. A single LLM call fits Hintze’s Type II quite well: it uses recent context and keeps nothing afterwards. An agent with a persistent store that it writes to and reads from no longer fits, because it does save experience across sessions. If a vendor calls a product “limited memory AI”, ask which of the four locations it actually uses. For a contrast with models that carry recurrent state inside the network, see sentiment analysis algorithms and their memory needs.

Types of AI agent memory and the architecture behind each

CoALA divides an agent’s memory into short-term working memory and three long-term stores: episodic, semantic and procedural. LangGraph’s documentation uses the same three long-term types, alongside a recall-scope split between short-term memory scoped to one thread and long-term memory that spans threads.

Memory type What it holds How it is usually built
Working (short-term) Current inputs, active goals, retrieved knowledge and reasoning results for this decision cycle The context window, plus thread-scoped message history saved by the agent runtime
Episodic Records of past events and actions An event log or memory stream the agent can retrieve from, often used to recall how a task was done before
Semantic Facts about the world, the user and the agent itself An external database, vector index or knowledge graph, often used for personalisation
Procedural How to act Implicitly the LLM weights, explicitly the agent’s code, such as a skill library

Published agents show how these combine. ReAct has no semantic or episodic memory, so it never retrieves or learns. Voyager keeps a hierarchical library of code skills as procedural memory and adds new skills as it goes. Park et al.’s Generative Agents store a complete natural-language record of each agent’s experiences, combine it into higher-level reflections over time and retrieve them to plan. In CoALA’s reading, those reflections are written from episodic into semantic memory.

CoALA’s design advice is a useful discipline: decide which memory modules the application needs, then define read and write access to each one. In the paper’s retail-assistant example, that means semantic memory for the catalogue, episodic memory for each customer’s history, procedural memory for the query functions and working memory for the dialogue state.

Can AI remember past conversations, and what is actually happening when a chatbot product appears to “remember” a user?

The model does not remember. The application around it does. When a chatbot with memory seems to know you, the product stored something earlier and put it back into the current context.

OpenAI describes two mechanisms in ChatGPT: saved memories, and referencing recent conversations. Free users get a lighter version giving short-term continuity, while Plus and Pro get a longer-term understanding of the user. Both can be turned off in Settings. Temporary Chat neither uses nor updates memory, and OpenAI says it may use memories to improve its models unless the user opts out in Data Controls.

Anthropic’s memory tool for Claude makes the mechanism explicit. Claude creates, reads, updates and deletes files in a memory directory that persists between sessions. The tool runs client-side: Claude requests the file operations and your application carries them out, so you decide where the data is stored. Anthropic suggests pairing it with compaction, which summarises the conversation on the server as it nears the context limit, while memory files keep what has to survive that summary.

For system design, the question is not whether the model can remember. It is who owns the store, what gets written to it, and who can read or change it.

When is a longer context window the right answer, when is a retrieval (RAG) layer, and when does a workload need durable long-term agent memory?

Use a long context when the material for a task is bounded, fits well within the length the model handles reliably, and you can afford to send all of it every time. Use retrieval when the corpus is too large or too costly to send in full. Use durable agent memory when information has to outlast sessions and change over time.

Li et al. (EMNLP Industry 2024) found that long-context models consistently beat RAG on average when given enough resources, while RAG’s much lower cost remained a clear advantage. Their Self-Route method lets the model route each query to RAG or long context based on self-reflection, cutting compute while keeping performance comparable to long context.

The context length on the spec sheet is not the length you can rely on. In the RULER benchmark (Hsieh et al., COLM 2024), every model tested claimed 32K tokens or more, but only half held satisfactory performance at 32K, and almost all fell below the threshold before their claimed length, despite near-perfect needle-in-a-haystack scores. Liu et al. found accuracy was highest when the relevant information sat at the start or end of the input, and dropped significantly when it sat in the middle. Chroma’s 2025 context-rot report tested 18 models and found performance consistently fell as input grew, with sharper drops when the question matched the relevant text less closely and uneven effects from distractors.

Long contexts also cost hardware. For the hardware side of long contexts, see NVIDIA HPC-Benchmarks for memory sizing.

Workload signal Lean towards Main trade-off
Bounded documents per task, well within the model’s effective length, budget allows full input Long context Higher cost per call than RAG; accuracy drops for material buried mid-context
Large or growing corpus, answers depend on a small relevant slice RAG Much cheaper than full context, but lower average accuracy in Li et al.’s comparison
Mixed queries, some needing the whole document Hybrid routing Extra routing logic in exchange for lower compute at comparable quality
User facts, preferences or task progress that must persist and be corrected over time Durable agent memory Outdated facts must be updated or invalidated, and the store secured against untrusted writes

The CoALA authors expect that a longer context window could reduce the importance of long-term memory. That may come true. Even so, we favour a modular memory layer (a retrieval store or an explicit long-term store) over putting everything into the prompt. The reason is observability: when an answer is wrong, you can see what was retrieved or stored and fix that one component. The default gives way when a task truly needs the whole document in view at once, and in that case long context is the right tool. TechnoLynx’s Generative & Agentic AI R&D practice builds agentic systems around this kind of modular, observable memory layer.

Where each memory architecture fails in production

The core problem with AI memory in production is that each location fails in its own way. You can only debug a memory failure if you know which location failed.

Weights go stale. Knowledge in the parameters changes only through training. RULER also found that as context grows, models lean more on parametric knowledge and sometimes ignore the context they were given.

Context windows degrade. LangGraph’s documentation warns that a full history may not fit in the window at all, which causes an unrecoverable error, and that even when it fits, models get distracted by stale or off-topic content while becoming slower and more expensive. On top of that come the lost-in-the-middle effect and context rot described above.

Retrieval returns the wrong slice. Zep’s authors argue that RAG as usually built assumes a mostly static corpus, which suits documents better than continuously changing conversational and business data. That is their framing, but it matches a structural fact: a retriever can only return what was indexed, ranked by how well it matches the query.

Persistent memory goes stale and can be poisoned. Knowledge updates (a user changing jobs, for instance) are one of the five abilities LongMemEval tests. Zep’s design addresses them by using an LLM to spot contradictory facts and marking old graph edges invalid while keeping their history. In 2024, Johann Rehberger (Embrace The Red) showed that prompt injection from a third-party website could plant false long-term memories in ChatGPT that persisted into future conversations, and that memories carrying spyware instructions could exfiltrate every later chat. He noted that the exfiltration route was mitigated, but untrusted content could still invoke the memory tool to store arbitrary memories. Treat any write path into long-term memory as an attack surface.

What frameworks add memory to AI agents, and how should you evaluate them?

Several memory designs and tools are now available. MemGPT applies an operating-system idea, virtual context management, moving data between memory tiers so a fixed context window behaves like a larger one. Mem0 extracts, consolidates and retrieves key facts from ongoing conversations. Zep builds a temporally-aware knowledge graph (Graphiti) with episodic, semantic-entity and community subgraphs, and combines cosine-similarity, BM25 and breadth-first graph search before reranking. LangGraph provides thread-scoped and cross-thread memory as framework primitives, and Anthropic’s memory tool offers file-based persistence that your application controls.

Read the headline numbers as claims made by their own authors. The Mem0 paper reports a 26% relative improvement on an LLM-as-judge metric over OpenAI’s memory, a 91% lower p95 latency than full context, and over 90% token savings. The Zep paper reports accuracy gains over a full-context baseline on LongMemEval_s of 15.2% with gpt-4o-mini and 18.5% with gpt-4o. A Zep post then challenged Mem0’s use of LoCoMo. It argued that conversations of roughly 16,000 to 26,000 tokens fit easily in modern context windows, and pointed out that Mem0’s own results showed a simple full-context baseline scoring about 73% against Mem0’s best of about 68%. The same post noted that LoCoMo has no knowledge-update questions and that one category lacked ground-truth answers.

The benchmarks measure different things. LoCoMo’s conversations average 600 turns and about 16K tokens over up to 32 sessions. LongMemEval uses 500 questions covering information extraction, multi-session reasoning, temporal reasoning, knowledge updates and abstention, and reports a 30% accuracy drop for commercial assistants and long-context LLMs over sustained interactions. Many of these results also use an LLM as judge, and a 2024 survey of benchmark contamination notes that LLM judges can themselves suffer from benchmark contamination.

When comparing frameworks, we would check four things before looking at any leaderboard:

  • whether it handles knowledge updates and contradictions explicitly, rather than only appending new facts;
  • whether you can inspect, edit and delete stored memories, and trace which ones were retrieved for a given answer;
  • who controls the storage and how writes from untrusted content are blocked;
  • how it performs against a full-context baseline on your own private held-out conversations.

That last check matters most. If a memory layer cannot beat sending the whole conversation on conversations of your real length, you are adding complexity you don’t need. If it can, the benefit should show up as lower cost and latency as well as accuracy.

FAQ

What happens when you reach the context window limit?

If the full history does not fit in the window, the call fails unless the history is summarised first. LangGraph’s documentation describes this as an irrecoverable error.

What is context window compaction?

Compaction summarises the conversation as it approaches the context limit, so the active context stays small. Anthropic suggests pairing it with a memory store that keeps the information the summary would otherwise lose.

Is there an AI with unlimited memory?

Every model has a finite context window. Memory stores can grow over time, but long-context accuracy already falls before the advertised limit.

Back See Blogs
arrow icon