What Is Agent Memory?

Systems•6 min read•beginner

Agent memory is what an application stores outside the model and puts back into a later run. Short-term and long-term memory, who writes it, what breaks.

SYSTEMS
The fish forgot. The note didn't.
PRUNINGMYPOTHOS.COM
MEMORYlikesmetricno idea.written down.

An agent that greets you by name next week did not remember you. After this conversation something wrote your name into storage, and before the next one something put it back into the model's input. That writing and reading is agent memory.

The model keeps nothing between calls; an application stores information outside it and places selected parts back into a later run. Everything an agent appears to remember arrives the same way as everything else it sees: in the context window for the current run.

Short-term and long-term memory

LangChain's documentation describes short-term memory as thread-scoped, kept as part of the agent's state and saved through checkpoints. In practice that is the conversation so far, plus anything the agent has worked out within the same thread or session. It still has to fit in the context window, so long threads are trimmed or summarised, and whatever is cut is gone from the run.

Long-term memory is shared across threads and kept outside any single conversation, in what LangChain calls namespaces in a store. This is the part people usually mean by persistent memory: it survives the end of a session and can be read back in a new one.

  1. Short-term memory

    • The conversation so far
    • Kept for one thread or session
    • Trimmed when the window fills
  2. Long-term memory

    • Facts, past actions, instructions
    • Kept across sessions
    • Read back when the application chooses
  3. Neither one lives in the model.

Short-term memory is one thread's conversation; long-term memory is kept across sessions; neither lives in the model.The two kinds of agent memory, and where each one is kept.

What gets stored

LangChain's documentation names three kinds of long-term memory: semantic memory holds facts, episodic memory holds experiences such as past actions, and procedural memory holds instructions for doing a task. For illustration: "the user prefers metric units" is a fact, "the last deploy failed at the database migration" is an experience, and "run the tests before opening a pull request" is an instruction.

The three names describe what a memory is about. All three can sit in the same store, as text or records, and they are read back the same way.

Who decides what gets written

  1. Run one

    "I prefer metric."

  2. Write

    Code or a tool saves it.

  3. Store

    Outside the model.

  4. Run two

    Placed back in the input.

A memory is written during or after one run, kept outside the model, and placed back into the input of a later run.One fact, from one run to the next.

Something has to choose what is worth keeping. Memory can be written while the agent is responding, which LangChain calls the hot path, or afterwards as a background task. Writing on the hot path makes the memory available at once and slows the response; writing in the background keeps the response quick and the memory arrives later.

Sometimes the model makes the choice through a tool. Anthropic's memory tool lets Claude store files under a /memories directory and read them back in later conversations, and it runs client-side: Claude requests the file operations and the application carries them out. With the tool enabled, Claude checks its memory directory before starting a task. The model proposes what to write; the application decides where it lives and whether the write happens at all, the same split an agent harness makes for every other action.

Reading memory back is a selection problem. A store that has grown for months holds more than one run can use, so the application picks the items that belong in this run, the same choice retrieval-augmented generation makes for documents. MemGPT, a 2023 research system, manages memory in tiers, drawing on how operating systems move data between fast and slow memory. The model's input is the fast tier; storage is the slow one; something has to move items between them.

What goes wrong

Memory fails in ordinary ways, because it is ordinary data.

  • Stale: the user changed their preference, and the old fact is still read back.
  • Wrong: the agent wrote down a misunderstanding, and every later run inherits it as context.
  • Unscoped: memory saved for one user or project is read into another one's run.
  • Planted: text the agent stored from a web page or a document returns in a later run looking like trusted context.
  • Out of bounds: Anthropic's documentation warns that a path such as /memories/../../secrets.env can reach files outside the memory directory, so the application has to check every path.

Because memory lives in ordinary storage, it can be inspected, corrected and deleted, and it needs the same scoping and review as any other data the system keeps.

What this changes

When an agent seems to forget, look at what was written and what was read back into the run before blaming the model. When it remembers something wrong, there is a record to find and delete. And when an agent hands work to the next session on purpose, a written handoff is memory with a name on it: chosen, dated and readable by a person.

Where this helps, and where it stops

What it is
A plain explanation of agent memory: short-term and long-term memory, the kinds of thing stored, who writes and reads it, and what goes wrong.
What it does not guarantee
A comparison of memory products or vector databases, or a guide to building a memory store.
When the distinction matters
An agent forgets something it should know, remembers something wrong, or is about to be given memory that persists across users or sessions.

Sources

  1. LangChain, Memory overview (accessed 2026-11-18)external
  2. Anthropic, Memory tool (accessed 2026-11-18)external
  3. Packer et al., MemGPT: Towards LLMs as Operating Systems, 2023external