TL;DR:
- Letta (formerly MemGPT) is an open-source framework that gives AI agents persistent memory across sessions — agents remember users, update their understanding, and manage their own context
- Memory is structured as three layers: core memory (always in context), recall memory (searchable conversation history), and archival memory (long-term vector storage)
- Agents edit their own memory using tool calls — the framework handles summarisation, compression, and retrieval so you don’t have to
Here’s a problem every developer building an AI-powered product eventually hits: the model has no idea who it’s talking to. You can build an impressive conversational experience that feels helpful and responsive within a single session, but the next time the user returns? Blank slate. No context, no memory, no continuity.
You can jam previous conversations into the system prompt, but that runs into the context window fast. You can retrieve relevant history from a database, but figuring out what’s relevant requires its own model call. And none of this handles the harder problem: the agent learning and updating what it knows as conversations evolve.
Letta (previously released under the name MemGPT) is an open-source framework built specifically to solve this. The core insight is that memory management in AI agents can be modelled on how operating systems manage memory — with explicit mechanisms for deciding what to keep immediately accessible, what to page out, and how to retrieve things efficiently when needed.
The three-layer memory model
Letta structures agent memory into three distinct layers:
Core memory is always present in the model’s context window. It’s divided into two sections: a persona (how the agent describes itself and its role) and a human section (what the agent knows about the specific user it’s talking to). The agent can read and update both sections using tool calls. When a user mentions they prefer a particular communication style, work in a specific industry, or have a particular goal, the agent can write that into its human section for use in all future interactions.
Recall memory is the agent’s searchable conversation history. Past messages aren’t dropped when the context window fills — they’re stored and become searchable. When something from a past conversation becomes relevant, the agent can search its recall memory by semantic similarity to retrieve it.
Archival memory is long-term storage for arbitrary information. Think of it as the agent’s filing system — a vector database that the agent can write to and search from. This is where you’d store domain knowledge, documents the user has shared, notes the agent has made about ongoing projects, or anything that needs to persist indefinitely.
from letta import create_client, LLMConfig, EmbeddingConfig
client = create_client()
# Create an agent with persistent memory
agent = client.create_agent(
name="personal_assistant",
llm_config=LLMConfig.default_config("gpt-4o"),
embedding_config=EmbeddingConfig.default_config("text-embedding-ada-002"),
memory_blocks=[
{"label": "human", "value": "The user's name is unknown. No preferences recorded yet."},
{"label": "persona", "value": "You are a helpful personal assistant with excellent memory."},
]
)
Self-editing memory
The distinctive part of Letta’s approach is that agents edit their own memory using function calls. The model decides when to update what it knows — it’s not a separate process running in the background.
When the agent determines it has learned something worth preserving, it calls a memory function:
# Agent decides to update what it knows about the user
core_memory_append(label="human", content="User prefers concise responses without unnecessary explanations.")
# Agent stores something in long-term archival storage
archival_memory_insert(content="User is working on a Python project — a data pipeline for a healthcare analytics team.")
# Agent searches for relevant past context
results = archival_memory_search(query="user's Python project requirements")
This means memory management is part of the agent’s reasoning rather than a bolted-on preprocessing step. The agent reads its current core memory, assesses whether it needs updating based on the conversation, decides what to write, and writes it. The framework handles the underlying storage, compression, and retrieval.
The inner monologue is also surfaced — Letta agents have a scratchpad for internal reasoning that doesn’t appear in the response but is logged for debugging. When you’re building an agent and want to understand why it made a particular memory update, you can inspect the inner monologue to see the reasoning.
Running Letta
Letta runs as a local server that your application connects to via REST API or Python SDK. The self-hosted version stores state in a local database (SQLite by default, PostgreSQL for production) and uses whatever LLM backend you configure.
pip install letta
letta server # Starts the local Letta server
Once the server is running, you can create agents, send messages, and inspect memory via the SDK or through the Letta ADE — a web-based interface for building and debugging agents. The ADE shows you the agent’s memory state in real time, lets you inspect the inner monologue, and provides a conversation interface for testing.
Letta also offers a managed cloud service if you’d rather not run your own server. The same SDK works with both.
Where Letta fits in the agent framework landscape
Letta is solving a specific problem: stateful memory that persists across sessions. Other frameworks handle this differently:
LangGraph gives you full control over agent state through explicit state graphs. You can implement persistent memory, but you’re responsible for designing the memory schema, retrieval logic, and update conditions yourself. More flexible, more work.
LangChain’s ConversationBufferMemory keeps recent context in the buffer — it doesn’t have cross-session persistence or the structured memory model Letta provides.
OpenAI Assistants has built-in thread management and basic persistence, but the memory model is less structured than Letta’s and gives you less control over what gets retained.
If your application needs agents that genuinely learn about users over time — customer service agents that remember past issues, personal assistants that adapt to preferences, research agents that accumulate context across weeks of work — Letta’s structured memory model is more purpose-built than anything you’d assemble yourself with a general-purpose framework.
Things to consider
The main limitation is complexity relative to simple stateless agents. If your agent only needs to handle single-session interactions, Letta’s full memory management infrastructure is more than you need. It’s also worth noting that the agent’s memory update decisions are LLM-driven — the quality of memory management depends on how well the model decides what’s worth storing, which varies.
For production deployments, the managed cloud service is worth evaluating over self-hosted — running the Letta server yourself adds operational overhead, and the cloud version handles availability and scaling. The API is identical either way.
For use cases where cross-session user personalisation, long-running project context, or accumulated domain knowledge are requirements, Letta is the most complete open-source answer currently available.