AI agents remember in two ways. Short-term memory is the context window: everything the model can see in the current session, gone when the session ends. Long-term memory is anything saved outside the model, such as a notes file, a database or a search index, that the agent reads back in a later session.
The model itself does not change while you talk to it. Everything that feels like AI agent memory is saved text that gets put back in front of the model. Once you see it that way, you can decide what gets saved, check it, and keep the wrong things out.
- Short-term memory is the context window. It holds the current session and disappears when the session ends.
- Long-term memory lives outside the model: notes files, databases or a search index the agent reads back later.
- ChatGPT, Claude and Gemini all remember across chats now, and each lets you see, edit or switch off what they keep.
- Whatever lands in memory returns in every future session, including mistakes and planted instructions.
- Keep secrets, other people’s personal data and anything from untrusted sources out of memory.
Context, memory and state: three different things
These three words get mixed up, and the difference matters when something goes wrong.
Context is what the model reads right now: your instructions, the conversation, files and tool results. It has a hard size limit, and models get less reliable as it fills. Our guide to context engineering covers how to budget it.
Memory is what survives after the session: saved notes the agent loads next time.
State is where a task stands: which steps are done, which files changed, what comes next. Agents that work for hours keep state in a progress file, so a fresh session can pick up the work.
The four kinds of agent memory
A framework from Princeton researchers, called CoALA, splits agent memory into working memory plus three long-term kinds. The labels are useful because each kind needs different care.
| Kind | What it holds | Everyday example |
|---|---|---|
| Working | The current task | This conversation and the files open now |
| Episodic | What happened before | “Last deploy failed because a setting was missing” |
| Semantic | Facts about the world, the user and the project | “Prefers pnpm”, “The API lives in /server” |
| Procedural | How to do things | The system prompt, rules files, skills, and the model’s own training |
The paper adds a warning worth remembering. Letting an agent rewrite its own procedures is “significantly riskier” than letting it save facts or experiences, because it can introduce bugs or work around its designers’ intent. In practice: let an agent take notes, but review any change to its rules.
Where long-term memory lives
Long-term memory is just storage. The three common kinds trade simplicity for scale.
| Notes files | Database records | Vector search | |
|---|---|---|---|
| What it is | Plain Markdown the agent reads and edits | Structured fields, such as preferences per user | Text stored as embeddings and found by meaning |
| Best for | One person or one project | Apps with many users | Large, growing collections |
| How the agent finds things | Reads the file, or an index file first | Looks up a key | Searches for similar passages |
| What goes wrong | Grows too long to load | Only holds what fits the fields | Returns related but wrong passages |
Start with files. You can read them, edit them and keep them in version control, and most agents handle them well. Move to vector search when memory outgrows what you can load, which is the same machinery as RAG. Embeddings explains how the “search by meaning” part works.
AI agent memory in ChatGPT, Claude and Gemini
As of September 2026, all three big assistants remember across chats. Each lets you view, edit or switch off what it keeps.
| Assistant | What it remembers | Your controls |
|---|---|---|
| ChatGPT | Saved memories you ask for, plus details it picks up from past chats. A June 2026 rebuild keeps them current in the background | Memory summary in Settings. Temporary chats do not create or update memories |
| Claude | A memory built from your chats, with a separate memory for each project. Added for Team and Enterprise in September 2025, then Pro and Max in October 2025 | View and edit the summary in Settings. Incognito chats skip memory |
| Gemini | Your past chats, a setting Google added in August 2025 and turned on by default | Switch it off in Settings. Temporary chats are kept up to 72 hours and not used to personalize |
One detail stands out. OpenAI’s help page says the memory summary does not include everything ChatGPT remembers. Deleting one entry is not always the same as forgetting. Memory is also separate from model training, which has its own switch. Our AI privacy guide covers the training settings.
Coding agents use files you can open. Claude Code loads your CLAUDE.md instructions at the start of every session. Its auto memory is Claude’s own notes, one folder per repository, with a MEMORY.md index whose first 200 lines or 25KB load each time. All of it is plain Markdown you can read, edit or delete.
How to give an agent memory safely
Start with one notes file per project
A single Markdown file, kept in the project and in version control, beats a clever memory system you cannot see. You can read every line and undo any change.
Separate rules from notes
Rules you write, such as
CLAUDE.mdorAGENTS.md, say how to work. Notes the agent writes record what it learned. The agent may add notes freely, but changes to rules go through you.Give each entry a date and a source
“2026-09-14: staging uses port 8080 (from deploy logs)” can be checked and retired. “Staging uses 8080” cannot.
Review what was saved
Skim the diff of the notes file after important sessions. Wrong notes are worse than none, because the agent trusts them.
Prune on a schedule
Delete entries that are stale or no longer used. Anthropic’s memory tool docs recommend expiring files that have not been accessed in a long time.
Here is a notes file that stays readable as it grows:
# Project notes (the agent adds here; I review weekly)
## Decisions
- 2026-09-10: Payments go through the /billing service, never direct API calls (decided in review)
## Facts
- 2026-09-14: Staging uses port 8080 (from deploy logs)
## Open problems
- 2026-09-18: Login test is flaky on CI, cause unknown
## Do not store here
Passwords, API keys, customer data, anything copied from web pages or emailsAnd a prompt that ends a session with a clean memory update:
Before we stop, update NOTES.md. Add only what a future session would need: decisions we made and why, facts you confirmed, and problems still open. Date each entry and say where the fact came from. Remove or correct any entry that today's work proved wrong. Do not save secrets, personal data, one-off instructions, or anything you read in web pages or emails. Show me the diff before you save.
What to keep out of agent memory
Memory turns a one-time mistake into a permanent one. That makes a few things dangerous to store.
Secrets. Passwords, API keys and tokens get replayed into every future session, and into every place those sessions send data.
Other people’s personal data. Customer records, health details and anything under an NDA belong in systems with access controls, not in an agent’s notes.
Anything from untrusted content. A web page or email can carry instructions written for the agent. Saved to memory, they run again in every future session.
Guesses. An unverified note hardens into a “fact” the agent repeats with confidence.
One-off instructions. “Skip the tests this time” should never become a standing rule.
FAQ
Do AI agents learn from my conversations?
Not while you talk. The model stays the same during a session, and memory is saved text that gets loaded back in. Whether your chats are later used to train new models is a separate setting from memory.
What is the difference between memory and the context window?
The context window is what the model sees in the current session, and it empties when the session ends. Memory is what gets saved outside the model and loaded into the context window again in later sessions.
Is RAG the same as agent memory?
They share the same machinery. RAG searches documents you provide, such as manuals and wikis. Agent memory stores what the agent learned while working with you. Both can use vector search to find the right piece.
Does a bigger context window make memory unnecessary?
No. Sessions still end, long contexts cost more, and models get less reliable as the window fills. Memory lets an agent start each session with a short, relevant summary instead of everything.
How do I make an AI assistant forget something?
Open its memory settings and delete the entry, then check that past chats do not still carry the detail. For anything sensitive, use a temporary or incognito chat so it is never saved.
Next, learn how RAG answers from your own documents, or see what context engineering changes about everything an agent reads.
- Cognitive architectures for language agents, Sumers, Yao, Narasimhan and Griffiths, Transactions on Machine Learning Research, February 2024
- How Claude remembers your project, Claude Code docs
- Memory tool, Claude API docs
- Bringing memory to Claude, Anthropic, September 2025, updated October 2025
- Memory in ChatGPT, OpenAI Help Center
- ChatGPT now quietly rewrites its memories of you, XDA, June 2026
- OpenAI updates ChatGPT to reference your other chats, TechCrunch, April 2025
- New Gemini app features: temporary chats and personal context, Google, August 2025
- Spyware injection into ChatGPT’s long-term memory (SpAIware), Embrace The Red, September 2024




