MemGPT treats the context window as fast RAM and external stores as slow disk with the model as the OS; Letta exposes this through named memory blocks plus read, write, search, and edit tools the model invokes during
Imagine your desk holds only the papers you are actively using. Anything else lives in a filing cabinet across the room. A good worker pulls a file from the cabinet when they need it, puts notes back in the cabinet when they are done, and clears the desk when it gets cluttered. MemGPT proposes that an LLM should manage its own desk and cabinet system the same way: the desk is the context window, the cabinet is external storage, and the LLM decides what to pull, what to file, and what to throw away. Letta gives the LLM the actual tools to do this, open a drawer, write a note, search the cabinet, edit a tag.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
The MemGPT paper (Packer et al. 2023) reframed LLM memory as a virtual-memory system where the model itself acts as the operating system, paging content between the context window and external stores. Letta is the 2026 production framework that operationalizes this design with named memory blocks and model-invoked tools. This deep dive walks through the paging metaphor, the concrete mechanism, the productionization that Letta adds, and the architectural payoff that has made the framing influential beyond Letta itself.
The paging metaphor in detail
Operating systems solved a problem decades ago that LLMs face today: the working set is larger than the fast-access memory. The OS solution is virtual memory with paging: a small fast main memory (RAM) holds the active working set, a large slow disk holds everything else, and a page-replacement policy decides what gets evicted when RAM fills.
MemGPT's insight is that LLMs face the same shape of problem. The context window is the equivalent of RAM: limited (hundreds of thousands of tokens), expensive to fill (input cost and latency), fast to access (the model attends to it directly). External stores (vector databases, document stores, knowledge graphs) are the equivalent of disk: large (unbounded), cheap, slow (require a retrieval call). A long-running agent's working set will not fit in the context window, so something has to manage what gets paged in and out.
The radical part is who does the managing. Earlier memory frameworks treated the surrounding code as the manager, retrieve top-k at every turn, decide what to evict via a policy. MemGPT argues that the LLM should be the manager: it knows what it cares about, it knows what it just used, it knows what it will probably need next. Give it the right tools, and it manages its own memory better than any external policy could.
This is the framing that has won beyond MemGPT itself. The implementation details vary across frameworks; the framing has become the default mental model for 2026 long-running agents.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- The original MemGPT research demo (2023) shipped agents that maintained user facts across long sessions by self-managed paging
- Letta (2026) is used in autonomous-agent research and in some production assistants that need long-running memory
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does Letta's design hold up when a single agent serves many users?
Letta supports per-user agent instances, each with their own persona, human, and archival store keyed by user ID. The named-block pattern scales to multi-tenancy because the blocks are user-scoped from the start. The challenge is operational: many agent instances mean many small Postgres rows or per-tenant tables. Letta's hosted offering manages this; self-hosters need to plan storage.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating MemGPT as just a vector store with retrieval, missing that the key contribution is putting the model itself in charge of memory operations through explicit tool calls.
60 second bullets to scan on the way to the call.
What is the paging metaphor that MemGPT borrows from operating systems?
Which memory blocks did the original MemGPT design define?
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.