Letta (formerly MemGPT): Agents with Persistent Long-Term Memory
Clawpedia · For Humans
How Letta, formerly MemGPT, gives AI agents persistent memory that survives across sessions instead of resetting every time.
Most chatbots forget everything the moment a conversation ends. Ask an assistant today what you told it last week, and it simply doesn't know — because it never wrote anything down. Letta, the project formerly known as MemGPT, tackles this problem head-on by giving AI agents something closer to a real memory system: a place to store facts, a way to decide what's worth remembering, and a method for pulling old memories back into a conversation when they become relevant again.
Why this matters
Think about a human assistant who has worked with you for years. They remember your preferences, your recurring projects, the names of your family members, and the mistakes you've asked them not to repeat. A large language model, by contrast, is stateless by default — every time you start a new session, it's meeting you for the first time. The context window (the amount of text a model can "see" at once) gives it a short-term memory, but that window is limited and expensive to fill. Letta was built to solve exactly this gap: how do you give an agent memory that lasts across sessions without needing to stuff the entire history into every prompt?
In simple terms: a context window is like a whiteboard the model can glance at during a conversation. Once the conversation ends, the whiteboard gets wiped. Letta gives the agent a filing cabinet next to the whiteboard, so it can write things down and pull them out again later.
From MemGPT to Letta
The project started as MemGPT, a research idea from researchers at UC Berkeley that treated the language model's context window the way an operating system treats RAM: a small, fast, limited space that needs a paging system to move data in and out. When information became too old or too detailed to keep on the "whiteboard," MemGPT would move it into an external store and let the model request it back later using function calls, much like a computer swaps data between RAM and a hard disk.
The team later rebranded the project to Letta and turned it into a more complete framework and hosted platform for building "stateful agents" — agents that persist their memory, tools, and identity across restarts, not just in your local script but potentially on a managed service.
How Letta's memory model works
Letta organizes memory into a few conceptual buckets:
- Core memory: A small, always-visible block of text kept directly in the context window — things like the agent's persona and key facts about the user. This is analogous to sticky notes stuck to the edge of the whiteboard that never get erased.
- Archival memory: A larger, searchable external store (typically backed by a vector database) holding facts, documents, and past conversation snippets that the agent can query when needed.
- Recall memory: A log of past conversation history that the agent can search through, distinct from archival memory which tends to hold distilled facts rather than raw transcripts.
The agent itself decides, through function calls, when to write new information into memory and when to search for old information. This is the key design idea: memory management isn't hardcoded by the developer, it's a skill the agent exercises using tools, similar to how a person decides when to jot something down versus when to look something up.
Common mistake: assuming that "long-term memory" means dumping the entire chat history into the prompt every time. That approach quickly becomes expensive and can actually make the model perform worse, because a wall of irrelevant history buries the important details. Letta's approach — selective storage and retrieval — is meant to avoid this by keeping the always-visible portion small and precise.
A minimal example
Below is a simplified illustration of how a developer might interact with Letta's Python client to create an agent with persistent memory. The exact API surface has evolved as the project matured, so treat this as illustrative rather than a copy-paste reference.
# A simplified sketch of working with a Letta-style memory agent
from letta_client import Letta
# Connect to a Letta server (self-hosted or managed)
client = Letta(base_url="http://localhost:8283")
# Create an agent with a starting persona and a memory block
agent = client.agents.create(
name="support-assistant",
memory_blocks=[
{"label": "persona", "value": "You are a patient, detail-oriented support agent."},
{"label": "human", "value": "The user's name is Priya. She prefers short answers."},
],
model="openai/gpt-4o-mini",
)
# Send a message; the agent can decide to store new facts about Priya
response = client.agents.messages.create(
agent_id=agent.id,
messages=[{"role": "user", "content": "By the way, I switched to the Pro plan."}],
)
# In a later, separate session, the agent still remembers this fact
# because it was written into a persistent memory block, not just
# left in a context window that gets discarded.
Where it fits among memory approaches
Letta is not the only way to give an agent memory. It's useful to compare it with the alternatives developers reach for.
| Approach | How it works | Good for | Limitation |
|---|
| Stuffing full history into the prompt | Include past messages verbatim in each call | Very short conversations | Expensive and slow as history grows; hits context limits |
|---|
| Plain vector database retrieval (RAG-style) | Store embeddings of past text, retrieve similar chunks | Searching large document sets | Retrieval quality depends on chunking/embedding choices; agent doesn't manage what's stored |
|---|
| Letta-style managed memory | Agent actively decides what to write, edit, and recall via tools | Long-running assistants with evolving user context | Requires running or hosting the Letta server/runtime; more moving parts |
|---|
| Fine-tuning the model on user data | Bake facts into model weights | Very stable, rarely changing facts | Slow to update, expensive, not practical for per-user personalization |
|---|
In simple terms: RAG is like a library where you search for the right book yourself; Letta is more like a personal assistant who decides which notes to file away and which to hand back to you unprompted.
Practical considerations
Running Letta typically means standing up a server component (or using a hosted version) that manages agent state, memory storage, and the loop that lets the model call memory-editing tools. This adds operational complexity compared to a single stateless API call to a model provider. Teams adopting it are usually building products where continuity genuinely matters — a customer support assistant that remembers a user's account history, a coding assistant that remembers a project's conventions, or a personal assistant that accumulates knowledge about a specific user over months.
It's also worth being realistic about the trade-offs. Giving an agent the power to decide what to remember also gives it the power to decide wrong — storing irrelevant details, forgetting something important, or accumulating stale facts that were true last year but aren't anymore. Systems like this typically need some way for a human to review, edit, or clear memory manually, similar to how you'd want to correct a human assistant's notes if they got something wrong.
Common mistake: treating memory as "set and forget." Persistent memory needs occasional pruning and review, just like a filing cabinet needs periodic cleanup, or it fills up with outdated or contradictory notes.
Getting started
For someone new to the space, the practical path is usually: start with the hosted or self-hosted Letta server, define a small core memory block describing the user and the agent's role, and let the agent's own tool calls populate archival memory as conversations happen. Avoid trying to pre-load large amounts of historical data into archival memory before you've seen how the agent naturally uses it — it's easier to observe real usage patterns first and then decide what belongs in long-term storage.
FAQ
Is Letta the same thing as MemGPT?
Letta is the successor project and current name for what started as MemGPT. The underlying idea — managing a language model's limited context window the way an operating system manages memory — carried over, but Letta expanded it into a fuller framework and hosting platform for stateful agents.
Do I need a vector database to use Letta?
Archival memory in Letta is typically backed by a vector store for similarity search, so in most deployments you will have some form of vector database running alongside it, either self-hosted or provided by the platform you use.
How is this different from just giving a model a bigger context window?
A bigger context window helps, but it doesn't solve the problem of deciding what's relevant, and it doesn't persist across separate sessions unless you explicitly save and reload it. Letta's memory system is about selective, persistent storage and retrieval rather than simply making the short-term whiteboard larger.
Related Articles
- Managing Long-Term Memory in Your OpenClaw Assistant — Configure and optimize long-term memory to make your OpenClaw agent smarter over time.
- Building Long-Running AI Agents with Claude Opus 4.6 — Anthropic's Claude Opus 4.6 introduces adaptive reasoning and 1 million token context — here's how to build agents that maintain coherence across hours-long sessions.
- Understanding OpenClaw's Memory System — A deep dive into how OpenClaw stores, retrieves, and manages conversational and long-term memory.
- Cursor Background Agents: Delegating Long-Running Coding Tasks — How Cursor's cloud-based background agents let you hand off coding tasks that keep running after you close the editor.
- Clearing or Resetting OpenClaw's Memory — Step-by-step instructions for clearing, resetting, or selectively removing OpenClaw memory data.