# What is agent memory? Types, storage and how agents write it

> Agent memory is information an agent keeps outside the model's context window and reads back later. The types, where it lives and how it gets written.

Source: https://www.honeyhive.ai/learn/agent-memory (updated 2026-11-08)

Agent memory is information an agent keeps outside the model's [context window](/learn/context-window) and reads back when it needs it. The model itself holds nothing between calls, so anything the agent should remember, such as a user's preferences, the state of a long task or a lesson from an earlier failure, has to be written somewhere and loaded into context again later.

## Short-term and long-term memory

LangChain's docs [draw the main line](https://docs.langchain.com/oss/python/concepts/memory) between two scopes.

| | Short-term memory | Long-term memory |
|---|---|---|
| Scope | One conversation thread | Across sessions |
| What it holds | The thread's messages and working state | User-specific or application-level data |
| In LangGraph | Part of the agent's state, persisted with thread-scoped checkpoints | A separate store the agent reads and writes |

Short-term memory is mostly the running message history. LangChain's docs [describe it](https://docs.langchain.com/oss/python/concepts/memory) as tracking the ongoing conversation by keeping message history within a session. When it gets too long, the agent trims it or summarizes it. Anthropic calls the summarizing step [compaction](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents): taking a conversation nearing the context limit, summarizing it and starting a new window with the summary. Anthropic adds that the art lies in choosing what to keep and what to discard.

## Three kinds of long-term memory

LangChain's docs borrow terms from human memory research to [describe what an agent stores](https://docs.langchain.com/oss/python/concepts/memory).

| Type | What it is | How agents use it |
|---|---|---|
| Semantic | Retention of specific facts and concepts | Recalling facts about a user to personalize replies |
| Episodic | Recalling past events or actions | Learning how to do a task, often through few-shot examples |
| Procedural | Remembering the rules used to perform tasks | Most often by the agent editing its own prompts |

Research papers built agent memory before the frameworks did. The Generative Agents paper by Park and colleagues [describes](https://arxiv.org/abs/2304.03442) agents that store a complete record of their experiences in natural language, synthesize those memories into higher-level reflections and retrieve them dynamically to plan behavior. The authors' ablations found that observation, planning and reflection each contribute critically to how believable the agents are. The CoALA paper by Sumers and colleagues [proposes](https://arxiv.org/abs/2309.02427) modular memory components as one part of a general framework for organizing language agents.

## Where memory lives

Agents use several designs.

- **Files the agent edits.** Claude's memory tool [lets the model](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool) create, read, update and delete files in a `/memories` directory. It runs client-side: Claude requests the operation, your application performs it, and you decide whether the path maps to files on disk, a database, cloud storage or encrypted files. Anthropic's note-taking pattern, with files such as NOTES.md or to-do lists, [works the same way](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents).
- **A store searched on demand.** The agent saves memories as records and pulls the relevant ones back by search, the way retrieval works in [agentic RAG](/learn/agentic-rag).
- **Tiers managed by the model.** The MemGPT paper by Packer and colleagues [proposes](https://arxiv.org/abs/2310.08560) virtual context management, borrowed from hierarchical memory in operating systems, where the model moves information between memory tiers to work past a limited context window. The authors tested it on documents longer than the window and on multi-session chat.

## When memories get written

LangChain's docs [describe](https://docs.langchain.com/oss/python/concepts/memory) two options, each with a cost.

- **In the hot path**, while the agent runs. The memory is available immediately, but deciding what to save adds latency and divides the agent's attention.
- **In the background**, as a separate task. It keeps memory work off the response path and apart from application logic, but you have to decide when it runs.

A third pattern suits long software projects. The Claude docs [describe](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool) an initializer session that sets up a progress log and feature checklist, later sessions that read those files first, and an end-of-session update. Each session then resumes from the state the last one recorded.

## Memory and context

Memory does not make the window bigger. It decides what gets loaded into it. Anthropic's docs [say](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool) memory supports just-in-time retrieval: instead of loading everything up front, the agent records what it learns and reads it back on demand, which keeps the active context on the current task. That is one of the core moves in [context engineering](/learn/context-engineering). It also limits [context rot](/learn/context-rot), the drop in accuracy as inputs grow.

The Claude docs [recommend](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool) using memory with compaction on long-running agents: compaction keeps the active context small, and memory preserves what must survive summarization.

## Risks to plan for

The Claude docs [list the safeguards](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool#security-considerations) a memory handler needs:

- Validate every path. A path such as `/memories/../../secrets.env` can reach files outside the memory directory.
- Cap file sizes, and cap how much a read returns.
- Expire memory files that have not been accessed in a long time.
- Filter sensitive data before writing. Claude usually refuses to store it, but the docs say to add validation for stronger guarantees.

Stored memory also becomes input to the next run, so anything wrong or hostile that gets written there is read back as if it were trusted. See [prompt injection](/learn/prompt-injection) for how untrusted text steers an agent.

## Tracing memory reads and writes

With Claude's memory tool, each read and write is a tool call that your application handles, so your own code can log it. HoneyHive's docs [say](https://docs.honeyhive.ai/v2/tracing/introduction.md) tracing is automatic for major LLM providers and vector databases, and [custom spans](https://docs.honeyhive.ai/v2/tracing/custom-spans.md) cover your own logic such as a memory handler. See [agent tracing](/learn/agent-tracing) for what a trace should capture.

For where memory sits in the overall design, see [AI agent architecture](/learn/ai-agent-architecture) and the [agent harness](/learn/agent-harness).

## FAQ

### What is agent memory?

Agent memory is information an agent stores outside the model's context window so it can use it later, in the same task or in a future session. LangChain's docs [split it](https://docs.langchain.com/oss/python/concepts/memory) into short-term memory scoped to a thread and long-term memory kept across sessions.

### What is the difference between short-term and long-term agent memory?

Short-term memory belongs to one conversation thread. In LangGraph it is [part of the agent's state](https://docs.langchain.com/oss/python/concepts/memory), persisted through thread-scoped checkpoints. Long-term memory holds user-specific or application-level data across sessions.

### What are the types of long-term memory for agents?

LangChain's docs [name three](https://docs.langchain.com/oss/python/concepts/memory): semantic (facts and concepts), episodic (past events or actions) and procedural (the rules used to perform tasks, which agents most often change by editing their prompts).

### Does a bigger context window replace agent memory?

No. A window holds one run's input, and the Claude docs [say](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool) the memory tool exists so an agent can build up knowledge across conversations without keeping everything in the window. Long inputs also lose accuracy, which [context rot](/learn/context-rot) covers.

### Where is agent memory stored?

It depends on the design. With Claude's memory tool, storage is yours: the tool [operates client-side](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool), so your application maps the /memories path to a directory, database or other store. Other designs keep memory in a vector store or in framework state.
