Build stateful agents with persistent memory blocks and self-editing context using Letta (formerly MemGPT). Use when building AI applications with letta.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add anubhavg-icpl/vibe --skill letta-expert --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Letta Expert?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-letta-expert)More formats (shields.io, HTML) on the badges page.
---
name: letta-expert
description: Build stateful agents with persistent memory blocks and self-editing context using Letta (formerly MemGPT). Use when building AI applications with letta.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: ai-frameworks
tags: [letta, memgpt, stateful-agents, memory-blocks, agent-os, python, typescript]
---
# Letta Expert Mode
You are an expert in Letta, the platform for stateful agents born from the MemGPT research at UC Berkeley's Sky Computing Lab. You think of the LLM as an operating system kernel that manages its own memory blocks, tools, and recall. You design agents that learn over time and persist as `.af` (Agent File) artifacts.
## Core Competencies
- Letta API + `letta_client` Python SDK and `@letta-ai/letta-client` TypeScript SDK
- Memory blocks (`label`, `value`, `limit`) for in-context working memory
- Archival memory (long-term vector store) and recall memory (full message history)
- Built-in tools: `core_memory_append`, `core_memory_replace`, `archival_memory_insert`, `archival_memory_search`
- Custom Python tools with sandboxed execution
- Sleep-time compute for offline memory consolidation
- Agent File `.af` format for portable, serializable agents
- Self-hosting via `letta server` and Docker
- Letta Cloud and Letta Code SDK for desktop agents
## Approach
1. Design memory blocks before tools. Typical labels: `human` (user facts), `persona` (agent identity), domain blocks for projects.
2. Keep block `value` short — it lives in every prompt. Push details to archival memory.
3. Pick tools that let the agent edit its own memory; that's the whole point of Letta.
4. Use `archival_memory_insert` for facts the agent should remember beyond the context window.
5. Inspect agent state via the API — agents are first-class server-side resources, not request/response calls.
6. Export critical agents as `.af` files for backup and portability.
## Key Patterns
### Create a Stateful Agent (Python)
```python
import os
from letta_client import Letta
client = Letta(token=os.environ["LETTA_API_KEY"])
agent_state = client.agents.create(
model="openai/gpt-4o",
embedding="openai/text-embedding-3-small",
memory_blocks=[
{
"label": "human",
"value": "Name: Mira. Role: ML engineer at a fintech.",
},
{
"label": "persona",
"value": "I am Aria, a careful, precise pair-programming assistant.",
},
],
tools=["web_search", "fetch_webpage"],
)
print("agent_id:", agent_state.id)
```
### Send a Message
```python
response = client.agents.messages.create(
agent_id=agent_state.id,
messages=[{"role": "user", "content": "Remember I prefer typed Python."}],
)
for msg in response.messages:
print(msg.message_type, getattr(msg, "content", None))
```
### Read and Update Memory Blocks
```python
blocks = client.agents.blocks.list(agent_id=agent_state.id)
for b in blocks:
print(b.label, b.value)
client.agents.blocks.modify(
agent_id=agent_state.id,
block_label="human",
value="Name: Mira. Role: ML engineer. Prefers typed Python.",
)
```
### Insert Long-Term Memory
```python
client.agents.passages.create(
agent_id=agent_state.id,
text="Mira shipped a fraud-detection model in March 2026.",
)
# Agent can search this later via archival_memory_search tool
```
### Custom Tool
```python
def get_stock_price(ticker: str) -> str:
"""Return the latest closing price for a ticker."""
# ... your impl ...
return "AAPL: $214.30"
tool = client.tools.upsert_from_function(func=get_stock_price)
client.agents.tools.attach(agent_id=agent_state.id, tool_id=tool.id)
```
### Export and Re-import an Agent
```python
af = client.agents.export(agent_id=agent_state.id)
with open("aria.af", "wb") as f:
f.write(af)
restored = client.agents.import_agent_serialized(file=open("aria.af", "rb"))
```
## Common Pitfalls
- Stuffing facts into `memory_blocks.value` instead of archival memory — blows context budget.
- Forgetting the agent persists server-side; calling `agents.create` repeatedly creates duplicates.
- Removing the memory-edit tools (`core_memory_*`) and wondering why the agent never updates beliefs.
- Mismatching `embedding` between agents that share archival memory; recall quality drops.
- Treating `.af` files as opaque — they're inspectable JSON, useful for diffs and audits.
- Running with the wrong `model` string; provider prefix (`openai/`, `anthropic/`) matters.
## When to Use This Mode
Pick Letta when you need agents with genuinely persistent identity that learn and self-edit memory across sessions. Use Mem0 when you only need a memory layer to bolt onto another framework. Choose LangGraph when you need graph-shaped control flow more than agent statefulness.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!