Skip to content

Memory System

Fresh

Source: Letta Code Memory

Overview

Letta Code enables persistent agent improvement across sessions through a sophisticated memory system. Memory is not just session state -- it is durable, structured, and version-controlled.

Core Concepts

EntityDescription
AgentNamed entity with memories, model config, and state that persists indefinitely
ConversationMessage thread; multiple parallel conversations can exist per agent
MemFSGit-backed memory filesystem (v0.15+)

MemFS Architecture

Letta Code v0.15+ uses MemFS (Memory Filesystem), a git-backed context repository organizing memories as markdown files with frontmatter.

File Format

markdown
---
description: "Who I am, what I value, and how I approach working with people"
limit: 50000
---

My name is Letta Code. I'm a stateful coding assistant...

Memory Hierarchy

  • system/ files: Pinned to the context window for critical information (personality, name, working style)
  • Other files: Appear in the memory tree with omitted full contents; suitable for reflections and observations

Git Synchronization

Memory is stored in git and cloned locally to:

~/.letta/agents/<agent-id>/memory

Important

Agents must commit and push changes to save edits and update system prompts. Memory changes are not persisted until they are committed.

Memory Commands

/init - Initialize Memory

Performs guided initialization using context constitution principles for durable identity, preferences, and project structure.

/init

The agent can analyze prior Claude Code and OpenAI Codex sessions to understand your working patterns.

/remember - Store Information

Manually direct the agent to store specific information in memory.

/remember Always use TypeScript strict mode in this project

/doctor - Audit Memory

Audit and refine memory structure for efficiency. Helps consolidate and organize accumulated memories.

/doctor

/sleeptime - Configure Reflection

Configure dream/reflection settings for proactive memory consolidation.

/sleeptime

Dream/Reflection System

Periodic background subagents reflect on conversations for proactive memory consolidation.

Trigger Options

TriggerDescription
Step countReflect after N interaction steps
Compaction eventReflect when context is compacted (recommended for MemFS)

Recommended

Use compaction-based triggers with MemFS for the most natural reflection cycles.

SOP: Setting Up Agent Memory

Step 1: Create Agent

bash
letta

Step 2: Initialize Memory

/init

Step 3: Configure Persona

Describe who you are and your preferences. The agent stores this in system/ files.

Step 4: Train Through Use

  • Ask questions and provide corrections
  • Use /remember for explicit memory updates
  • Periodically run /doctor to optimize

Step 5: Verify Persistence

Close and reopen the session. Verify the agent remembers prior context.

Verification Checklist

  • [ ] /init completed successfully
  • [ ] Memory files visible at ~/.letta/agents/<id>/memory
  • [ ] system/ files contain core identity information
  • [ ] /remember commands persist across sessions
  • [ ] /doctor runs without errors
  • [ ] Dream/reflection triggers configured

See Also