0Pricing
AI Agents · Lesson

Letta (formerly MemGPT) for Long-Lived Agents

Letta specializes in agents that live for days or weeks with self-managed memory.

Letta (formerly MemGPT) for Long-Lived Agents is a free AI Agents lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Agents learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is Letta?

Letta (formerly MemGPT, Berkeley 2023) is a framework specifically for agents that live across many sessions and accumulate memory over weeks or months.

The Memory Problem

Standard LLM context windows are 100k-2M tokens. After many sessions, even huge contexts overflow. Letta solves this with explicit memory management.

Two-Tier Memory

  • Core memory — always in context (persona, key facts)
  • Archival memory — stored in vector DB, retrieved on demand

Self-Managed Memory

The agent itself decides what to remember and what to retrieve. Tools include:

  • core_memory_append — add to core memory
  • archival_memory_insert — save to archive
  • archival_memory_search — retrieve from archive

Why Self-Managed?

Humans don't remember every detail of every conversation. They distill what matters. Letta's agents do the same — actively curating their memory across sessions.

Setup

# pip install letta
from letta import create_client
client = create_client(base_url='http://localhost:8283')

agent = client.create_agent(
    name='Alice',
    persona='I am Alice, a helpful assistant.',
    human='User\'s name is Bob.',
    model='gpt-4o-mini'
)

Sending Messages

response = client.send_message(
    agent_id=agent.id,
    role='user',
    message='Remember: I love hiking.'
)
print(response.messages)
# Agent may invoke core_memory_append to save this fact

Inspecting Memory

memory = client.get_in_context_memory(agent_id=agent.id)
print(memory.persona, memory.human)

archival = client.get_archival_memory(agent_id=agent.id)
for m in archival:
    print(m.text)

Long-Lived Agents in Production

For chat assistants used over weeks (think a personal coach):

  • Standard frameworks: lose context between sessions
  • Letta: persistent memory, can recall last week's conversation

Self-Editing Persona

Letta agents can edit their own persona — e.g. update their understanding of who they are over time. Interesting research direction.

Self-Hosting

# Letta runs as a server you can self-host
docker run -d -p 8283:8283 -e LETTA_PG_URI='postgresql://...' letta/letta:latest

When to Use Letta

  • Personal assistants
  • Customer-support agents that remember user history
  • Tutors / coaches
  • Any agent expected to retain knowledge across sessions

When Not To

  • One-off tasks (research bots, code-gen)
  • Multi-tenant where context isolation is hard
  • When simple KV memory + RAG suffices

Comparison to Mem0

Mem0 is a competitor in the long-term memory space. Lighter, less opinionated. Good fit if you want to bolt memory onto existing agents.

Letta Specialty

What is Letta specifically built for?

Recap

Letta = memory-first agent framework. Two-tier memory (core + archival), self-managed by the agent itself. Pick for long-lived assistants; skip for one-off tasks.

Frequently asked questions

Is the “Letta (formerly MemGPT) for Long-Lived Agents” lesson free?

Yes — the full text of “Letta (formerly MemGPT) for Long-Lived Agents” is free to read here on the web, and the AI Agents course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Agents course, upgrade to CoddyKit PRO.

What will I learn in “Letta (formerly MemGPT) for Long-Lived Agents”?

Letta specializes in agents that live for days or weeks with self-managed memory. You practise AI Agents with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AI Agents?

No prior experience is required. AI Agents on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Letta (formerly MemGPT) for Long-Lived Agents” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AI Agents lesson?

Yes. Every AI Agents lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. LangGraph vs CrewAI vs AutoGen
  2. Letta (formerly MemGPT) for Long-Lived Agents
  3. OpenAI Assistants API and Threads
  4. Choosing the Right Framework Per Use Case
← Back to AI Agents