You now have the pieces. This lesson studies three well-known architectures that combine them, so you can borrow the ideas that fit your problem.
Watch
A talk on Letta, the project that grew out of MemGPT, covering stateful agents and memory. Watch it alongside the tiered-memory section.
1. Tiered memory: MemGPT and Letta
MemGPT borrows from operating systems. The context window is like RAM: fast and small. External stores are like disk: large and slower. The agent itself gets tools to move information between tiers, which the paper calls virtual context management.
Takeaways to borrow:
- Keep a small always-in-context block for core facts (who the user is, the agent's persona and rules).
- Put the long tail in searchable external storage.
- Let the agent edit its own memory through explicit tools, so changes are visible and auditable.
The project is now maintained as Letta, with docs and open-source code.
2. Memory stream with reflection: Generative Agents
This paper stores every observation as a natural-language record in a memory stream. Retrieval scores each record on recency, importance and relevance, then injects the top ones. Periodically the agent reflects: it asks itself higher-level questions over recent memories and stores the conclusions as new memories.
Takeaways to borrow:
- A scoring function beats raw similarity. Start with
score = relevance + recency + importanceand tune weights on your own questions. - Reflection turns scattered episodes into durable semantic knowledge ("the user always postpones Friday tasks").
3. Temporal knowledge graph: Zep and Graphiti
Zep stores memory in a graph built by the open-source Graphiti engine. Per the paper, it keeps raw episodes, extracted entities and relationships, and community-level summaries, and it tracks when facts were true separately from when the system learned them.
Takeaways to borrow:
- Facts change. Store validity intervals instead of overwriting, so the agent can answer both "where does she live?" and "where did she live in 2023?".
- Relationship questions ("who did I discuss this with?") suit a graph. This connects directly to the GraphRAG course.
- The paper's benchmark numbers come from its authors, so treat them as a reason to evaluate on your own data.
Start simple: profile block plus a vector table (lesson 4). Add a scoring function when retrieval feels noisy, a graph when relationship or time-travel questions appear, and tiered self-editing memory when the agent runs for days.
Resources
Read in full this time, especially the memory tiers and function calls.
Memory blocks, archival memory and agent setup.
Open-source code for the stateful agent framework.
The memory stream, retrieval scoring and reflection sections.
The bi-temporal graph model and its evaluation.
The open-source temporal graph engine behind Zep.
Check yourself
- Add a scoring function to your lesson 4 retrieval and compare answers with plain similarity on 10 questions.
- Implement a reflection job that reads the last week of memories and writes 3 to 5 higher-level facts.
- Add
valid_fromandvalid_untilhandling so superseded facts stay queryable as history.