A single agent can struggle when a task depends on more information than fits effectively in its language-model context. A subagent is a specialist agent coordinated by another agent to handle part of a larger task. Instead of giving one agent every detail, the system delegates bounded work to specialists that can be refined and tested independently. section 2.4
Two coordination designs place subagents in different roles:
- Supervisor team: a supervising agent splits a larger task into subtasks and calls specialist subagents as tools. A mortgage-advice workflow uses this design to combine analysts’ work into an aggregate analysis. section 2.4.2
- Router: a selector chooses a registered specialist for an incoming task, forwards the input, and maintains a unified communication interface. Selection can account for constraints rather than relying on a fixed hierarchy. section 9.0
Listing 2.6 analyst_team.py: Bundling analysts under a single supervisor
from typing import Any
from .client import Client
from .react import ReActAgent
from .analysts import (
RateFairnessAnalyst,
IncomeSufficiencyAnalyst,
PropertyValueAnalyst,
IncomeTrendAnalyst,
...
)
class AnalystTeam:
def __init__(self, client: Client):
self.client = client
self.team: dict[str, ReActAgent] = {
"rate_fairness": RateFairnessAnalyst(client),
"income_sufficiency": IncomeSufficiencyAnalyst(
client
),
"property_value": PropertyValueAnalyst(client),
"income_trend": IncomeTrendAnalyst(client),
...
}
self.supervisor = ReActAgent(
client,
ADVISORY_TEAM_SUPERVISOR_SYSTEM_PROMPT,
self.team,
ADVISORY_TEAM_SUPERVISOR_USER_PROMPT_TEMPLATE,
)
self.advisory_output: dict[str, Any] = {}
async def run(
self, mortgate_details: dict[str, Any]
) -> str:
response: str = await self.supervisor.run(
mortgate_details=mortgate_details
)
self.advisory_output = {
str(type(agent).__name__): agent.get_result()
for agent in self.team
}
return response
def get_result(self) -> dict[str, Any]:
return self.advisory_output
ADVISORY_TEAM_SUPERVISOR_SYSTEM_PROMPT = """
...
"""
ADVISORY_TEAM_SUPERVISOR_USER_PROMPT_TEMPLATE = """
...
"""
The analyst-team listing registers specialist ReAct agents by name and supplies that registry to a supervising ReAct agent. The registry makes the available delegation targets explicit. section 2.4.2
Mortgage analysis
A mortgage-advice supervisor can call separate agents for rate fairness, income sufficiency, property value, and income trends. Each analyst owns a focused task; the supervisor coordinates their contributions to the larger analysis. section 2.4.2
Choose the coordination mechanism to match the job: a supervisor can assemble multiple specialist contributions, while a router can classify and dispatch a request to an appropriate specialist. Both avoid making one general-purpose agent carry every specialist’s responsibilities. section 2.4 section 9.0






