MemGPT (Packer et al., 2023) made the operating-system analogy literal: give an LLM a small "main context" it can see, a large "external context" it cannot, and self-directed tools — paging instructions in and out — so an agent with a modest window can work over an unbounded workspace.
The design maps OS virtual memory onto tokens. Main context is the window: system instructions, a working "RAM" block of key facts, and the message queue. External context is everything else — documents, transcripts, prior runs — addressed by search. The model itself issues memory-management calls: search external storage, edit its own RAM block, page a result into working context, evict what has gone cold. Interrupts handle overflow — when the queue nears capacity, control passes to the model with an instruction to summarize and flush, exactly like a page fault handler deciding what to swap out.
What made the paper durable is not the specific implementation but the inversion of control: memory management became part of the agent's policy instead of an external preprocessor's guess. Only the agent knows which of its current observations will matter in ten steps — so let it manage its own working set. Every serious long-horizon agent framework since (Letta's memory blocks, Claude Code's files-as-memory, editors' agent scratchpads) is this idea in different clothing.
Lessons for Long-Horizon Agents
- Structured beats raw: page in distilled, structured notes — not raw transcript dumps; the working block is a summary layer, not a tape recorder.
- Self-editing needs guardrails: the model editing its own memory can overwrite critical facts; invariants (goal, identity, constraints) live in read-only blocks.
- Eviction needs policy: recency plus relevance scores beat last-in-first-out; what leaves the window should land in searchable storage, never in the void.
- Interrupt early: compaction triggered at 80% capacity preserves reasoning flow; a forced compact at 100% mid-thought corrupts it.
The abstraction has a familiar weakness too: page thrashing. An agent that pages in and out constantly is burning tokens on memory management instead of the task — the same failure OS designers solved with working-set models, and worth borrowing wholesale.