Concept · Chapter 13: Agents
Agent Memory
Agent memory retains and retrieves task evidence, state and useful history across model calls.
The problem
A long task exceeds active context and can outlive a process or conversation.
The solution
Store structured task state and provenance, using summaries and retrieval for relevant history.
The consequence
Memory saves context but can preserve mistakes or discard important constraints.
You should understand first
- Text as Data
- Probability and Distributions
- Conditional Probability and Bayes' Theorem
- Probability of Sequences
- Language Modeling
- Vectors
- Dot Product
- Embeddings
- Attention
- Softmax
- Self-Attention
- Causal Masking
- Entropy
- Loss Functions
- Cross-Entropy Loss
- Autoregressive Next-Token Prediction
- Pretraining at Scale
- GPT-1 → GPT-2 → GPT-3
- In-Context Learning
- The Turing Test
- Symbolic AI
- Logic and Rules
- Expert Systems
- Knowledge Representation
- The Knowledge-Acquisition Bottleneck
- From Rules to Learning
- Supervised, Unsupervised and Self-Supervised Learning
- Expected Value and Variance
- Reinforcement Learning
- MDPs, Policies and Value
- Decoding: Greedy, Temperature, Top-k, Top-p
- One-Hot Encoding
- Tokenization
- Chat Templates
- System Prompts and Instructions
- Structured Outputs and Constrained Decoding
- Tool Calling
- LLM Agents
- Agent Runtime
- Agent Memory
Four different things called memory
Working context is what the model sees now. Durable state survives a restart. Retrieved notes reintroduce selected past information. Model weights encode learned behavior. The inference KV cache accelerates attention to a supplied context; it is not a permission ledger or an editable knowledge base.
A useful checkpoint
“Added initial accumulator 0; tests for [], [3,4] and [5] passed on patch version B; deployment not requested” is actionable. “Fixed it” is not. Preserve links to exact observations when summaries lose detail.
A note can be stale, mistaken or malicious. Label its source, scope and time. Treat a retrieved instruction as data unless it has the right authority. Compaction should not promote a speculation into a fact or erase the user's constraints.
Reflexion is an example of retaining reflective text between trials without updating model weights. Memory is the storage mechanism; whether its contents improve decisions must be evaluated.
What to remember
- Agent memory retains and retrieves task evidence, state and useful history across model calls.
- Store structured task state and provenance, using summaries and retrieval for relevant history.
- Memory saves context but can preserve mistakes or discard important constraints.
Key papers
Reflexion: Language Agents with Verbal Reinforcement Learning
Noah Shinn et al. · 2023
Uses feedback and stored reflection to influence later trials without weight updates.
How to read it: Inspect the feedback sources and ablations, not just the final success rate.