Skip to main content

Long-Term Memory (Agent Memory)

Long-term memory is a persistent store that gives an agent access to information across sessions — user preferences, prior decisions, past tool results worth remembering, or accumulated background about a project. It is distinct from the context window, which is per-request and reset each call. Implementations typically combine a vector store (for semantic recall by similarity) with a key-value or structured store (for exact lookups like "what is this user's time zone"). Memory is often split into three kinds borrowed from cognitive science: episodic (specific past events), semantic (facts and preferences), and procedural (how-to patterns the agent has learned). Writing to memory needs policy — not every turn is worth remembering, and over-eager writes pollute future retrievals. Read policy also matters: surfacing too much memory bloats the context window and causes context rot.

Example

A coding-assistant agent works with a developer daily. Without long-term memory, every session restarts cold — the agent re-asks about the repo layout, preferred test framework, and deployment target. With a memory layer storing "uses pnpm, Vitest, Fly.io deploys, prefers functional style", the agent picks up each session in the right key immediately. A small retrieval step pulls the three most relevant memory items per task rather than dumping everything into context, keeping the context window lean while still adapting to the developer's known preferences.

Put this into practice

Build polished, copy-ready prompts in under 60 seconds with SurePrompts.

Try SurePrompts