Skip to content
Letta Code Letta Code Letta Docs
Sign up
Features

Subagents

Specialized agents for task decomposition and parallel execution

Subagents are specialized agents that your main agent can spawn to handle complex tasks autonomously. By delegating work to focused subagents, your main agent can keep its context window clean and make use of parallelism to divide and conquer tasks.

Letta Code includes seven built-in subagent types optimized for common workflows, and you can create custom subagents for specialized tasks.

Your main agent can launch subagents using a specialized subagent (“Task”) tool. When the subagent tool is called, a new (sub)agent is created via a subprocess of Letta Code.

The subagent runs autonomously with its own system prompt, tools, and model. The final message from the subagent is returned to the main agent, which keeps the main agent’s context clean.

For example, if the main agent wants to understand where a certain function is located in the codebase, it can launch an explore subagent. The explore subagent may use hundreds of thousands of tokens to read hundreds of files, but the main agent will only see the final answer - saving the main agent from unnecessary context “pollution” from tool calls and returns.

By default, when your main agent launches a subagent, the subagent tool does not return until the subagent is finished working. However, your main agent can also choose to launch subagents in the background.

If a subagent is launched in the background, the subagent tool returns immediately (letting the main agent know the subagent was successfully launched), and the main agent gets automatically notified / triggered once the subagent has completed execution.

By default, the built-in subagents are not reused - they are created fresh on each invocation.

It is also possible to deploy an arbitrary Letta Code agent as a subagent by specifying its agent_id. This lets your main agent “teleport” other agents that carry their own rich memories, personalities, and skillsets into your Letta Code instance and read/write/edit code.

To deploy an existing agent as a subagent, your main agent simply needs to know its agent ID (both agents must exist in the same Letta API org/project):

> I have another agent that's an expert at web design. Can you ask them to review your changes? Their agent ID is ...

If you don’t remember their agent ID, your main agent can also use the built-in “finding agents” skill to find them:

> Can you ask my other agent "Dora Designer" to review this PR as a subagent? I forgot their agent ID though.

Each subagent has a default model, but you can override it with prompting (e.g., Spawn an explore agent with Opus).

SubagentPurposeDefault ModelAccess
exploreFast codebase search—find files, search patterns, explore structureHaikuRead-only
general-purposeFull implementation—research, plan, and make changesSonnetRead/write
history-analyzerMigrate conversation history from Claude Code or Codex into memorySonnetRead/write
memoryClean up and reorganize memory blocks—remove redundancy, add structureOpusRead/write
planBreak down complex tasks into detailed implementation roadmapsOpusRead-only
recallSearch conversation history for past discussions and decisionsOpusRead-only
reflectionBackground “sleep-time” memory consolidation from recent conversationsSonnet 4.5Read/write

Create custom subagents by adding Markdown files with YAML frontmatter to the .letta/agents/ directory.

.letta/
└── agents/
└── my-subagent.md

You can also create global subagents at ~/.letta/agents/ that are available across all projects.

.letta/agents/security-reviewer.md
---
name: security-reviewer
description: Reviews code for security vulnerabilities and suggests fixes
tools: Glob, Grep, Read
model: sonnet-4.5
memoryBlocks: human, persona
---
You are a security code reviewer.
## Instructions
- Search for common vulnerability patterns (SQL injection, XSS, etc.)
- Check authentication and authorization code
- Review input validation
- Identify hardcoded secrets or credentials
## Output Format
1. List of findings with severity (critical/high/medium/low)
2. File paths and line numbers for each issue
3. Recommended fixes
FieldRequiredDescription
nameYesUnique identifier (lowercase, hyphens allowed). Must start with a letter.
descriptionYesWhen to use this subagent (shown in Task tool and /subagents)
toolsNoComma-separated list of allowed tools, or all. Defaults to all.
modelNoModel to use (e.g., haiku, sonnet-4.5, opus). Defaults to inheriting from main agent.
memoryBlocksNoWhich memory blocks the subagent can access: specific list, all, or none. Defaults to all.
skillsNoComma-separated list of skills to auto-load

The body of the Markdown file (after the frontmatter) becomes the subagent’s system prompt. Write clear instructions for what the subagent should do and how it should format its output.

Custom subagents override built-ins with the same name. Project-level subagents (.letta/agents/) override global ones (~/.letta/agents/).

Use subagent_type to control what tools the deployed agent can access:

Access LevelToolsUse Case
exploreRead, Glob, GrepSafer for exploration—agent can search but not modify
general-purposeBash, Edit, Write, Read, etc.Full access for implementation tasks

If subagent_type is omitted, it defaults to general-purpose.