Subagents
The Agent tool delegates large or context-heavy subtasks to subagents that run in isolated sessions: each child sees only the prompt you pass it (never the parent conversation) and returns only its final text. Isolation keeps the parent's context clean — you get the answer without paying for the exploration that produced it.
Declaring a subagent
A subagent is an agents/*.md file with YAML frontmatter; the body becomes the subagent's system prompt:
Loading order (later directories override earlier ones by name):
- Global:
~/.lite-agent/agents - Project:
<workdir>/.lite-agent/agents agentsDirconfig option, if set
A built-in general-purpose agent (inherits the parent's full tool set and model) is always seeded, so subagents work with zero files. Set agents: false to disable the whole capability.
Model selection
With a models catalog, choose simple, medium, or complex in a
definition or in an individual task. Selection is deterministic:
For example, this simple definition is overridden by one complex task:
With a catalog, both tool calls and agent definitions must select a configured tier; unknown model names fail closed. Without a catalog, legacy raw model overrides retain the inherited provider. The tool schema and description expose available profiles to the parent.
Profiles accept reasoningEffort: "low" | "medium" | "high". OpenAI-compatible providers send reasoning_effort; Anthropic enables adaptive thinking with output_config.effort. Use supported models; unsupported settings produce provider errors, never an automatic model upgrade. Reasoning cannot be combined with temperature/topP; Anthropic adaptive thinking also rejects forced tool choice. Permissions and concurrency remain independent.
The prompt recommends delegation for explicit requests and independent complex work. Automatic tool selection still depends on the model; configuring profiles alone does not force delegation.
Dispatch
Every Agent call creates one sibling group. Each task must include a
non-empty, visible display_name: it is the UI and result label for this
invocation. subagent_type only selects an AgentLoader definition, while
the returned agentId is the stable run identity to pass as resume later.
Groups are always detached from a long-lived createLiteAgent() session. The
tool immediately returns an accepted-group placeholder; after all children
settle, the session receives exactly one ordered aggregate completion. The
legacy run_in_background field is still accepted for parsing, but no longer
changes this behavior; run_in_background: false does not make a group
synchronous. Set background: false only when you want Agent dispatch to fail
explicitly instead of creating background work.
The root agent owns one shared FIFO pool. maxParallelSubagents defaults to 5
and is shared by groups from every session on that root, so two groups with
three tasks each never get separate five-child limits. Results retain task
input order. A group is completed only when all children complete; mixed
outcomes are partial; wholly failed or cancelled groups are respectively
failed or cancelled. A child that throws, is cancelled, reaches
max_turns, or stops without final text is never represented as success.
For example, two calls can submit two groups of three tasks:
One mixed aggregate is delivered after its group settles:
Use createLiteAgent() with subscribe() and close() for interactive,
long-lived work: user and autonomous completion turns are serialized per
session, while subscription receives child and aggregate events. query() is
one-shot: before it closes its temporary agent it waits for Agent groups it
started and their autonomous completion turns, but it does not wait for an
unrelated detached daemon such as background Bash.
Children run with agents: false; recursive subagents, Agent Teams, message
buses and shared inboxes are not supported.
Children inherit the parent's policy and tool allow-list. subagentPermission and definition tools can only restrict them further. Parent and child approvals share one serial queue; missing approval handlers deny ask calls.
When tasks are enabled, delegation creates a tracked task automatically. Pass task_id to link an existing task. A successful child enters review; failures and cancellations remain explicit. Verify the result before marking the task completed.
Programmatic access
Use AgentLoader / builtinAgents directly if you need the same loading mechanism outside createLiteAgent.
See also
- Built-in tools — the
Agenttool and how to disable it (agents: false). - Skills — the other markdown-driven, on-demand capability.
- Permissions — write the allow/deny rules
subagentPermissionexpects. - Custom tools — add tools your subagents can inherit.