Thanks to visit codestin.com
Credit goes to docs.letta.com

Skip to content
Sign up
Features

Memory

Understand Letta Code's hierarchical memory system

With Letta Code, you can use the same agent indefinitely - across sessions, days, or months - and have it get better over time. Your agent remembers past interactions, learns your preferences, and self-edits its own memory as it works.

Letta Code agents are intended to become more sophisticated over time. It is generally good practice to work with a single agent per git repository, for example — this will help develop an agent highly specialized to specific projects or tasks. You can further specialize your agents by working with agents that focus on specific aspects of your project, such as design, backend, security, database, etc.

When you run letta in a project directory, Letta Code automatically resumes your last used agent:

Start Letta Code
letta
● Resumed last used agent in ~/my-project
→ Agent: my-agent
→ https://app.letta.com/agents/agent-xxx
→ Use /pinned or /resume to switch agents
  • Existing project → resumes the last used agent automatically
  • New project → creates a new agent automatically

You can close your terminal, come back days later, and pick up right where you left off.

Force create a new agent
letta --new
Connect to a specific agent by ID
letta --agent <agent-id>

Pin agents to quickly access them across projects.

Pin current agent globally (available everywhere)
> /pin
Pin current agent locally (this project only)
> /pin -l
Unpin globally
> /unpin
Unpin locally
> /unpin -l

You can also rename the agent while pinning:

Rename and pin
> /pin MyAgent
Open the pinned agents selector
> /pinned
Browse all agents
> /resume

Use the selector to:

  • Enter - Switch to an agent
  • P - Pin/unpin the selected agent locally
  • D - Unpin from all locations

When starting with a new project, run /init to help your agent understand the codebase:

Terminal window
> /init

The agent will first ask you questions to understand your needs:

  • Research depth: Standard (quick, ~5-20 tool calls) or deep (comprehensive, ~100+ tool calls)
  • Your identity: Which git contributor are you? This helps correlate git history to your coding style
  • Related repositories: Are there other repos (backend, shared libs) you work with?
  • Workflow preferences: How proactive should the agent be? Auto-commit or ask first?
  • Communication style: Terse or detailed responses?

Then the agent will research your project:

Standard initialization focuses on essentials:

  • Reads README, package.json, configuration files
  • Reviews git status and recent commits (provided automatically)
  • Explores key directories
  • Creates/updates memory blocks with project commands, architecture, and your preferences

Deep research initialization is comprehensive:

  • Everything in standard, plus:
  • Analyzes git history for commit patterns and conventions
  • Identifies main contributors and team dynamics
  • Explores architecture deeply across multiple directories
  • Identifies pain points (frequently buggy areas) and code evolution
  • Creates specialized memory blocks for conventions, gotchas, and architecture

/init typically creates or updates these blocks:

  • human: Your identity, workflow preferences, and communication style
  • persona: Behavioral rules you want the agent to follow
  • project: Often split into multiple focused blocks:
    • project-commands: Build, test, lint commands
    • project-architecture: Directory structure and key modules
    • project-conventions: Commit style, PR process, code patterns
    • project-gotchas: Footguns and things to watch out for

The agent updates memory incrementally as it researches, ensuring nothing is lost even in long research sessions.

Run /init again whenever you want the agent to re-analyze the project, such as after major changes or adding documentation that you want the agent to ingest.

As the agent works, it may update its memory with important information. For example, after discovering your project uses pnpm instead of npm, it may decide to remember that for future sessions.

Agents can sometimes fail to store information on their own, or they may not notice that a particular piece of information is useful for the future.

You can use /remember to explicitly tell the agent to remember something:

Remember something specific
> /remember Always use pnpm instead of npm in this project

Without arguments, the agent reflects on recent interactions and updates memory as appropriate:

Suggest a memory update without specifics
> /remember

The prompt used when invoking /remember is available here.

Agents remember information using tools, such as memory. Agents must actively choose to remember information, unless the agent has a sleeptime agent attached. When a sleeptime agent is attached to your coding agent, memory operations are offloaded to an asynchronous agent designed to passively update memories while the primary agent works. To enable sleeptime agents when creating a new agent:

Create agent with sleeptime
letta --new --sleeptime

Or set it as the default in ~/.letta/settings.json:

~/.letta/settings.json
{
"enableSleeptime": true
}

See sleeptime agents documentation for more details on how sleeptime works.

Use the /memory command to view all memory blocks attached to your agent:

Terminal window
> /memory

The memory viewer shows:

  • List view: All blocks with label, character count, description preview, and content preview (3 lines)
  • Detail view: Press Enter on a block to see its full content with scrolling

Navigation:

  • j/k or arrow keys to navigate between blocks
  • Enter to view full block content
  • ESC to go back or close

You can also click the “View/edit in the ADE” link to open the block in the Letta ADE for direct editing.

Memory is stored as blocks on the Letta server. Each block has a label, description, content, and size limit. Agents can read and write to their own blocks. To learn more about memory blocks, check the main documentation page.

Local files track pinned agents and settings:

FilePurposeGit
~/.letta/settings.jsonGlobally pinned agents, API keysN/A
.letta/settings.local.jsonLast used agent, locally pinned agentsIgnored
.letta/settings.jsonShared project settingsCommit
  1. Run /init on new projects - Helps the agent understand your codebase
  2. Use /remember for important context - Explicitly save information you want persisted
  3. Commit .letta/settings.json - Share project context with your team
  4. Keep .letta/settings.local.json gitignored - Personal settings stay personal