D3 · Long-term memory
Family: Context and memory
The agent keeps facts, experiences and know-how from one session to the next.
Principle
Three kinds of memory are distinguished: semantic (facts), episodic (past experiences, often fed back as examples) and procedural (instructions or code). The agent writes to it and retrieves what is useful, sometimes paging its own context the way an operating system manages memory.
The problem it solves
An agent with no memory starts from scratch in every conversation: it retains neither your preferences nor what it has already learned.
When to use it
- A persistent agent serves the same users or tasks over time: assistant, simulation.
- You must handle documents longer than the context window, or follow conversations spread over several sessions.
When to avoid it
- What is stored may come from untrusted data: memory poisoning is a recognised risk (OWASP ASI06), so what gets written must be controlled.
- Everything fits in one session: structured notes (D2) are enough.
Common pitfalls
The anti-patterns that misuse this pattern, best established first. Each sheet describes the symptoms, the public incidents and the remedies.
Context and memory
- AP33 · Unvalidated memory writes — The agent remembers what it reads, including orders slipped into a document, and later rereads them as facts.
- AP26 · Context poisoning — A mistake written into the context becomes a fact, which the agent rereads and reinforces at every turn.
Oversight, operations and governance
- AP81 · Hard vendor coupling — The agent rests on a stateful API or a specific model with no isolation layer: a forced migration becomes a rewrite.
Synonyms by vendor
- Mémoire sémantique, épisodique, procédurale (CoALA (Sumers, Yao, Narasimhan, Griffiths))
- Memory-augmented agents (AWS)
- Memory Management (A. Gulli (ch. 8))
- MemGPT / Letta (Packer et al. (2023))
- LangGraph memory (LangChain)
Neighbouring patterns
Sources
- Managing context on the Claude Developer Platform — Anthropic (Claude), 2025-09-29
- Generative Agents: Interactive Simulacra of Human Behavior — J. S. Park et al. (UIST 2023), 2023
- MemGPT: Towards LLMs as Operating Systems — C. Packer et al., 2023
- Cognitive Architectures for Language Agents (CoALA) — T. Sumers, S. Yao, K. Narasimhan, T. Griffiths
- OWASP Top 10 for Agentic Applications for 2026 — OWASP GenAI Security Project, 2025-12-10
Content reviewed on 2026-10-02