Overview

4 Memory: What your agent remembers shapes what it becomes

Memory in an AI agent is not just storage; it is a policy for deciding what information survives boundaries, what returns to active context, and under what checks it may influence action. The chapter frames memory as a governed system that distinguishes state persistence, evidence retrieval, and experience capture, emphasizing that persistence alone does not create learning or authority.

To make this concrete, the chapter develops several memory patterns. Hierarchical Retention manages information across tiers with different scopes, lifetimes, and ownership; RAG Pipeline retrieves current evidence from large or changing sources while preserving provenance and permissions; Progress Tracking preserves the state needed to resume work safely after interruptions; and Failure Journals store failure evidence plus candidate lessons without automatically promoting them to rules. Across all of these, versioning, supersession, permissions, and validation matter more than raw recall or proximity to the model.

The chapter also compares these patterns to real systems and shows that production agents already use partial forms of them through scoped instruction files, project memory, checkpoints, and retrieval tools. Its central lesson is practical: start with the authoritative sources a task already has, add memory only when the boundary truly demands it, and measure success by better downstream decisions, fewer repeated failures, safer recovery, and correct source authority rather than by how much text the agent can keep.

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.

FAQ

What is agent memory in this chapter?Agent memory is the policy for what information may survive a boundary such as a turn, session, task, user, device, or system boundary. It also defines the form of the information, who owns it, how long it lasts, and what checks are required before it can re-enter active context.
Why isn’t simple persistence enough for memory?Because storing information does not decide whether it is current, valid, or authorized to influence a decision. A separate control plane must validate scope, version, permission, and admission before memory becomes active guidance.
What are the main responsibilities of memory in an agent system?The chapter groups memory into three responsibilities: state persistence, evidence retrieval, and experience capture. State persistence helps resume work, evidence retrieval brings in relevant external material, and experience capture preserves failure facts and candidate lessons with provenance.
What is Hierarchical Retention?Hierarchical Retention is a memory pattern that organizes information into tiers with explicit scope, function, access, and lifetime policies. It is used when useful information has different urgency or lifespan, and when promotion, eviction, invalidation, and conflict resolution must be controlled.
How is memory different from authority?Memory can make information available, but it does not make that information authoritative. A frequently retrieved note, preference, or model-written memory can still be subordinate to a human-owned rule or a newer controlled source.
When should a RAG Pipeline be used?Use RAG when the source corpus is too large or too changeable to load directly into context. The pipeline is useful when the agent needs governed evidence retrieval, citations, and a way to assemble the right sources for a specific decision.
What should a progress checkpoint contain?A good checkpoint should preserve the bounded goal, completed artifacts, authoritative references, pending decisions, and any executed effects or receipts. It should let another session verify what happened and continue safely without repeating work.
What is the purpose of a Failure Journal?A Failure Journal preserves failure facts, execution evidence, and candidate lessons so recurring failures can be studied across tasks. It keeps raw events immutable while allowing candidate diagnoses to be reviewed, scoped, admitted, superseded, or retired separately.
How should memory quality be measured?Measure memory by downstream decision quality, not by store size. Useful signals include retrieval utility, repeated-mistake rate, staleness, and publication ratio, along with whether the retrieved item actually improved the next action.
How do memory and collaboration differ?Memory owns persistence and retrieval across boundaries, while collaboration owns task decomposition, role authority, handoff, communication, and integration across workers. They can share a store, but they solve different problems and should not be merged.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents ebook for free