AI agent memory is how an agent carries useful information from one session to the next. Because a model's context window is finite, agents keep a short working memory for the current task and a separate long-term store of facts, events and preferences, which they retrieve selectively, summarize, update and deliberately forget.
- Working memory holds the task at hand; long-term memory outlives the session and has to be retrieved on purpose.
- A bigger context window doesn't remove the problem: models use information buried in the middle of long inputs less reliably.
- Episodic memory records what happened, semantic memory what is true; mixing them turns one-off events into rules.
- Retrieval precision matters more than storage size, because a wrong memory recalled with confidence does more harm than none.
- Every stored fact needs a date and a source so it can expire or be overridden.
- Forgetting is maintenance: decay, demote and delete on a schedule.
What is agent memory?
Agent memory is information an AI system keeps after a conversation ends and can bring back in a later one. A stateless assistant starts from zero every time: you explain your project, your preferences and your constraints again in each session. An agent with memory starts from what it already knows. That sounds like pure gain, but every remembered item has a cost, and the longer something is kept, the greater the chance it will be recalled at the wrong moment.
The research vocabulary is useful here. The CoALA framework (Cognitive Architectures for Language Agents, by Sumers, Yao, Narasimhan and Griffiths) describes a language agent with modular memory components and separates four kinds. Working memory holds what is active in the current decision. Episodic memory stores experience from earlier interactions. Semantic memory stores knowledge about the world and the agent itself. Procedural memory is how the agent acts, held partly in the model's weights and partly in the agent's code.
Consider a scheduling assistant that remembers "this client prefers morning calls". Storing that line is trivial. The hard parts are everywhere else: noticing that it is worth keeping, finding it again when a meeting request arrives, and dropping it when the client moves to another time zone. Cross-session memory is mostly an access problem, and the design effort collects on the retrieval side.
Working memory vs long-term memory
Working memory is the material of the current task: the request, the files open, the last few steps. It is fast to use but narrow, and it loses meaning when the task ends. Long-term memory is broad and durable, but only a small part of it is in front of the model at any moment. Keeping the two layers apart is a necessity. If temporary details leak into long-term storage, a one-off situation starts behaving like a permanent rule. If durable facts stay only in working memory, they vanish when the session closes and the agent relearns them every time.
Well-built systems define a promotion rule between the layers. A note moves from working to long-term memory only when it passes a threshold: it has proven useful more than once, it applies beyond the current task, or the person explicitly asked the agent to remember it. Too loose a rule fills long-term memory with noise; too strict a rule means the agent never learns.
| Dimension | Stateless assistant | Agent with long-term memory |
|---|---|---|
| Lifespan of information | Ends with the session | Extends across sessions |
| Starting point | From zero each time | From what it has kept |
| Main risk | Rebuilding context again and again | Recalling a stale or wrong memory |
| Maintenance | Almost none | Managing staleness, conflicts and noise |
| Privacy surface | Small | Grows with everything stored |
Why a bigger context window is not enough
The context window is the amount of text a model can consider at once. Windows have grown dramatically, which invites a tempting shortcut: keep the whole history and let the model sort it out. Two findings argue against it.
First, models don't use long inputs evenly. In "Lost in the Middle" (Liu and colleagues, published in TACL), performance was often highest when relevant information occurred at the beginning or end of the input and degraded significantly when it sat in the middle, even for models built for long contexts. Second, more context can actively hurt. Anthropic's engineering team calls this context rot: as the window fills, the model's ability to recall information from it decreases, so context is a finite resource with diminishing returns.
So remembering turns into compressing. The common technique, which Anthropic calls compaction, summarizes a conversation near the limit and starts a fresh window from the summary. Compression always loses something, and you can't know in advance which detail tomorrow's question will need. Mature systems layer the two: recent history in detail, older history summarized, and the summary written with a purpose ("what would the next session need to continue this project?") rather than as a generic recap.
Episodic, semantic and procedural memory
Separating memory by job makes design decisions clearer, because each kind ages differently.
- Episodic memory
- What happened, and when: "on 3 March the client rejected the blue logo". It stays true forever as a record of the past, but its relevance to today fades.
- Semantic memory
- What is currently true: "the client's brand colour is green". It is useful precisely because it is general, and it can silently become false when conditions change.
- Procedural memory
- How to do things: the agent's instructions, tools and learned routines. It changes least often and is usually edited by people.
- Retrieval precision
- How often the memory the agent brings back is the right one for the moment.
The classic mistake is promoting an episode to a fact. A user once asked for a formal tone in a legal email; the agent stores "user prefers formal tone" and applies it to every casual message for months. Keeping the episode as an episode, with its date and context, avoids the overreach. Semantic facts, by contrast, need periodic re-checking, because nothing in them announces when they stop being true.
How do agents decide what to recall?
Storing is easy; choosing what to bring back is the real work. One influential design comes from the Generative Agents paper by Park and colleagues (UIST 2023). Its agents keep a complete record of experiences in natural language and retrieve them dynamically to plan behavior. Each memory is scored on three signals: recency, which decays exponentially from the last time the memory was used; importance, which the model rates from 1 (mundane) to 10 (poignant) when the memory is created; and relevance, measured as similarity to the current situation. The highest combined scores go into the prompt.
Whatever the formula, the measure of success is how rarely the wrong memory is recalled. A system that remembers nothing at least behaves as if it doesn't know. A system that recalls a stale fact builds on a faulty foundation and sounds sure of itself, and that silent error is harder to catch than an honest gap. Growth makes this worse: the more an agent stores, the more near-duplicates and contradictions compete at retrieval time.
Two habits help. Check validity before use: is this memory still current, and where did it come from? And when confidence is low, ask instead of assuming: "Last time you preferred morning calls; is that still right?" costs one message and prevents a wrong booking.
How should an agent forget?
Memories go stale. What was true last quarter may not be true now, and an agent that never forgets ends up arguing with its own past. Forgetting is what keeps memory useful. A practical order of priorities:
- Attach a date, a source and a confidence level to every stored item.
- Keep episodes and facts separate, so a single event never becomes a rule by accident.
- Let the weight of rarely used items decay over time instead of deleting them at once.
- When two memories conflict, prefer the one with the better source and more recent confirmation, and record that the older one was superseded.
- Re-check a memory's validity before acting on it; if in doubt, don't use it or ask.
- Give people a way to see, correct and delete what the agent remembers about them.
Soft decay and hard deletion serve different purposes. Fading a memory's weight pushes it into the background but leaves a way back if it turns out to matter. Deletion is final and is the right choice for anything sensitive, anything the person asked to remove and anything that was simply wrong.
Practical memory patterns you can use today
Most working agents combine a few simple patterns rather than one elaborate memory system. Anthropic describes three for long-running work: compaction, structured note-taking in which the agent regularly writes notes to a store outside the context window (a to-do list or a NOTES.md file) and reads them back later, and sub-agents that explore with clean context windows and return condensed summaries to a lead agent.
| Pattern | What it keeps | Good for | Watch out for |
|---|---|---|---|
| Structured notes file | Decisions, open tasks, key facts | Long projects with one owner | Notes drifting out of date |
| Session summaries | A compressed record of each session | Continuing work days later | Lost details nobody can recover |
| Searchable memory store | Many small records, retrieved by meaning | Assistants serving many users | Near-duplicates and stale hits |
| Sub-agents with summaries | Only the condensed result of each sub-task | Research and multi-step jobs | Summaries hiding errors |
If you are building an agent, start with the simplest pattern that could work: a notes file the agent reads at the start of each session and updates at the end. Add summaries when sessions get long, and add search by meaning only when the notes no longer fit. Each layer adds a new way to be wrong, so add it when the simpler one demonstrably fails, and test retrieval with a small set of "should recall" and "should not recall" cases.
Choosing what goes into the window at each step is the discipline our piece on context engineering as information architecture covers in depth. Memory gets harder again when several agents share it, as described in multi-agent orchestration, and the stakes rise once agents act on what they remember, the shift discussed in tool-using agents.
Keep your project's context in one place with WisyLink
The same principles apply when you build an app by chatting with an AI. In WisyLink, each project (a link) has its own chat thread, and follow-up messages in that thread change the same app. Keep working in that thread instead of starting new ones, so the history of decisions stays attached to the project. Developers can do the same through the API by continuing a link with its id, as described in the API reference and our guide to the AI website builder API.
Don't rely on any chat history as your only memory, though. Keep a short written brief of the decisions that must survive (who the app is for, the rules for bookings or refunds, the tone of the copy) and restate them when you ask for a larger change. That brief is your semantic memory, and our article on spec-driven development explains why it deserves the same care as the product itself. Keep secrets out of the chat entirely: payment and email keys go under Integrations, where they are encrypted.
When you're ready to try it, start free and describe your first app in a single, well-structured message.
F.A.Q.
