Sub Agent Relationships
Copy page
Learn how to add Sub Agent relationships to your agent
Sub Agent relationships are used to coordinate specialized Sub Agents for complex workflows. This framework implements Sub Agent relationships through using canDelegateTo() and canTransferTo(), allowing a parent Sub Agent to automatically coordinate specialized Sub Agents for complex workflows.
Understanding Sub Agent Relationships
The framework supports two types of Sub Agent relationships:
Transfer Relationships
Transfer relationships completely relinquish control from one Sub Agent to another. When a Sub Agent hands off to another:
- The source Sub Agent stops processing
- The target Sub Agent takes full control of the conversation
- Control is permanently transferred until the target Sub Agent hands back
Delegation Relationships
Delegation relationships are used to pass a task from one Sub Agent to another while maintaining oversight:
- The source Sub Agent remains in control
- The target Sub Agent executes a specific task
- Results are returned to the source Sub Agent
- The source Sub Agent continues processing
When to Use Each Relationship
Use Transfers for Complex Tasks
Use canTransferTo when the task is complex and the user will likely want to ask follow-up questions to the specialized Sub Agent:
- Customer support conversations - User may have multiple related questions
- Technical troubleshooting - Requires back-and-forth interaction
- Order management - User might want to modify, track, or ask about multiple aspects
- Product consultations - Users often have follow-up questions
Use Delegation for Simple Tasks
Use canDelegateTo when the task is simple and self-contained:
- Data retrieval - Get a specific piece of information and return it
- Calculations - Perform a computation and return the result
- Single API calls - Make one external request and return the data
- Simple transformations - Convert data from one format to another
Types of Delegation Relationships
Sub Agent Delegation
Sub agent delegation is used to delegate a task to a sub agent as seen above.
External Agent Delegation
External agent delegation is used to delegate a task to an external agent.
You can also specify headers to include with every request to the external agent.
Team Agent Delegation
Team agent delegation is used to delegate a task to another agent in the same project.
You can also specify headers to include with every request to the team agent.