Archive/AGENTS

Memory for AI agents: what to store, what to forget

Working, episodic, semantic and procedural memory, and the rules for writing, retrieving, updating and deleting each without creeping users out.

Memory for AI agents: what to store, what to forget

Language models are stateless: every request starts from nothing except what you send. Agents and assistants that seem to remember you are built on top of a memory system that decides what to save from each interaction, what to retrieve next time, and what to update or forget.

Getting memory right makes an assistant feel genuinely helpful: it remembers your preferences, avoids asking the same questions twice and builds on past work. Getting it wrong makes it feel either forgetful or invasive, and can create real privacy and security problems. This guide covers the types of agent memory, what to store, how to retrieve and update it, when to forget, and the privacy controls users need.

Why the context window is not enough

A large context window lets a model read a lot at once, but it does not persist across sessions, has no notion of importance, and gets more expensive and less reliable as it fills up. Memory is a separate system that selects what matters and re-inserts it when relevant. We cover the distinction in detail in context windows are not memory.

Four types of agent memory

Cognitive science distinctions are a useful frame, and research such as Sumers et al. (2023), "Cognitive Architectures for Language Agents" (CoALA), applies them to LLM agents.

Types of memory in AI agents
TypeWhat it holdsExampleTypical storage
Working memoryThe current task statePlan, recent steps, intermediate resultsThe context window
Episodic memoryRecords of past interactions and events"On 3 March the user asked to move the weekly sync"Logs, summaries, vector store
Semantic memoryStable facts and preferences"Prefers metric units; works in Lisbon; manager is Ana"Structured profile, key-value store
Procedural memoryHow to do things"For this customer, invoices go to the finance inbox"Instructions, rules, learned workflows

Most practical systems combine a structured store for semantic facts, a searchable store for episodes, and procedural knowledge kept in prompts or configuration.

What to store

Store information that is useful later, stable enough to rely on, and appropriate to keep.

Good candidates:

Usually not worth storing:

A simple test: would a thoughtful human assistant write this down in their notes about the person? If it would feel odd or intrusive for a human to note it, do not store it.

How to write memories

jsonmemory-record
{
  "id": "mem_2391",
  "user_id": "u_118",
  "statement": "Prefers meeting summaries in French",
  "type": "preference",
  "source": "conversation 2026-08-02, user stated explicitly",
  "confidence": "explicit",
  "created": "2026-08-02",
  "last_confirmed": "2026-08-02"
}

How to retrieve memories

Retrieve selectively, based on the current task, not all at once.

Retrieval quality matters as much as storage. The same techniques used for document retrieval apply; see RAG chunking strategies compared.

Updating and resolving conflicts

Facts change. The user moves, changes jobs or reverses a preference. Without update logic, memory accumulates contradictions and the agent uses outdated facts.

Forgetting

Forgetting is a feature, not a failure.

Privacy and trust

Memory is where AI products most often feel creepy. Design for user control from the start:

Asking before saving sensitive or inferred memories is a natural fit for human-in-the-loop patterns.

Shared and organisational memory

Not all memory belongs to one user. Team assistants and enterprise agents often need shared memory: project decisions, team conventions, customer histories. Shared memory adds governance questions:

Treat shared memory more like a knowledge base with editorial ownership than like personal notes.

Testing memory

Memory bugs are hard to spot in single-session tests. Build multi-session evals: scenarios where a fact is stated in session one, changed in session two and needed in session three. Check that the agent uses the current fact, does not surface deleted memories, and does not leak memories between users. See evaluating agents end to end for broader agent evaluation.

Frequently asked questions

How do AI agents remember things between sessions?

The application stores selected information, such as preferences, facts and summaries of past interactions, in a database, then retrieves relevant items and adds them to the model's context in later sessions. The model itself does not retain anything between requests.

What should an AI assistant remember about users?

Explicit preferences, stable facts about their context, decisions and ongoing work that will be useful later. Avoid one-off details, offhand remarks and sensitive information unless the user wants it remembered and the product needs it.

How do I handle outdated memories?

Check for conflicts when writing new memories, replace or mark superseded facts, expire time-bound information, and confirm with the user when a stored fact may have changed.

How can users control what an AI remembers?

Provide a view of stored memories, the ability to edit or delete individual items, an option to turn memory off, and notifications when new memories are saved. Deletion should remove derived data such as embeddings and summaries too.

RK
WRITTEN BYRafael KimAgents and tooling. Has personally been booked into a yurt by a language model.

Keep reading

Liked this? The Sunday Diff has one like it every week.