4 Memory: What your agent remembers shapes what it becomes
This chapter argues that memory is not just storage, but a policy for what information survives each boundary and what is allowed back into decision-making. An agent’s memory must distinguish working context, session state, long-term evidence, preferences, decisions, and candidate lessons, while also tracking scope, ownership, version, permissions, and expiry. The central lesson is that persistence alone does not create authority: an item can be remembered without being valid, current, or allowed to guide action.
The chapter then presents four memory patterns, each designed for a different failure. Hierarchical Retention keeps information in tiers so useful material can persist without confusing old or low-authority items with current guidance. RAG Pipeline assembles governed evidence from large or changing corpora, with retrieval methods chosen to fit the source and with citations and authority checks preserved. Progress Tracking stores resumable task state so work can continue after resets or handoffs, and Failure Journals preserve failure evidence and candidate lessons without automatically promoting them into rules.
Across these patterns, the recurring design principle is to preserve history while controlling reuse. Good memory systems do not simply retain more; they retain the right things, in the right form, for the right audience, and with clear rules for supersession, invalidation, and review. The chapter closes by showing how these patterns can be composed when needed, but only after checking that the combined design improves outcomes such as recovery, citation quality, and correct resumption without repeating mistakes.
Memory access-cost analogy. Promotion and eviction manage active context; authority, version, and permission remain separate checks.
Hierarchical Retention in two views. The three-tier teaching model shows promotion and eviction; the production view adds scope, function, lifetime, ownership, and admission.
RAG Pipeline from basic retrieval to governed compile and assemble paths. Provenance, version, permission, and source identifiers survive into the evidence package.
Progress Tracking from a checkpoint chain to verified resumption. Each checkpoint records the goal, artifacts, versions, effect receipts, and pending decisions.
Failure Journal from an immutable failure entry to governed reuse. An entry may support a candidate lesson; independent admission controls publication, and later retrieval and effect observation govern continued reuse.
Memory validity checks. A superseded game decision is rejected before active context; a current, authorized item may re-enter.
Summary
- Memory is a policy for what survives a boundary and under what authority it may return to a later decision. A separate memory service is optional.
- Hierarchical Retention (Memory × Hierarchy) separates scope, function, access, and lifetime. Recency and frequency can guide retrieval; they do not determine authority.
- RAG Pipeline (Memory × Chain) governs a compile path for sources and an assembly path for decision evidence. Exact, lexical, semantic, structural, relational, and temporal retrieval serve different corpora.
- Progress Tracking (Memory × Orchestrate) preserves the goal, acceptance condition, artifact evidence, authoritative versions, pending decisions, side-effect receipts, and handoff conditions needed to resume safely.
- Failure Journals (Memory × Loop) keep raw failure evidence, candidate diagnoses, and published lessons distinct. Chapter 7 owns admission and replay.
- The four patterns are selected from observed failures; they do not form a mandatory pipeline. A system may use one, several, or none.
- Memory and Collaboration may share infrastructure while retaining different responsibilities. Memory governs persistence and retrieval; Collaboration governs roles, handoffs, and integration.
- Measure memory through downstream decisions: retrieval utility, repeated mistakes, stale reads, duplicated effects, harmful transfer, latency, and token cost within a defined workload.
Designing AI Agents ebook for free