Skip to main content

Overview

Sub-Agent is Zeus’s task delegation mechanism. The main Agent dispatches subtasks to independent sub-agents by calling the task 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’s SubAgentMiddleware. It is registered automatically during Agent creation and injects the task tool into the main Agent’s tool set.

Backend Configuration

Configured in BaseService._create_agent():

Execution Flow


Frontend Integration

SSE Event Flow

Sub-agent execution is streamed to the frontend via standard SSE events. The frontend uses tool_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 a subAgentTaskId 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: groupMessagesIntoTasks filters out subAgentTaskId messages before processing, preventing interference with main task status
  • Todos: Sub-agent write_todos calls are completely skipped, leaving the main Agent’s task list unaffected

TaskToolCallCard

Each task 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
Parallel sub-agents each display their own independent 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
Each tab maintains an independent step slider, allowing users to browse different agents’ execution history without interference. Switching tabs updates the trajectory content and code preview accordingly.

Parallel Execution

The main Agent can call multiple task tools in a single turn, triggering parallel sub-agents:
The frontend uses a stack model (subAgentStack) to track the currently active sub-agent context, routing subsequent tool call events to the correct sub-agent trajectory.

Design Principles


Use Cases