Overview
Sub-Agent is Zeus’s task delegation mechanism. The main Agent dispatches subtasks to independent sub-agents by calling thetask tool. Each sub-agent has its own context and reasoning loop, and returns results to the main Agent as a standard Tool Result upon completion.
Core capabilities:
- Task Decomposition — Break complex tasks into independent subtasks
- Context Isolation — Each sub-agent has its own isolated context
- Parallel Execution — Multiple subtasks run concurrently for improved efficiency
- Result Aggregation — Sub-agent results return to the main Agent for continued reasoning
Architecture
Main Agent vs Sub-Agent
The task Tool
The main Agent triggers sub-agents through the task tool. This tool is automatically injected by the DeepAgents framework’s SubAgentMiddleware.
Parameters
Example
SubAgentMiddleware
Sub-Agent capability is provided by the DeepAgents framework’sSubAgentMiddleware. It is registered automatically during Agent creation and injects the task tool into the main Agent’s tool set.
Backend Configuration
Configured inBaseService._create_agent():
Execution Flow
Frontend Integration
SSE Event Flow
Sub-agent execution is streamed to the frontend via standard SSE events. The frontend usestool_name and tool_call_id to distinguish between main Agent and sub-agent messages.
Message Isolation
Messages produced by sub-agents (tool calls, text) are tagged with asubAgentTaskId field and excluded from the main chat flow:
- Chat area: Sub-agent tool calls are only shown inside their corresponding
TaskToolCallCard, not in the main message stream - Task grouping:
groupMessagesIntoTasksfilters outsubAgentTaskIdmessages before processing, preventing interference with main task status - Todos: Sub-agent
write_todoscalls are completely skipped, leaving the main Agent’s task list unaffected
TaskToolCallCard
Eachtask tool call renders as an expandable card in the chat area:
- Collapsed: Shows status icon, task description, progress (e.g. 5/11), and current activity
- Expanded: Lists all internal tool calls with their status and parameter previews
- Running state: Blue border highlight with spinning loader
- Supports clicking “View in trajectory →” to jump to the corresponding trajectory tab
TaskToolCallCard with individual progress tracking.
Trajectory Tabs
When sub-agents are active, the trajectory area displays a tab bar at the top:- Main — Main Agent’s tool execution history
- Sub-Agent — Each sub-agent has its own tab showing its tool execution history
Parallel Execution
The main Agent can call multipletask tools in a single turn, triggering parallel sub-agents:
subAgentStack) to track the currently active sub-agent context, routing subsequent tool call events to the correct sub-agent trajectory.