Blog

How AI memory works in agents and apps

AI memory is the system that lets an AI app or agent keep information between conversations. The language model itself keeps nothing from one request to the next. A memory system saves what matters, such as a preference, a decision or a fact about a user. Later, it finds the entries related to a new request and adds them to the prompt.

We build CrystalBrain, one memory that your AI apps share, so the last section shows how we handle each point below in our own product.

What is AI memory?

AI memory is everything an assistant can recall that is not in the current conversation. A language model answers from its prompt and from what it learned in training. It does not keep anything between two requests. The CoALA paper on language agents says it in one line: “Language models are stateless: they do not persist information across calls” (Sumers et al., 2024).

So when an assistant seems to remember you, an application has put text back into its prompt. Within one conversation, that text is the conversation so far, held in the model’s context window. Across conversations, the text has to come from a store that the application writes to and reads from. That store, with the rules for what goes in and what comes out, is what people call AI memory, long-term memory or persistent memory. This article uses “long-term memory” for it.

What types of memory does an AI agent use?

An agent uses a short-term working memory and three kinds of long-term memory. The four names come from cognitive science, and the CoALA paper applies them to language agents.

TypeWhat it holdsExample
Working memoryWhat the agent uses for the current step: the prompt, the latest messages, results so farThe last messages of a support chat
EpisodicPast events and interactionsOn March 3, the customer reported a late delivery
SemanticFacts about the world or about the userDeliveries go to the warehouse in Lyon
ProceduralHow to act: rules, steps and instructionsConfirm the order number before any refund
The four memory types described in the CoALA paper, with an example of each in a customer-facing app.

Each type needs different handling. Episodes pile up and need a summary. Facts change and need correcting. Procedures have to apply every time, and a search may not return them when they are needed. So a long-term memory needs a way to tell them apart, such as a type on each entry.

How does long-term memory work?

Most long-term memory systems run the same four steps, whatever the storage behind them.

1Write
The app or the model picks what to keep from a conversation.
2Store
Each entry is saved with the user, the topic and the date.
3Search
Before an answer, a search finds the entries related to the request.
4Use
The entries found go into the prompt, next to the request.
The loop of a long-term memory: an entry is written once, then found and added to the prompt whenever a request needs it.

Writing

Some systems let the model save an entry itself, through a tool it calls when it hears something worth keeping. Others run a separate step after each conversation to extract facts. The memory tool of the Claude API is of the first kind. Claude reads and writes files in a /memories directory, and your application runs each file operation against storage you control (Claude Platform Docs, checked November 21, 2026).

Searching

Most systems search by meaning. The request and each entry are turned into embeddings, which are lists of numbers, and the entries closest to the request come first. Many systems add filters on the user or the topic, and a short summary that is always sent.

Fitting it into the context window

The context window limits how much text the model can read at once. MemGPT, a 2023 research system now called Letta, borrowed the idea of memory tiers from operating systems. It keeps a small part of the memory in the context window and moves information in and out as the task needs it (Packer et al., 2023).

Why not put the whole history in the context window?

Context windows have grown, so it is tempting to send the whole history with every request. Two problems remain.

The first is cost. The model provider bills every token of the prompt, and a long history is sent again with each request. Our token counter shows what a given prompt costs with Claude.

The second is accuracy. In “Lost in the Middle”, researchers found that models used information best when it sat at the beginning or the end of a long prompt. Performance “significantly degrades” when the relevant passage sits in the middle (Liu et al., 2023). A long-term memory sends only the entries related to the request, so the prompt stays short and the useful facts are not buried among unrelated ones.

Choosing what goes into each prompt, and what stays out, is called context engineering. Our guide to context engineering for AI apps covers the main strategies.

What is the difference between AI memory and RAG?

RAG, or retrieval-augmented generation, searches a set of documents and adds the passages it finds to the prompt. Long-term memory uses the same search step, so the two are often confused. Claude’s search of your past chats is one example. Anthropic says these searches “use Retrieval-Augmented Generation (RAG)” (Claude Help Center, checked November 21, 2026).

The difference lies in what is stored and how it changes. RAG reads documents that people write and maintain elsewhere, such as a manual or a wiki. A long-term memory holds short entries that the AI writes itself, about one user or one task. Those entries go out of date. A customer moves, a decision is reversed, a preference changes. So a long-term memory needs operations that RAG rarely needs:

  • update an entry when the user corrects it;
  • archive an entry that no longer applies;
  • merge two entries that say the same thing;
  • delete everything about one person.

How do ChatGPT, Claude and Gemini remember you?

All three assistants have memory features. Here is what their help pages say, as of November 21, 2026.

  • ChatGPT. ChatGPT can draw on past chats, saved memories, custom instructions, saved files and connected apps such as Gmail, depending on your plan and region. You review it in Settings, then Personalization, then Memory. OpenAI notes that deleting a chat “does not necessarily delete a separate saved memory created from that chat” (OpenAI Help Center).
  • Claude. On paid plans, Claude can search your past chats. Its memory is organized in topics that you can read, edit or delete in Settings. Anthropic calls the import and export of memory between Claude and other AI services experimental (Claude Help Center).
  • Gemini. Google personalizes Gemini from your past chats, from the Google apps you connect and from your instructions. It works only with a personal Google Account, and Google says the features are “not available to everyone at this time” (Gemini Apps Help).

Each of these memories stays inside its own assistant. What you tell ChatGPT does not reach Claude, and an agent you build cannot read either one. A memory shared by several tools has to live outside them, and each tool reaches it through a connector such as an MCP server. The memory MCP page explains how that works.

What goes wrong as a memory grows?

A long-term memory that only grows gets harder to trust. Three problems come back most often.

Duplicates and contradictions

The same fact gets saved twice in different words. Later, its opposite gets saved too. A search can then return both versions, and the model picks one. We describe how this happens, and how to catch it, in how an AI memory ends up contradicting itself.

Entries nobody can see

If users and teams cannot read what the AI stored, they cannot fix a wrong entry. The wrong entry then keeps coming back in answers. Reading every entry does not scale, so figures help to choose where to look. Measuring whether an AI memory helps covers the memories the AI never reads and the ones that have gone stale.

Personal data

A memory about your users holds personal data. When someone asks what you store about them, or asks to be deleted, the memory has to answer too. Read what does your AI store about our users for the first question, and deleting a user from an AI memory for the second.

Update (November 26, 2026): the services a memory reads from can set limits too. On November 24, 2026, Google made its Workspace MCP servers for Gmail, Drive, Docs, Sheets, Slides, Calendar, Chat and Tasks generally available. It also said AI agents must reach Workspace data through those servers or the Workspace CLI, not the REST APIs, with technical enforcement from February 1, 2027 (Google Workspace Updates). Google’s new Workspace AI Tools Addendum “does not allow permanent raw storage, model training, extended retention of derived data, or API scraping,” and “derived and user data are removed within a defined window and when a user disconnects” (Google Cloud Blog, November 25, 2026). An agent that saves facts drawn from a user’s Gmail or Drive into its memory has to plan for that deletion. Neither post gives the length of the window.

Should each user have their own memory?

Yes, as soon as an app serves more than one person. The memory needs a key, which is the user each entry is about. Without that key, a fact about one customer can show up in another customer’s answer. With it, each search reads only the entries of the user it serves.

A product with several AI features, such as a support chatbot, an n8n workflow and an in-app assistant, should share one memory per user instead of keeping three. One memory per user, many AI apps explains how to set that up.

Which AI memory tools can developers use?

Several services and open-source projects give an app or agent a long-term memory. The table sums up how four of them describe themselves in their own repositories, checked November 21, 2026, next to CrystalBrain.

ToolWhat it isHow you use itWhat it puts forward
Mem0Describes itself as an intelligent memory layer for AI assistants and agentsA Python or TypeScript library, a self-hosted server or a cloud platformSince April 2026, extraction only adds memories and overwrites nothing. Search mixes meaning, keywords and entities
Zep and GraphitiZep is a context service for companies, built on the open-source Graphiti frameworkZep as a managed service or in your own cloud, Graphiti self-hostedA knowledge graph that tracks how each fact changes over time and links it to its source
LettaA platform for agents that keep their own memory, formerly MemGPTA terminal app, a server, a TypeScript SDK or Letta CloudAgents that keep their state and memory, and learn and improve over time
SupermemoryDescribes itself as the memory and context layer for AIAn API, plugins and an MCP server for coding agents, or self-hostingUser profiles, contradiction handling, expiry of old facts, connectors to Google Drive, Gmail and Notion
CrystalBrainOne memory that your AI apps shareMCP for Claude, ChatGPT, Gemini and coding agents, a REST API, TypeScript and Python SDKsTyped memories per user and per brain, a dashboard to read and fix them, contradictions in a Review queue
Five AI memory tools, as their own documentation describes them on November 21, 2026.

The right choice depends on where the memory has to live and who needs to see it. Mem0 and Graphiti can run on your own servers, so the storage stays fully yours. Zep fits data where the history of each fact matters. Supermemory also brings in documents from tools like Google Drive and Notion. CrystalBrain is built for one memory shared by several AI apps, which people can read and correct.

Building the memory yourself is the other option. Build or buy an AI memory layer lists the pieces a memory needs once it is in production, and when building them yourself makes sense. The next section shows how CrystalBrain works.

How we handle memory in CrystalBrain

CrystalBrain is one memory your AI apps share. Claude, ChatGPT, Gemini, your agents and your own app read and write it, and you can see and fix every memory. Here is how it handles the points above.

  • One memory per user, split by topic. The structure is workspace, then user, then brain, then memory. A user is one of your customers, named by the ID it has in your app. A brain is one topic of that user, such as a project or a client, and every user starts with a brain named General. A search reads the brains of one user, plus any brain shared with that user’s groups.
  • Typed entries. Each memory has one of 13 types, such as fact, preference, decision, procedure or constraint. The dashboard sorts them into nine sections. Decisions get their own tab, with a status: proposed, accepted or superseded.
  • Checks. CrystalBrain refuses a near-duplicate of a memory already in the same brain when it is saved. On paid plans, memory checks run each day on the memories that changed. Each contradiction they find goes to a Review queue, where you keep one version or both.
  • Control. You can read, edit and archive every memory, see the ones the AI never used, and set a date after which a memory stops being used. Deleting a user permanently takes two steps, with 7 days to cancel.
  • Connections. Apps that support MCP connect with a link. The Connections page gives the steps for Claude, ChatGPT and Gemini, and for coding agents such as Claude Code, Cursor and Codex. Workflows and your own code use the REST API or the TypeScript and Python SDKs.

The CrystalBrain home page describes the product and its plans, including the free plan.

FAQ

Does ChatGPT have long-term memory?

Yes. ChatGPT can use saved memories and past chats to personalize its answers, depending on your plan and region. You manage it in Settings, then Personalization, then Memory. That memory stays inside ChatGPT.

Is RAG a form of AI memory?

RAG is the search step that most long-term memories use. RAG alone reads documents that people maintain. A long-term memory also writes, updates and deletes its own entries about a user or a task.

What is the difference between short-term and long-term memory in AI?

Short-term memory is what the model sees during one conversation, held in its context window. Long-term memory is stored outside the model, and a search brings the right entries back into later conversations.

Can you delete what an AI remembers about you?

In ChatGPT, Claude and Gemini, you can review and delete remembered items in the settings. In ChatGPT, deleting a chat does not always delete a memory created from it, so check both. In a product built on a memory service, deletion depends on what that service offers.

Sources

Free up to 25 tracked users, no card.

Start free