What Is a Subagent?
A subagent is an autonomousdual_ai agent spawned by a parent thread. It runs in its own DurableThread with isolated:
- message history
- execution logs
- SQLite state
- filesystem and attachments
Why Use Subagents?
- Keep orchestration in a parent agent and delegate focused work to children
- Run specialized worker + reviewer loops (
side_a+side_b) - Scale work across multiple child instances without mixing state
- Preserve strong isolation while still supporting parent/child communication
Invocation Modes
Subagent behavior is defined per prompt-tool relationship:| Mode | Behavior |
|---|---|
| non-resumable + blocking | parent waits, child completes, child terminates |
| non-resumable + non-blocking | parent returns immediately, child reports later |
| resumable + blocking | parent waits per call, child persists |
| resumable + non-blocking | parent returns immediately, child can be messaged anytime |
Prompt Configuration
UseSubagentToolConfig in definePrompt({ tools: [...] }):
Key Properties
initUserMessageProperty: maps tool args to child initial message textinitAttachmentsProperty: maps tool args to child initial attachmentsinitAgentNameProperty: maps tool args to child display name (name:<value>tag)resumable.maxInstances: max concurrent instances for this subagent type
Resumable Lifecycle Tools
For resumable subagents, AgentBuilder injects built-in tools:subagent_create: create or start a resumable child instancesubagent_message: send a message to an existing resumable child
Child Lifecycle Bindings
Child-side lifecycle is configured indefineAgent via SideConfig:
sessionStopsessionFailsessionStatus
Parent/Child Communication
Parent -> Child
- initial invocation payload mapping
- resumable messaging with
subagent_message - attachment references are copied parent filesystem -> child filesystem
Child -> Parent
sessionStopqueues a silent result message on parentsessionFailqueues a silent failure message on parentsessionStatusupdates child status in parent registry- returned attachments are copied child filesystem -> parent filesystem
Runtime State and APIs
ThreadState exposes subagent-aware APIs:
getChildThread(referenceId)getParentThread()childrenregistry entriesqueueMessage()(durable queued delivery)terminate()andterminated