Agent Memory Systems
Read a little, play a little. No scary maths, and no rush.
Goldfish agents forget; good ones remember
An agent that forgets your order number mid-refund is worse than no agent. Memory systems give agents three kinds of recall, each with different costs and jobs.
Short-term: the working desk
Keep the recent turns (say, last 10) verbatim in context — this is where the current task lives. As conversations grow, summarize older turns into running notes ("user wants a refund for order 12847, already verified identity") instead of carrying the full transcript. Summarization is itself an LLM call, run when the window fills.
Long-term: the filing cabinet
Facts that outlive one chat live outside context and get retrieved when relevant:
- User profile: preferences, tier, timezone — small structured store.
- Vector memory: past conversations, notes, and decisions embedded for similarity search ("what did we decide about refunds last month?").
- Episodic traces: full past runs, for debugging and learning.
Retrieval keeps the prompt lean: pull memory in only when the current task resembles it.
Checkpoints: save games for agents
After every action, persist {step, tool, args, result}. Crashes resume instead of restarting; auditors replay exactly what happened; billing counts real work. Checkpointing turns a fragile loop into a system you can operate — resume, inspect, and bill accurately.
A worked example: a travel assistant over two weeks
Week 1. While planning a trip, the user mentions they are vegetarian and prefer window seats. Those go into the profile store as durable preferences. As the long conversation fills the window, older turns are summarized into notes: "booked Lisbon hotel May 3–7, still needs a flight."
Week 2. The user returns: "Book the same kind of flight as last time." The assistant retrieves the earlier trip from episodic memory, sees the airline and fare class chosen, applies the window-seat preference, and proposes a matching flight. Each step is checkpointed, so a crash during payment resumes at payment rather than searching again.
Deciding what to remember
Storing everything is neither useful nor responsible. Good defaults:
- Remember explicit, durable preferences and facts the user confirmed.
- Do not quietly store sensitive details such as health information or financial account numbers unless the product genuinely needs them and the user agreed.
- Let users see and delete what is remembered about them.
- Update stale facts. When the user says they moved cities, replace the old address rather than keeping both, and keep a timestamp so the newest fact wins.
Memory can be wrong
Summaries drop details and occasionally introduce errors, and a wrong memory repeated in every future conversation is worse than none. For anything that matters, such as a booking reference or an amount, keep the original record and retrieve that rather than trusting a summary's paraphrase of it. Where possible, show the user which memory an answer relied on, so a wrong one gets noticed and corrected.
Remember this
- Desk (recent turns) + cabinet (retrieved facts) + save games (checkpoints).
- Summarize the desk, retrieve the cabinet, checkpoint every move.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
Practice this in an incident
Related chapters
Spotted a mistake or want a topic covered? Report an issue