Memory Blocks and Sleep-Time Compute
Discrete functional memory blocks the model can edit directly, and a sleep-time agent that consolidates memory asynchronously while the primary agent is idle. These two ideas are how you scale memory beyond one conversation. Name the three memory tiers Letta uses (core, recall, archival) and the role of each. Explain the memory-block pattern: Human block, Persona block, and user-defined blocks as first-class typed objects. Describe what sleep-time compute is, why it sits off the critical path, and why it can run a stronger model than the primary agent. Implement a scripted two-agent loop where a primary agent serves responses and a sleep-time agent consolidates blocks between turns. MemGPT (Lesson 07) solved the virtual-memory control flow. Three production problems emerged: Latency. Every memory operation sits on the critical path. If the agent has to prune, summarize, or reconcile while the user waits, tail latency blows up. Memory rot. Writes accumulate. Contradicted facts stay. Retrieval drowns in stale content. Structure loss. A flat archival store cannot express "the Human block is always in the prompt; the Persona block is always in the prompt; the Task block swaps per session.". Letta (letta.com) is the platform name the original MemGPT project adopted in 2024 — the paper's pattern keeps the MemGPT name — and the 2026 Letta V1 rewrite is a later, separate step.…
Memory Blocks and Sleep-Time Compute: Discrete functional memory blocks the model can edit directly, and a sleep-time agent that consolidates memory…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.