Overview
Subagent is Zeus’s task delegation mechanism, allowing the main Agent to dispatch subtasks to specialized sub-agents for execution. Through SubagentMiddleware, the main Agent can process multiple independent subtasks in parallel without interrupting its own reasoning. Core values of Subagent:- Task Decomposition: Break complex tasks into independent subtasks for separate execution
- Focused Isolation: Each sub-agent has its own independent context, preventing interference
- Parallel Execution: Multiple subtasks can be processed concurrently for improved efficiency
- Result Aggregation: After sub-agents complete, results are returned to the main Agent for continued reasoning
Architecture
Relationship with Main Agent
| Dimension | Main Agent | Subagent |
|---|---|---|
| Context | Full System Prompt + conversation history | Minimal context + task description |
| Tools | All available tools | Inherits main Agent’s tool set |
| Lifecycle | Session-level | Single task |
| Checkpoint | Yes (via LangGraph) | No independent Checkpoint |
| Memory | Read/write access | Inherits main Agent’s configuration |
Tool Interface
The Agent invokes Subagent through thetask tool:
| Tool Name | Function | Parameters |
|---|---|---|
task | Delegate a subtask to a sub-agent | agent: sub-agent name, task: task description |
Usage Example
When the main Agent receives a complex request (e.g., “Analyze this data and generate a visualization report”), it can:- Create a subtask: “Analyze sales.csv data and compute key metrics”
- Create another subtask: “Generate charts based on the analysis results”
- Collect results from both sub-agents and synthesize the final report
SubagentMiddleware
Subagent capability is provided by the DeepAgents framework’sSubagentMiddleware. This middleware is automatically registered during Agent creation, injecting the sub-agent list into the main Agent’s tool set.
Configuration
InBaseService._create_agent(), the sub-agent list is passed via the subagents parameter:
Execution Flow
Frontend Integration
When processing the SSE stream, the frontend distinguishes between main Agent and Subagent messages:- Subagent’s
write_todoscalls are skipped and not displayed in the main Agent’s task list - Subagent’s tool calls and results are shown in a nested format in the Trajectory panel
- The
isInsideSubagent()state flag is used to identify the message source
Design Principles
| Principle | Description |
|---|---|
| Minimal Context | Sub-agents receive only the necessary task description, not the full conversation history |
| Independent Execution | Sub-agent execution does not block the main Agent’s other operations |
| Result Pass-through | Sub-agent execution results are returned to the main Agent as Tool Results |
| Error Isolation | Sub-agent failure does not cause the main Agent to crash |
Use Cases
| Scenario | Description |
|---|---|
| Data Analysis | Split data cleaning, statistical analysis, and visualization into independent subtasks |
| Code Generation | Generate frontend components, backend APIs, and database migrations separately |
| Document Writing | Delegate different sections to different sub-agents for parallel writing |
| Information Research | Search multiple sources simultaneously and aggregate results |