What MemGPT Is, and the Four Types of AI Agent Memory
MemGPT is a 2023 Berkeley design that treats an LLM's context window like RAM and external storage like disk, letting the model page information in and out with function calls. Agent memory is usually split four ways: working memory in the prompt, episodic memory of past events, semantic memory of facts, and procedural memory of skills.
The lecture this page starts from
Stanford Online published Lecture 7 of CS329Z: Engineering AI Agents on 15 November 2026. It was recorded on 14 October 2026 in the graduate course taught by Diyi Yang, Michael Ryan and John Yang, with Michael Ryan presenting. The lecture description lists its scope: the four types of agent memory (working, episodic, semantic, procedural), storing memories in files, databases or knowledge graphs, and architecture patterns including skill libraries like Voyager, tiered memory like MemGPT, reflective consolidation, and memory maintenance with A-MEM and Mem0. It closes on benchmarks and open problems in forgetting, privacy and over-personalization.
This guide goes to the primary sources for two of those topics, MemGPT and the memory taxonomy, so you can read them alongside the lecture. Watch the lecture for the rest.
MemGPT: the context window as RAM
MemGPT comes from the paper "MemGPT: Towards LLMs as Operating Systems" by Charles Packer, Sarah Wooders, Kevin Lin, Vivian Fang, Shishir G. Patil, Ion Stoica and Joseph E. Gonzalez, posted to arXiv in October 2023 (2310.08560, revised February 2024). Its core idea is virtual context management, borrowed from how operating systems give programs the illusion of more memory than physically exists. The context window plays the role of RAM: small, fast, and the only thing the processor can see. External storage plays the role of disk: large, slower, and reachable only by explicit reads and writes. The twist is that the LLM itself decides what to page in and out, using function calls.
Main context: what the model sees
The paper splits the prompt into three parts. Read-only system instructions describe the agent and its memory functions. Working context is a fixed-size, read and write block of unstructured text where the agent keeps key facts about the user and the task. A FIFO queue holds the rolling message history, and its first entry is a recursive summary of messages already evicted.
External context: what the model can fetch
Recall storage holds the complete message history and can be searched with functions, so nothing evicted is truly lost. Archival storage is a database for arbitrary-length text, used for long-term information such as documents or facts the agent chose to save.
Memory pressure and eviction
A queue manager watches token use. In the paper's example, at 70 percent of the window it inserts a memory pressure warning so the model can save anything important to working context or archival storage. At 100 percent it evicts a share of messages, 50 percent in the example, and folds them into a new recursive summary. A request_heartbeat flag on a function call hands control straight back to the model, which lets it chain several searches before answering.
What the paper measured
The authors evaluated two settings where a fixed window breaks. In multi-session chat, a deep memory retrieval task asks about details from earlier sessions; the paper reports 93.4 percent accuracy for MemGPT on GPT-4 Turbo against 35.3 percent for the baseline model alone. In document analysis, MemGPT can page through archival search results instead of being capped by a retriever's top-K, and on a nested key-value lookup task the paper reports that fixed-context baselines fall to zero by three levels of nesting while MemGPT with GPT-4 holds up. These are 2023 results on 2023 models.
The four types of agent memory
The working, episodic, semantic and procedural split most courses use is laid out for language agents in "Cognitive Architectures for Language Agents" (CoALA) by Theodore Sumers, Shunyu Yao, Karthik Narasimhan and Thomas Griffiths (arXiv 2309.02427, 2023), which adapts categories from cognitive science.
Working memory
CoALA defines it as the active information for the current decision cycle. In practice this is the prompt: instructions, the current goal, recent turns and whatever was just retrieved. It is the only memory the model reasons over directly.
Episodic memory
Experience from earlier decision cycles: what happened, when, and how it turned out. Conversation logs, past task trajectories and records of failed attempts are episodic. MemGPT's recall storage is an episodic store.
Semantic memory
Knowledge about the world and about the agent itself: facts, preferences, documentation. MemGPT's archival storage and its working context both hold semantic memory, at different levels of permanence.
Procedural memory
How to do things. CoALA notes two forms: implicit knowledge in the model's weights and explicit knowledge written in the agent's code. Tool definitions, prompts and skill libraries such as Voyager's stored code routines are procedural. CoALA also names the internal actions that connect these stores: retrieval reads long-term memory into working memory, and learning writes to long-term memory.
From MemGPT to Letta
In September 2024 the MemGPT project and its company were renamed Letta, with MemGPT kept as the name of the research design pattern. Letta's v1 SDK documentation, now marked legacy, kept the shape of the paper: memory blocks pinned in context, and archival memory as a semantically searchable store that agents query on demand with archival_memory_insert and archival_memory_search. Letta's current docs describe MemFS instead, a git-backed memory filesystem. Files at the memory root load into the system prompt every turn, directories with their own MEMORY.md index stay out of context until the agent opens them, and no vector index is included by default.
The tiers survived; the storage changed. Always-loaded memory stays small, everything else waits outside the window until the agent asks for it.
What to take from it when building
Decide which tier each kind of memory lives in before choosing a database. Keep working memory small and curated. Log episodes so they can be searched, not replayed. Give semantic memory an explicit write step, because an agent that saves everything retrieves noise. Treat procedural memory as code you version.
For the semantic tier, an external retrieval layer does the archival job without building it yourself. RDK indexes vaults, docs and code as encrypted private chunks; agents query over MCP, the CLI or the Partner API and get a few hundred tokens of context instead of whole documents, which cuts token spend 80 to 90 percent on repeated or reference-heavy work.
Frequently asked questions
- What is MemGPT in simple terms?
- MemGPT is a 2023 research design from UC Berkeley that lets an LLM manage its own memory like an operating system manages RAM and disk. The prompt holds a small working set, larger stores sit outside it, and the model uses function calls to search, save and evict information. That gives the effect of unlimited context on a fixed-size window.
- Is MemGPT the same thing as Letta?
- Letta is the company and open source project that grew out of MemGPT; the project was renamed in September 2024. MemGPT now refers to the original research design pattern. Letta's tooling has moved on since: its current docs describe MemFS, a git-backed memory filesystem, while its older SDK used memory blocks and archival memory closer to the paper.
- What are the four types of AI agent memory?
- Working memory is what the model sees right now, the prompt. Episodic memory records past events and interactions. Semantic memory holds facts and knowledge, including about the user. Procedural memory covers how to act, in model weights, prompts, tools and code. The split is set out for language agents in the 2023 CoALA paper, adapted from cognitive science.
- What is the difference between episodic and semantic memory in an agent?
- Episodic memory stores specific experiences with their context, such as a past conversation or a failed attempt at a task. Semantic memory stores general knowledge distilled from those experiences or loaded from documents, such as a user's preferences or how an API works. Many systems periodically consolidate episodes into semantic facts so the agent retrieves the lesson rather than the whole transcript.
- Does MemGPT still matter if models have million-token context windows?
- Yes, because a bigger window does not remove the cost of filling it or the drop in accuracy on long, crowded inputs. The MemGPT pattern keeps the prompt small and fetches on demand, which stays cheaper and often more accurate. Long windows mainly raise the size of the working set, not the need for tiers outside it.