Glossary
MemGPT
An LLM agent design that manages its own memory, paging information between the context window and external storage through function calls.
MemGPT is a design for LLM agents that treats the context window like the main memory of a computer and gives the model function calls to move information in and out of slower external storage. It comes from the 2023 paper “MemGPT: Towards LLMs as Operating Systems” by Charles Packer and colleagues at UC Berkeley, which called the technique virtual context management. The open-source MemGPT project later became Letta, and the name MemGPT now mostly refers to the original agent pattern: an LLM that manages its own memory through tools.
Where MemGPT came from
The paper was first posted to arXiv in October 2023 and revised in February 2024. Its starting point was a limit every agent builder runs into. A model can only reason over what fits in its prompt, and both long conversations and large documents outgrow that space quickly. Making the window bigger helps less than it seems: long-context models cost more per call, and accuracy tends to fall when the relevant passage sits in the middle of a long input, a pattern known as lost in the middle.
The authors borrowed an idea from operating systems. A computer gives programs the impression of a large address space by paging data between fast RAM and slower disk. MemGPT does the same for an LLM: a small, fast tier inside the prompt and a large, slow tier outside it, with the model itself deciding what to page in and out. The paper tested the idea in two settings, document analysis over files far larger than the context window and multi-session chat where an agent has to remember a user across many conversations.
In September 2024 the MemGPT open-source project became part of Letta, the company founded by the paper’s authors. The framework and Python package were renamed to Letta, while MemGPT was kept as the name for the agent design described in the paper. If you see “MemGPT” in older tutorials or GitHub issues, it usually means the framework; in newer writing it usually means the pattern. The comparison pages on Exabase vs Letta and Letta alternatives cover the framework as a product.
How MemGPT works
MemGPT splits an agent’s memory into two tiers. Main context is everything in the prompt for the current call. External context is everything stored outside the prompt that the agent can reach through function calling.
Main context has three parts. The system instructions are read-only and describe the agent’s role, how control flows and which memory functions it can call. Working context is a fixed-size block of text that the agent can edit through function calls, used for key facts about the user and the agent’s own persona. The FIFO queue holds the rolling message history: user messages, system notices, and the inputs and outputs of function calls. The first slot of the queue holds a recursive summary of messages that have already been evicted.
External context also has two parts. Recall storage keeps the full history of past messages, so the agent can search for something said weeks ago even though it has long since left the prompt. Archival storage is a general read-write store for arbitrary text, such as documents or notes the agent decides to save, and it is searched with embeddings much like a vector database.
A component the paper calls the queue manager watches how full the prompt is. When token usage passes a warning threshold, it inserts a memory pressure notice into the queue, which prompts the agent to save anything important to working context or archival storage. When usage reaches the flush threshold, the queue manager evicts a block of older messages, writes them to recall storage and updates the recursive summary. Nothing is silently lost: evicted messages stay searchable in recall storage, and the summary keeps a compressed trace of them in the prompt.
Self-editing memory and the agent loop
The defining feature of MemGPT is that the model manages memory itself. Instead of a separate pipeline deciding what to store, the agent has tools to append to or replace text in working context, insert text into archival storage, and search both archival and recall storage. Search results come back in pages, so a broad query cannot flood the prompt.
MemGPT runs as an event-driven agent loop. An event such as a user message, a system warning or a scheduled timer triggers a model call. The model can reply, call a function, or both. A function call can set a heartbeat flag that asks for another turn straight away, which lets the agent chain several steps, such as searching recall storage, reading a second page of results and then updating working context, before it yields control back to the user. Without the flag, the agent stops and waits for the next event.
A short example shows the pattern. A user mentions in January that they are allergic to peanuts. The agent writes that to working context. In March the conversation has grown far past the context window and the January messages have been evicted, but the allergy is still in working context, so a recipe suggestion avoids peanuts. If the user then asks what restaurant they discussed in January, the agent searches recall storage, finds the old message and answers from it.
What MemGPT changed in agent memory
MemGPT made two ideas mainstream. The first is that memory is a hierarchy with different tiers for different jobs, rather than one large prompt or one vector index. This maps loosely onto how people talk about short-term memory, working memory and long-term memory in agents today. The second is that the agent can be an active participant in its own memory, deciding what to keep, what to look up and when, through the same tool use it applies to everything else.
Both ideas run through modern context engineering. Techniques such as context offloading and context compression are close relatives of MemGPT’s paging and recursive summaries. The paper also sits alongside other 2023 work on agent memory, notably the Stanford generative agents paper, which used a memory stream with reflection to build higher-level conclusions from raw observations.
Trade-offs and limits
Self-managed memory has real costs. Every memory operation is a model call or part of one, so storing and retrieving facts consumes tokens and adds latency. The quality of what gets remembered depends on the model’s judgment in the moment: a smaller or less capable model may fail to save an important fact, save trivial ones, or overwrite working context badly. The paper’s own experiments leaned on strong function-calling models for this reason.
Working context is plain text with a fixed size limit, so it has no built-in notion of when a fact stopped being true. If a user moves from Toronto to Berlin, the agent has to notice the change and edit the right line itself. Archival storage is a similarity search, which returns what resembles the query rather than what is current, the same limit covered in why a vector database is not a memory system. Over months, this is where memory drift and stale facts creep in unless something handles contradiction resolution and memory consolidation.
Recursive summaries share the weakness of conversation summary memory: a summary is written before anyone knows the next question, so a detail that later matters may already be compressed away. Recall storage softens this because the raw messages are still searchable, but only if the agent thinks to search for them.
None of this makes the design wrong. It describes a specific trade: maximum agent control over memory, in exchange for more model calls and more reliance on the model’s discipline. For research agents and long-running assistants with a capable model, that trade often makes sense. For products with many users, tight latency budgets or cheaper models, teams often move memory management out of the model’s loop.
MemGPT compared with managed memory
The main alternative is managed memory, where a service extracts and maintains memories outside the agent’s reasoning loop and the agent simply asks for relevant context. The table below sets out the differences.
Aspect | MemGPT pattern | Managed memory service |
|---|---|---|
Who decides what to store | The agent, through function calls | An extraction engine, with optional direct writes |
Cost of memory upkeep | Model calls and tokens inside the agent loop | Handled by the service, outside the agent loop |
Handling changed facts | The agent edits text itself | Resolved when memories are written |
Retrieval | Paged search over recall and archival storage | Ranked search returning only relevant memories |
Best fit | Agents where memory decisions are part of the task | Products serving many users with predictable latency |
The two approaches combine well. A MemGPT-style agent can keep its working context and self-editing tools, and use a managed memory store as its archival tier, calling search as a tool when it needs something it no longer holds in the prompt.
Where Exabase fits
Exabase Memory is a managed memory service rather than a MemGPT implementation. You send conversations or text to the Memory API and the M-1 engine extracts facts, preferences and events, tracks relationships between them, resolves contradictions as facts change and consolidates related memories over time. A user who moves from Toronto to Berlin ends up with one current city, without the agent having to find and edit the old line. When you need exact control, you can write a memory verbatim with infer set to false, and mark a memory immutable so the self-organising process never changes it.
Retrieval is a single call. Memory search uses hybrid search across semantic and keyword matching with recency weighting, and can expand the query into several passes (expandQueries, 1 to 5) and apply reranking (rerankCandidates up to 500, plus a rerankThreshold). Simple retrieval returns in about 200ms, which suits a real-time agent loop. If you prefer to skip prompt assembly, memories.ask returns an answer drawn from the relevant memories.
For a MemGPT-style design, Exabase works as the external tier. Expose memories.search as the agent’s archival search tool, keep a small working context in your own prompt, and let M-1 handle extraction and upkeep in the background. Each user gets their own Base, scoped with the X-Exabase-Base-Id header as described in memory scoping, so one user’s memories never surface in another’s search. Exabase provides the memory substrate; the agent’s reasoning, tools and loop stay in your framework of choice.
M-1 scores 96.4% on LongMemEval and is state of the art on BEAM at 100K, 1M and 10M tokens. The agent memory solution page walks through the full setup, and the long-term memory use case shows how teams apply it. Memory is available on the free plan, with higher limits on paid plans listed on the pricing page.
What is MemGPT in simple terms?
MemGPT is an LLM agent design that manages its own memory like an operating system manages RAM and disk. The prompt holds a small amount of active information, and the agent uses function calls to save things to external storage and search for them later, so it can work with far more information than fits in its context window.
Is MemGPT the same as Letta?
They are closely related. MemGPT was the open-source project that came out of the 2023 Berkeley paper, and in September 2024 it became part of Letta, the company its authors founded. Letta is now the name of the framework, while MemGPT refers to the original self-editing memory pattern. See the Letta review and Letta pricing for the framework as a product.
What is the difference between recall storage and archival storage in MemGPT?
Recall storage holds the agent’s past messages, so it can search conversation history that has been evicted from the prompt. Archival storage is a general store for any text the agent chooses to save, such as documents, notes or facts, searched by similarity.
Does MemGPT solve the context window limit?
It works around it. MemGPT keeps the prompt within the model’s context window by evicting old messages and summarising them, while keeping the full history searchable. The model still sees only what is in the prompt on each call, so answers depend on the agent retrieving the right information at the right time. The difference between the two ideas is covered in memory vs context window.
How is MemGPT different from RAG?
Standard retrieval-augmented generation runs a fixed retrieval step before each answer over a static document set. MemGPT lets the agent decide when to search, what to save and what to keep in its prompt, and it writes new information back into memory as the conversation goes on. The broader comparison is in RAG vs agent memory.
What are the downsides of self-editing memory?
Memory management uses model calls and tokens, adds latency, and depends on the model’s judgment about what to store and when to look things up. Plain-text memory also has no built-in way to tell which of two conflicting facts is current, so stale information can build up over long periods.
Can I use Exabase with a MemGPT-style agent?
Yes. Use Exabase Memory as the external memory tier: send conversations to the Memory API, expose memory search to your agent as a tool, and scope each user to their own Base. Exabase handles extraction, contradiction resolution and consolidation, while your agent keeps control of its loop and working context.
Related pages: Virtual context management, Agent memory, Working memory, Memory retrieval, Generative agents, Exabase vs Letta, Mem0 vs Letta, The context window is not memory, Agent memory solution, Mem0 alternatives