Subagent System
Overview
A subagent is the task decomposition and delegation mechanism of the workspace. The main Agent can break down a complex parallel task into subtasks, create dedicated subagents to execute them independently, and after the subagents finish, the results are returned to the main Agent for further processing.
The system supports three types of subagents, with a maximum nesting depth of 3 levels.
Three Types of Subagents
| Type | Tool Name | Creation Method | Applicable Scenario | Execution Location |
|---|---|---|---|---|
| Automatic Creation | create_local_sub_agent |
Autonomously created by the Agent during reasoning | Temporary subtask decomposition | Local node |
| Pre-registered Dispatch | dispatch_sub_agent |
Pre-configured by the user | Fixed specialized roles reused repeatedly | Local node |
| Cross-node Dispatch | dispatch_multi_node_agent |
Remote node selected by the Agent | Requires remote resources or capabilities | Remote node |
Automatically Created Subagents (create_local_sub_agent)
When the Agent determines during reasoning that the current task needs to be decomposed, it will autonomously call the create_local_sub_agent tool to create a temporary subagent. Users can also request the Agent to create a subagent through conversation prompts, for example:
"Please create a subagent to search for relevant materials, then create another subagent to write the document"
Creation Parameters:
| Parameter | Description | Required |
|---|---|---|
task |
Task description of the subagent | Yes |
systemPrompt |
Identity/role definition of the subagent | Yes |
cwd |
Working directory (inherits from parent by default) | No |
maxSpawnDepth |
Nesting depth (1-3), defaults to 1 | No |
Execution Flow:
- The main Agent decides to create a subagent and assigns the task
- The system starts an independent Agent Loop (default maximum of 50 rounds)
- The subagent has its own tool loop, and its execution process is visible in the parent conversation window
- After the subagent finishes, it returns the final result to the main Agent
- The main Agent continues subsequent work based on the result
Pre-registered Dispatch Subagents (dispatch_sub_agent)
Users can pre-register subagents with specific configurations in the APP settings, and the Agent invokes them via the dispatch_sub_agent tool when needed.
The descriptions of pre-registered subagents are automatically injected into the main Agent's system prompt, so when the LLM sees a matching task, it automatically selects the appropriate subagent.
Configuration Items:
| Configuration | Description |
|---|---|
name |
Subagent name |
description |
Capability description (injected into the parent Agent's system prompt) |
systemPrompt |
Identity/role definition |
tools |
Tool allowlist (inherits all if omitted) |
disallowedTools |
Tool blocklist |
skills |
List of available skill IDs |
mcpServers |
List of available MCP server names |
model |
Overrides the parent model |
maxTurns |
Overrides the default maximum number of rounds |
canSpawn |
Whether it can create lower-level subagents |
maxSpawnDepth |
Maximum nesting depth |
For the management interface, see Subagent Registration and Management.
Cross-node Dispatch (dispatch_multi_node_agent)
When a task requires resources or capabilities of a remote device, the Agent can dispatch the task to another node for execution via the dispatch_multi_node_agent tool.
Workflow:
- The main Agent views the list of online nodes (injected into the system prompt)
- Selects the target node based on the node capability declarations
- Sends
node.invoke.requestvia the Gateway WebSocket - The remote node starts an independent Agent Loop to execute the task
- Returns the result via
node.invoke.resultupon completion
Scenario Example:
- The Web client on Computer A initiates a conversation
- The task requires accessing local files on Computer B
- The Agent dispatches the file operation subtask to Computer B's APP node via the Gateway
- After Node B executes it and returns the result, the conversation continues to be displayed on Computer A
Nesting Depth Control
Subagents support nested creation, with a maximum depth of 3 levels:
深度 0: 主 Agent(用户对话)
└── 深度 1: 子代理 A
└── 深度 2: 子子代理 A-1
└── 深度 3: 最深层代理(不可再委派)
| Parameter | Value | Description |
|---|---|---|
DEFAULT_MAX_SPAWN_DEPTH |
1 | Default: subagents cannot create lower levels |
MAX_ALLOWED_SPAWN_DEPTH |
3 | Hard upper limit |
SUBAGENT_DEFAULT_MAX_TURNS |
50 | Default maximum rounds for subagents (higher than the main Agent's 25) |
The greater the depth, the stronger the autonomy, but Token consumption and execution time increase accordingly.
Tool Inheritance Mechanism
| Mode | Description |
|---|---|
| Default Inheritance | The subagent inherits all available tools of the parent Agent |
| Allowlist | The tools parameter specifies the list of tools allowed to be used |
| Blocklist | The disallowedTools parameter excludes specific tools |
| Skill Inheritance | Can inherit or override the parent's skills and MCP servers |
| Model Override | The subagent can use an LLM model different from the parent's |
UI Display
Subagents are displayed with special markers in the Work conversation window:

| Display Element | Description |
|---|---|
| SubagentToolRow | A tool call row dedicated to subagents, with a special color marker (emerald) |
| Activity Pass-through | The subagent's tool call process is displayed in real time in the parent conversation window |
| Result Display | After the subagent finishes, the final result is displayed as tool output |
Users can clearly see which operations are performed by the main Agent and which are performed by subagents.
How to Create a Subagent Through Conversation
You can request the Agent to create a subagent using natural language in the conversation. Here are some example prompts:
| Prompt | Effect |
|---|---|
| "Create a subagent to search for and organize relevant materials" | The Agent creates a subagent focused on searching |
| "Split this task into two subagents: one responsible for code, one for documentation" | The Agent creates two subagents each with its own specialty |
| "Help me create a subagent with a depth of 2 to handle this complex task" | The Agent creates a subagent that can further delegate |
| "Use a remote node to execute this file processing task" | The Agent uses dispatch_multi_node_agent |
Interpreting the Interface During Subagent Execution

| UI Element | Meaning |
|---|---|
| Emerald-marked tool row | This is a tool call being executed by the subagent |
| "create_local_sub_agent" tool call | The main Agent is creating a subagent |
| Tool call within the subagent | A tool the subagent autonomously decides to call, displayed in real time |
| Final result | The summary output after the subagent finishes |
Cost Impact
The token consumption of subagents is calculated independently:
| Scenario | Estimated Token Consumption |
|---|---|
| Main Agent only (no subagents) | 1x |
| Main Agent + 1 subagent | 1.5x ~ 2.5x |
| Main Agent + 2 subagents | 2x ~ 4x |
| 3-level nesting (main + child + grandchild + great-grandchild) | 3x ~ 6x |
Recommendation: Subagents are suitable for complex tasks that genuinely need to be decomposed. For simple tasks, just let the main Agent handle them directly—there is no need to create subagents.
When to Use / Not Use Subagents
| Suitable for Subagents | No Subagents Needed |
|---|---|
| The task naturally splits into independent parts (e.g., searching materials + writing documentation) | A single linear task (e.g., reading one file and summarizing it) |
| Different professional perspectives are needed (e.g., code review + security audit) | Simple Q&A |
| Resources of a remote node are needed (e.g., files on a remote server) | Local file operations |
| Large workloads that can be accelerated in parallel | Simple and quick tasks |
It is not recommended to assign different roles to Subagents for a division of labor and collaboration; in the AI era, collaboration actually reduces efficiency and quality. It is more suitable for scenarios of parallel task execution to save time and improve efficiency.
Related Documentation
- Subagent Registration and Management — Pre-registered subagent configuration
- Multi-node Architecture — The underlying mechanism of cross-node dispatch
- Agent Loop Engine — The Agent Loop used by subagents
