Sub-Agents
Build specialized agents that work together
Build specialized agents that work together to handle complex tasks.
What are Sub-Agents?
Sub-agents are specialized AI agents that your main agent can delegate tasks to. This architecture allows you to:
- Specialize: Create experts in specific domains
- Scale: Handle more complex workflows
- Maintain: Update individual agents without affecting others
- Optimize: Use different models for different tasks
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Multi-Agent System │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ │
│ │ Main Agent │ │
│ │ (Orchestrator) │ │
│ └────────┬─────────┘ │
│ │ │
│ ┌─────────────────┼─────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Technical │ │ Billing │ │ Sales │ │
│ │ Support │ │ Support │ │ Assistant │ │
│ │ Agent │ │ Agent │ │ Agent │ │
│ └───────────────┘ └───────────────┘ └───────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Use Cases
1. Customer Support Routing
Customer: "I'm having trouble with my API integration"
│
▼
Main Agent: Identifies as technical issue
│
▼
Technical Support Agent: Handles API troubleshooting
2. Multi-Step Workflows
Customer: "I want to upgrade my plan and add a user"
│
▼
Main Agent: Identifies two tasks
│
├──► Billing Agent: Process upgrade
│
└──► User Management Agent: Add team member
3. Language Specialization
Customer: "Bonjour, j'ai besoin d'aide"
│
▼
Main Agent: Detects French
│
▼
French Support Agent: Handles in French
Creating Sub-Agents
Step 1: Create Specialized Agent
Create a new agent for each specialization:
- Go to Agents > Create Agent
- Configure for specific domain:
markdown# Technical Support Agent You are a technical support specialist for CloudAPI. You handle: - API integration issues - SDK troubleshooting - Authentication problems - Rate limiting questions You have access to: - Technical documentation - API reference - Known issues database - Error code lookup tool Always provide code examples when relevant.
Step 2: Configure as Sub-Agent
Mark the agent as a sub-agent:
- Go to agent settings
- Enable "Available as Sub-Agent"
- Set visibility (which agents can call it)
Step 3: Connect to Main Agent
Add sub-agents to your orchestrator:
- Open your main agent
- Go to Sub-Agents tab
- Click Add Sub-Agent
- Select your specialized agents
- Configure routing rules
Routing Strategies
Intent-Based Routing
Route based on detected intent:
json{ "routing_rules": [ { "intent": "technical_issue", "sub_agent": "technical-support", "keywords": ["api", "error", "bug", "integration", "code"] }, { "intent": "billing_inquiry", "sub_agent": "billing-support", "keywords": ["invoice", "payment", "charge", "refund", "plan"] }, { "intent": "sales_question", "sub_agent": "sales-assistant", "keywords": ["pricing", "demo", "enterprise", "features"] } ] }
Explicit Routing
Let the main agent decide:
markdown# Main Agent Instructions When you identify a specialized need, delegate to the appropriate agent: - Technical issues → @technical-support - Billing questions → @billing-support - Sales inquiries → @sales-assistant Always inform the user when transferring: "Let me connect you with our technical specialist..."
Fallback Routing
Handle unmatched queries:
json{ "fallback": { "action": "handle_self", "message": "I'll help you directly with this." } }
Context Passing
Conversation Context
Pass relevant history to sub-agents:
json{ "context_passing": { "include_history": true, "max_messages": 5, "include_metadata": true } }
Custom Context
Add specific information:
json{ "context": { "customer_tier": "enterprise", "account_age_days": 365, "previous_issues": ["billing-2024-001", "tech-2024-015"] } }
Response Handling
Direct Response
Sub-agent responds directly to user:
User → Main Agent → Sub-Agent → User
(responds directly)
Filtered Response
Main agent reviews before sending:
User → Main Agent → Sub-Agent → Main Agent → User
(filters/enhances response)
Configuration
json{ "response_handling": { "mode": "filtered", "filter_rules": { "remove_internal_links": true, "add_branding": true, "check_tone": true } } }
Orchestration Patterns
Sequential Processing
Handle tasks one at a time:
Task 1 → Agent A → Complete
│
▼
Task 2 → Agent B → Complete
│
▼
Return combined result
Parallel Processing
Handle tasks simultaneously:
┌→ Agent A → Result A ─┐
│ │
Tasks ───┼→ Agent B → Result B ─┼→ Combined Result
│ │
└→ Agent C → Result C ─┘
Configuration
json{ "orchestration": { "mode": "parallel", "timeout_ms": 30000, "fail_strategy": "continue_others" } }
Best Practices
1. Clear Boundaries
Each sub-agent should have a well-defined scope:
| Agent | Handles | Does NOT Handle |
|---|---|---|
| Technical | API, SDK, errors | Billing, account |
| Billing | Payments, plans | Technical issues |
| Sales | Demos, pricing | Support issues |
2. Consistent Handoffs
Make transitions smooth:
markdownMain Agent: "I'll connect you with our billing team who can help with that invoice question." Billing Agent: "Hi! I'm here to help with your billing inquiry. I can see you have a question about your recent invoice..."
3. Fallback Handling
Always have a fallback:
json{ "fallback_behavior": { "no_match": "handle_self", "sub_agent_error": "escalate_to_human", "timeout": "retry_once" } }
4. Monitor Performance
Track sub-agent effectiveness:
| Metric | Description |
|---|---|
| Routing Accuracy | % correct routing decisions |
| Resolution Rate | % issues resolved by sub-agent |
| Handoff Time | Time to transfer to sub-agent |
| Customer Satisfaction | Rating after sub-agent interaction |
Next Steps
- Deployment - Deploy your multi-agent system
- Workflows - Connect agents to workflows