Skip to content

Sub-agents

A sub-agent is a child agent loop with its own scratchpad, its own per-session FileStateCache scoping, and its own conversation. The parent agent drives it via the agent tool and receives only the final answer (plus optional partial updates), keeping the parent’s context lean.

When to use a sub-agent

  • Wide reads. “Walk these 40 files and summarize what you find” — do it in a child so the parent’s context window survives.
  • Fan-out. Spawn N children in parallel for research, triage, or per-file review, then merge results.
  • Specialized prompts. A child can run with a different system prompt, model, or permission mode tailored to its task.

Built-in agents

Agent typeDescription
exploreRead-only research. Bounded read-window, no shell, no edits.
general-purposeGeneral worker that inherits the parent’s permission policy.
code-reviewReviews recent changes on a branch / diff for correctness and style.
taskRuns a focused task with a tight scope and bounded turns.
planPure-thinking planner used by plan mode.

All are invoked via the agent tool:

{
"tool": "agent",
"input": {
"type": "explore",
"prompt": "Find every place we serialize a User and report the JSON shape."
}
}

Custom agents

Custom agent definitions are Markdown files with YAML frontmatter. The body of the file is the system prompt — the runtime always prepends its universal worker preamble, so this prompt holds only the agent-specific portion.

ScopePath
Project.lime/agents/<name>.md
User~/.lime/agents/<name>.md (or $LIME_HOME/agents/<name>.md)

Built-in agents take precedence; project agents override user agents with the same type.

Example

---
name: refactor-rust
description: Specialised Rust refactor worker — runs cargo clippy and proposes minimal-diff fixes.
type: refactor-rust
model: inherit
max_turns: 30
color: cyan
tools:
- read_file
- grep_search
- edit_file
- "Bash(cargo:*)"
disallowed_tools:
- delete_file
permission_mode: accept-edits
---
You are a focused Rust refactoring assistant. Run clippy first, propose
the minimum diff that resolves each warning, and never reformat code
that's outside the scope of the requested change.

Frontmatter fields

FieldTypeNotes
namestringDisplay name. Defaults to the file stem.
descriptionstringSurfaced in the agent tool schema so the routing model can decide when to spawn it.
typestringThe agent_type / subagent_type value used to invoke it. Defaults to the slugified name.
toolsstring[] or comma-stringAllow-list of tools (and tool patterns).
disallowed_toolsstring[] or comma-stringDeny-list, evaluated after the allow-list.
modelstringOverride the model for this agent. inherit (or omitted) means use the coordinator’s model.
max_turnsintegerCap on agent loop iterations before forced stop.
colorstringDisplay color for TUI badges (green, cyan, purple, orange, red, gray, …).
backgroundboolAlways run in the background (async) instead of inline.
permission_modestringPermission-mode override (default, read-only, accept-edits, bypass-permissions, plan).
memory_scopeobjectPersistent memory scope for this agent (advanced).
skillsstring[] or comma-stringNames of skills bound to this agent — they appear in the agent’s tool surface automatically.

Manage agents

Snapshot from the CLI:

Terminal window
lime agents # list configured agents

Inside the REPL:

/agents # list, show, create, edit, delete

/agents create <name> writes a starter .lime/agents/<name>.md with the frontmatter scaffolded.

Lifecycle tools

Once a sub-agent is running, the agent_* family controls it:

ToolPurpose
agentSpawn a sub-agent.
agent_continueSend a follow-up message to an existing sub-agent.
agent_statusQuery a sub-agent’s execution status.
agent_stopCancel a running sub-agent.
send_messageSend a message to a specific sub-agent or broadcast to all.

CSV fan-out

spawn_agents_on_csv spawns one sub-agent per CSV row with per-row template substitution:

{
"tool": "spawn_agents_on_csv",
"input": {
"csv_path": "./bugs.csv",
"prompt_template": "Triage bug #{id} ({title}). Look for similar issues and propose a fix."
}
}

Live view in the REPL

/tasks Show live sub-agents spawned in this session.

The /tasks panel shows each sub-agent’s status, the latest streamed chunk, and whether it’s blocked on a permission prompt.