Skip to content

[FEATURE] Agent Handoffs/Delegation #911

@mkmeral

Description

@mkmeral

Problem Statement

Customers have asked for a simple way for agents to delegate requests to specialized sub-agents with complete handoff. They want to simplify the developer experience for common delegation patterns:

  • Graph/Swarm: Customers want simpler setup for hierarchical delegation use cases that don't require complex orchestration
  • Agents as Tools: For use cases where the sub-agent's response doesn't need additional LLM processing, customers want to avoid the extra step of main agent → sub-agent → main agent processing → final response

We need true delegation where the orchestrator analyzes the request, delegates to a sub-agent, and the sub-agent's response becomes the final response with no additional processing.

Proposed Solution

Introduce a sub_agents parameter (alternatively delegates, handoff_agents or something similar) to the Agent class that automatically creates delegation tools for each sub-agent. This would enable a clean, hierarchical agent architecture:

# Define specialized agents
customer_service = Agent(
    name="CustomerService",
    description="Handles customer service inquiries, billing questions, and account issues",
    system_prompt="You are a customer service specialist...",
    tools=[billing_lookup, account_management]
)
technical_support = Agent(
    name="TechnicalSupport", 
    description="Provides technical support for product issues and troubleshooting",
    system_prompt="You are a technical support specialist...",
    tools=[diagnostic_tools, product_database]
)
# Create orchestrator agent with sub-agents
orchestrator = Agent(
    name="HelpDeskOrchestrator",
    description="Routes customer requests to appropriate specialists",
    system_prompt="""
    You are a help desk coordinator. Route customer requests to the appropriate specialist:
    - Use CustomerService for billing, account, or general service questions
    - Use TechnicalSupport for product issues, bugs, or technical problems
    - Handle simple greetings and general questions yourself
    """,
    sub_agents=[customer_service, technical_support]
)

Implementation Details

Each sub-agent automatically generates a handoff_to_{agent_name} tool that:

  • Transfers complete control to the sub-agent
  • Terminates orchestrator execution after delegation
  • Makes the sub-agent's response the final response
  • No post-processing by the orchestrator
    Response Flow: User Request → Orchestrator Analysis → Delegation → Sub-agent Final Response

Use Case

Customer Support: Route billing questions to CustomerService agent, technical issues to TechnicalSupport agent
Multi-Domain Assistant: Route research to Researcher, writing to Writer, coding to Coder
Hierarchical Workflows: Manager delegates to Senior agents, who delegate to Junior agents

Alternatives Solutions

Enhanced Agents as Tools: Improve @tool decorator - still requires manual setup, doesn't provide true delegation
RouterAgent Class: New specialized class - introduces complexity, less flexible
Delegation Mixin: Mixin approach - complex inheritance, less intuitive

Additional Context

Key Difference: Unlike "Agents as Tools" where the main agent processes sub-agent results, delegation provides complete handoff with no additional processing.
Integration: Works with existing Graph/Swarm patterns - sub-agents can be nodes or swarm participants.
Error Handling: Handle sub-agent failures, prevent circular delegation, timeout management.
This would simplify hierarchical agent systems while maintaining flexibility of existing multi-agent approaches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-multiagentMulti-agent relatedenhancementNew feature or requestrefinedIssue is discussed with the team and the team has come to an effort estimate consensus

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions