AI agent memory is how an AI agent keeps track of what happened before, so it doesn't start from zero every time you talk to it. Think of a coworker who remembers your last meeting, your preferences, and the task you left half done. Without memory, an agent is closer to a stranger you have to brief from scratch, every single time.
That matters most when you ship agents to real people. A demo can get away with forgetting. A product can't. Below you'll learn the two basic kinds of memory, how an agent "remembers" in plain terms, what usually goes wrong, and a simple path to add memory to your first agent.
What is an AI agent, quickly?
An AI agent is a program that uses artificial intelligence (AI) to work toward a goal in several steps. It can read a request, decide what to do, use tools like search or email, and check its own results.
Most agents run on a large language model (LLM). That's the kind of AI behind chat assistants: you send it text, and it sends text back. Here's the catch. The model itself doesn't remember anything between requests. Every answer is based only on what you hand it right then.
So when an agent seems to remember you, something around the model is doing that work. That something is memory.
Why agents forget by default
Picture handing a very smart assistant one sheet of paper. Whatever fits on the sheet, they can use. Whatever doesn't, they've never heard of.
That sheet is called the context window: the text the model can see at one time. It holds your instructions, the conversation so far, and any documents you include. When the conversation ends, the sheet gets thrown away.
The sheet also has a size limit. Long conversations or big files eventually push older details off the page. That's why an agent can nail step two of a task and then forget what you said in step one.
Memory is everything you build to decide what goes on that sheet, and what gets saved for later.
The two kinds of AI agent memory
You'll see lots of labels online. For a beginner, two buckets cover almost everything.
Short term memory: what the agent knows right now
Short term memory is the current conversation or task. It's what's on the sheet of paper at this moment.
If you ask an agent to book a meeting and then say "make it 30 minutes," it knows "it" means the meeting. That's short term memory at work. Once the session ends, it's gone.
Long term memory: what the agent keeps between sessions
Long term memory is information saved outside the model so the agent can use it later. It lives in a regular place like a database or a set of files.
People usually split it into three everyday types:
- Facts about you or the world. "Maria prefers email over calls." "Our refund window is 30 days."
- Past events. "Last Tuesday, the user asked for a report and rejected the first draft."
- How to do things. "When this customer files a bug, tag the mobile team first."
You don't need fancy names for these. Just ask yourself: is this a fact, a past event, or a habit the agent should repeat?
How an agent actually remembers
This part sounds technical, but you already do it with sticky notes.
- Write it down. During or after a conversation, the agent (or your code) picks out things worth keeping and saves them as short notes.
- Find the right note later. When a new request comes in, the system searches the saved notes for anything related.
- Put it back on the sheet. The best matches get added to the context window, so the model can use them in its answer.
Step two is where most of the engineering lives. A simple setup searches by keywords, like your email inbox does. A more advanced setup uses semantic search, which means searching by meaning instead of exact words. With it, a note about "cancel my plan" can match a question about "stop my subscription."
The model never truly remembers. Your system remembers for it and passes the right notes in at the right time.
What goes wrong with agent memory
Memory makes agents more useful. It also creates new ways for them to fail. These are the problems you'll run into first.
It forgets what matters
The agent saves too little, or the search step misses the right note. The user repeats themselves and loses trust fast.
It remembers the wrong thing
Old facts stick around after they change. A user moved to a new city, but the agent keeps suggesting restaurants near the old address. Memory needs a way to update and replace notes, not just add them.
It remembers too much
If you save everything, the search step starts pulling in noise. Answers get slower, pricier, and less focused. More memory isn't automatically better memory.
It mixes people up
This one's serious. If notes from one user show up in another user's answers, you have a privacy problem. Every note needs to belong clearly to one person or one account.
It keeps things it shouldn't
Some information shouldn't be stored at all, like passwords or health details you didn't ask for. Users also expect a way to see and delete what an agent remembers about them.
A practical way to add memory to your first agent
If you're building an agent you plan to share, here's a sensible order. It keeps things simple until you actually need more.
- Start without long term memory. Get the agent working well inside one conversation first. Many problems that look like memory issues are really unclear instructions.
- Write down what's worth remembering. Make a short list: which facts, events, or habits would save the user time next session? If you can't name them, you don't need memory yet.
- Store notes somewhere boring. A regular database table with a user ID, the note, and a date is plenty to start. Boring is easy to debug.
- Add smarter search only when notes pile up. Once simple lookups miss things, try semantic search. You don't need it on day one.
- Decide how notes get updated or forgotten. Pick rules for replacing old facts and clearing out stale ones. Dates on every note make this much easier.
- Test with real conversations. Have a few people use the agent over several days. Check what it saved, what it pulled back in, and where it got things wrong.
- Let users see and delete their memory. It builds trust, and depending on where your users live, privacy rules may require it.
You'll also hear about ready made memory tools, such as Mem0, Zep, Letta, and Cognee. They can save you work later. Still, try the plain version first so you understand what those tools are doing for you.
How Anthropic layers Claude's memory, and the cleanup job it calls dreaming
Added November 11, 2026. On November 6, 2026, Anthropic published how it thinks about memory for Claude. It's the same sticky note idea from above, with a name for each layer and a plan for keeping the notes honest. Here's how it lines up with what you just read.
Picture memory as a stack, from the big messy bottom to the small tidy top:
- Logs and transcripts. The full record of what happened in each session. Nothing gets lost, but it's far too big to read every time, so the agent searches it when it needs something.
- Memory notes. Short notes the agent writes because they'll matter later. That's the "write it down" step from earlier.
- Structured pages. Notes organized so the agent can find its way around, like a small wiki: one page per subject, with links to related pages. In Anthropic's tests, this helped most when Claude could also run a normal search.
- Injected context. A short set of notes loaded onto the sheet of paper at the start of every session, so the agent doesn't have to look for them. Anthropic says this layer has to stay small. Every injected note takes up room on the sheet, and a wrong note gets carried into every single session.
That top layer is where "it remembers too much" and "it remembers the wrong thing" hurt the most.
Dreaming: a cleanup pass between sessions
Anthropic's fix is something it calls dreaming, a nod to how sleep helps people sort through the day. In plain terms, it's a cleanup job that runs offline, between conversations, instead of while the agent is busy helping someone. It rereads the transcripts and then:
- checks the notes against what really happened, and rewrites the ones that are wrong
- merges duplicates and builds or updates the linked pages
- decides which few notes move up into the small layer that loads every time, and pushes extra detail back down
Anthropic's example is easy to picture. While playing Pokémon Red, Claude saved a note with the wrong location for a landmark, and that note kept steering it back the way it came. A dreaming pass compared the note with the session transcript, caught the mistake and rewrote it. With the fixed note, Claude went back into the cave and made it to the next city.
You can copy the idea without any special tool. Take the boring notes table from step 3 of the plan above. Once a night, run a job that asks the model to compare recent notes with recent conversation logs, fix or delete the wrong ones, merge duplicates, and keep a short list of notes worth loading at the start of every session. The dates from step 5 make this much easier.
Tell the agent what memory is for, not how to use it
One more tip from the same post. On a test where an agent has to learn from its earlier answers, Anthropic simply told Claude that a memory folder was available. That general hint was enough for its newer models to use memory well and get a noticeable boost. So in your agent's instructions, say what memory is for ("keep what will help you with this user's next request") instead of scripting every save and every lookup.
None of this replaces the advice above. Start with the plain version. Add layers and a cleanup job once your notes start to pile up or go stale.
What this means if you're learning to build agents
Memory is where a lot of agent projects stop feeling like demos and start feeling like products. It pulls together several skills at once: working with databases, designing search, handling user data responsibly, and testing how a system behaves over time.
The good news is that none of it is magic. If you understand the sheet of paper, the sticky notes, and the search step, you understand the core idea. The rest is practice: building an agent, watching it forget, and fixing it.
If you want a structured path to build agents like this with mentors on hand when you get stuck, explore how the 4Geeks AI Engineering program works. You can also compare it with other 4Geeks programs to see which pace fits you.
If you are looking for structured AI training, review our AI programs side by side: length, level and outcomes.
