Letta — Stateful AI Agents with Memory
Letta builds stateful AI agents that learn and self-improve with advanced memory. 21.8K+ stars. CLI, Python/TS SDKs, skills, subagents. Apache 2.0.
What it is
Letta (formerly MemGPT) is a platform for building stateful AI agents with advanced memory management. Agents built with Letta maintain persistent memory across conversations, can self-edit their own context and instructions, and orchestrate subagents for complex tasks.
Letta targets developers building AI agents that need to remember user preferences, learn from interactions, and maintain context over long periods. It provides CLI tools, Python and TypeScript SDKs, and a skills system for extending agent capabilities. Apache 2.0 licensed.
How it saves time or tokens
Standard LLM conversations lose context when the session ends. Letta agents maintain a structured memory system with core memory (always in context), archival memory (searchable long-term storage), and recall memory (conversation history). This means agents do not need to be re-prompted with background information each session.
The estimated token cost for this workflow is approximately 264 tokens. By managing memory tiers, Letta keeps the active context window small while retaining access to large knowledge bases.
How to use
- Install Letta:
npm install -g @letta-ai/letta-code
# Or Python:
pip install letta-client
- Create and configure an agent:
from letta import create_client
client = create_client()
agent = client.create_agent(
name='my-assistant',
memory={
'human': 'User is a Python developer working on ML projects',
'persona': 'I am a helpful coding assistant'
}
)
- Chat with the agent -- it remembers across sessions:
response = client.send_message(
agent_id=agent.id,
message='Remember that I prefer pytest over unittest'
)
# Next session, the agent still knows this preference
Example
# Agent with archival memory search
from letta import create_client
client = create_client()
agent = client.create_agent(name='research-agent')
# Store knowledge in archival memory
client.insert_archival_memory(
agent_id=agent.id,
memory='The project uses FastAPI 0.115 with Pydantic v2'
)
client.insert_archival_memory(
agent_id=agent.id,
memory='Database is PostgreSQL 16 with pgvector extension'
)
# Agent searches archival memory when answering
response = client.send_message(
agent_id=agent.id,
message='What database does our project use?'
)
# Agent retrieves from archival: PostgreSQL 16 with pgvector
Related on TokRepo
- AI Memory Tools -- Deep-dive into Letta's memory architecture
- AI Tools for Agents -- Compare agent frameworks with memory capabilities
Common pitfalls
- Letta agents use LLM calls to manage memory (deciding what to store, what to retrieve). This adds token overhead per interaction compared to stateless agents.
- Archival memory search quality depends on the embedding model. Use a high-quality embedding model for better retrieval accuracy.
- Self-editing memory means the agent can modify its own instructions. Set guardrails if you need the agent to maintain specific behaviors.
Frequently Asked Questions
Letta is the evolution of MemGPT. The project was renamed as it expanded beyond the original memory-focused research into a full agent platform with SDKs, skills, subagents, and production deployment features.
Letta has three tiers: core memory (always in the LLM context window), archival memory (long-term searchable storage), and recall memory (conversation history). The agent decides when to move information between tiers.
Yes. Letta supports OpenAI, Anthropic Claude, and open-source models via compatible APIs. The memory management layer is LLM-agnostic.
Yes. Letta has a skills system that lets you attach Python functions as tools to agents. Agents can call these tools during conversations. Skills can be shared and reused across agents.
Letta provides a server mode with REST APIs for production deployments. It supports multiple concurrent agents, persistent storage, and user authentication. The platform is designed for production AI agent workloads.
Citations (3)
- Letta GitHub Repository— Letta builds stateful AI agents with advanced memory
- Letta Documentation— Three-tier memory: core, archival, and recall
- MemGPT Paper— Originally MemGPT research project, now a full agent platform
Related on TokRepo
Source & Thanks
letta-ai/letta — 21,800+ GitHub stars
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.