Source:
examples/sub-agentsOverview
This template shows how to deploy multiple specialist agents from a single service using theapp/agents/ directory. Each file in app/agents/ becomes an independent A2A endpoint alongside the main app/agent.ts coordinator.
The example has three agents and two tools:
- Coordinator (
app/agent.ts) — routes users to the right specialist - Math specialist (
app/agents/math.ts) — performs arithmetic using thecalculatetool - Text specialist (
app/agents/text.ts) — analyzes text using theword-counttool
Project Structure
Endpoints
A single deployment exposes three independent A2A endpoints:Sub-Agent Definition
Each file inapp/agents/ follows the same pattern as app/agent.ts:
app/agents/math.ts
math.ts) determines the URL prefix (/math/agent).
Key Features
- Auto-discovery — All
.tsfiles inapp/agents/are automatically registered - Independent endpoints — Each sub-agent gets its own A2A endpoint and agent card
- Shared tools via MCP — Tools in
app/tools/are exposed on a single/mcpendpoint - Mixed deployment —
app/agent.tsandapp/agents/can coexist in the same project
Running
http://localhost:3000: