9.4.1 Memory Roadmap: Write, Retrieve, Forget
Memory is not there to make an Agent feel human. It should help the task: reduce repeated questions, preserve useful context, reuse experience, and avoid stale or private information leaks.
See the Memory Loop First



The core decision is not “save everything.” It is what to save, when to retrieve it, when to update it, and when to forget it.
Run a Memory Write Filter
Only stable preferences and reusable facts should become long-term memory.
events = [
{"type": "preference", "text": "prefers short examples"},
{"type": "temporary", "text": "debugging one local error"},
{"type": "fact", "text": "project uses Python"},
]
memory = []
for event in events:
if event["type"] in {"preference", "fact"}:
memory.append(event["text"])
print("saved:", memory)
print("count:", len(memory))
Expected output:
saved: ['prefers short examples', 'project uses Python']
count: 2
If a memory is not useful, current, permitted, and retrievable, it can hurt the Agent more than it helps.
Learn in This Order
| Step | Read | Practice Output |
|---|---|---|
| 1 | Memory overview | Distinguish context window, short-term memory, long-term memory |
| 2 | Short-term memory | Track current task state across turns |
| 3 | Long-term memory | Save durable preferences, facts, and project background |
| 4 | Episodic and procedural memory | Separate what happened from how to do it next time |
| 5 | Memory engineering | Design write, retrieve, update, expire, and delete rules |
Pass Check
You pass this chapter when you can explain why “remember more” is not the same as “perform better.”
The exit mini project is a learning-planning assistant memory rule set: what to save, what to confirm, what to keep temporary, and what to delete.