All terms
Glossary · AI Coding & Agentic Development

Agent Memory

Agent memory is the set of mechanisms that let an AI agent keep and reuse information beyond a single model call: what happened earlier in the current task, and what it learned in past sessions. Language models do not retain anything between requests on their own, so memory has to be built around them by storing information and bringing the relevant parts back into the model's context when needed.

How Agent Memory Works

Most frameworks separate two scopes. LangChain's documentation, for example, describes:

  • Short-term memory: thread-scoped memory that tracks the ongoing conversation or task, mainly the message history inside the context window, saved so a session can be resumed.
  • Long-term memory: information stored outside any single conversation and shared across sessions, organized so the right items can be found later.

The same documentation borrows three types from human memory research:

  • Semantic memory: facts and concepts, such as a user's preferences or a project's tech stack.
  • Episodic memory: past events and actions, such as how a similar task was solved before, often reused as examples.
  • Procedural memory: rules for how to perform tasks, which for agents largely lives in instructions and the system prompt.

Memory can be written during the task, which is immediate but adds latency, or in a background process afterwards. Retrieval is increasingly just-in-time: rather than loading everything up front, the agent keeps lightweight references and pulls in what it needs. Anthropic's memory tool follows this pattern. Claude reads and writes files in a memory directory that the application controls, checks it at the start of a task and records progress as it works.

Memory pairs with context compaction. Compaction summarizes a long conversation to free space; memory preserves what must survive that summary.

Why Agent Memory Matters

Without memory, every session starts from zero. Users repeat preferences, agents rediscover the codebase and long tasks lose their thread once the context fills up. With it, an agent can continue multi-session work, apply lessons from earlier attempts and stay consistent across tasks.

Memory also brings risks. Stored information can go stale or be wrong, and an agent will keep acting on it. Sensitive data can end up stored where it should not be. Unpruned memory grows noisy and crowds out what matters. That is why agent memory should not become the source of truth for product decisions. It should point back to governed requirements and decisions rather than replace them.

Agent Memory Example

A coding agent works on a feature across several sessions. In the first session it creates two memory files: a progress log and a checklist of the feature's parts. Each later session starts by reading both, so the agent resumes where it stopped without re-exploring the repository. It marks an item done only after the tests pass, then updates the log before the session ends. Separately, it records the semantic fact "this project uses pnpm, not npm," so it stops suggesting the wrong install command.

For how memory fits with requirements, decisions and task context for coding agents, see context management for AI coding agents.

Agent Memory vs. Context Window

The context window is the model's working space for a single call: everything it can see right now, with a fixed size. Agent memory is what persists outside that window and is selectively loaded back into it. A larger context window delays the need for memory but does not remove it, because nothing in the window survives the end of a session.

Related terms
Context Window
The maximum amount of text, measured in tokens, that a language model can consider at once, including its instructions, the conversation and its own reply.
Context Compaction
Summarizing older parts of an AI conversation or agent session so the work can continue within the model's context window limit.
AI Agent
A system that uses an AI model to pursue a goal over multiple steps, choosing actions, using tools and reacting to results.
Context Management
The ongoing practice of keeping the information an AI works from relevant, accurate and current as tasks and sessions accumulate.
Source of Truth
The one designated, authoritative place where a piece of information is maintained, so everyone and every tool refers back to the same version.
Product Context
The structured knowledge about a product, such as users, goals, decisions, rules and scope, that people and AI need to make choices consistent with it.
Put the method into practice.
Prodstack is the AI product operating system that turns terms like this into shipped, evidence-backed work — from discovery to growth.
Start your 7 days free trial
// Newsletter
Field notes, in your inbox.

Evidence‑driven thinking on discovery, prioritization, specs, and shipping — plus new articles the moment they drop. No noise.