SendMessage Tools
Control returns to the caller, ideal for coordination with oversight. Implemented via
SendMessage tool variants.Handoffs
Control transfers to the target, ideal for full task transfer and specialization. Powered by
SendMessageHandoff + OpenAI SDK.Understanding the Two Paradigms
SendMessage Tools (Orchestrator Pattern)
- Control Flow: Control returns to the calling agent
- Use Case: Delegation with oversight and coordination
- Implementation: Via
SendMessagetool variants - Example:
Orchestrator → Worker → responds to Orchestrator - Conversation History: Each A→B communication flow maintains its own conversation thread. Agent B only sees the history from that specific A→B thread.
Handoffs (Sequential Pattern)
- Control Flow: Control transfers to the handoff target
- Use Case: Complete task transfer and specialization
- Implementation: Via
SendMessageHandofftool class + OpenAI SDK - Example:
Worker → Specialist(control stays with Specialist) - Conversation History: The receiving agent gets the full conversation history and continues the interaction
The Hybrid Resolution
When both patterns are used together, you can use Agency Swarm to implement a hybrid approach that allows both to coexist without conflicts.How It Works
The hybrid approach works by layering the two communication patterns:1
Primary Communication Uses Orchestrator Pattern
When Agent A sends a message to Agent B using
SendMessage, Agent A will always receive a response (either from Agent B directly, or from a specialist that Agent B handed off to).2
Internal Processing Can Use Handoffs
While Agent B is working on Agent A’s request, Agent B can hand off to specialists. The specialist receives Agent B’s context and responds directly to Agent A.
3
Best of Both Worlds
- Agent A gets the coordination benefits of the orchestrator pattern (responses come back)
- Agent B can hand off to specialists for specialized tasks
- Agent A receives the specialist’s response without managing multiple conversations
Setting Up Handoffs
In this framework, handoffs are configured via theSendMessageHandoff tool.
agency_setup.py
See the full working example: hybrid_communication_flows.py
Execution Flow
1
ProjectManager delegates to Developer
ProjectManager uses
send_message_to_Developer: “Implement user authentication with security best practices”.2
Developer hands off to SecurityExpert
Developer recognizes the need for security expertise and performs a handoff to SecurityExpert. Control transfers completely.
3
SecurityExpert responds with full context
SecurityExpert receives the full conversation history and provides comprehensive security recommendations directly to ProjectManager.
4
ProjectManager receives specialist response
ProjectManager receives the SecurityExpert’s response with complete security guidance, without needing to coordinate multiple conversations.
When to Use Hybrid Patterns
Ideal Use Cases
- Hierarchical task delegation with oversight: Manager delegates to workers who can hand off to specialists
- Expert consultation workflows: Agents can sequentially hand off to specialists while orchestrator maintains control
- Complex approval processes: Multiple specialists review work with responses going to orchestrator
- Quality assurance pipelines: Work flows through specialists but orchestrator tracks progress
Design Guidelines
When to use:SendMessage (Orchestrator)
• Control and visibility
• Coordination between multiple agents
• Task-focused agent boundaries
• Coordination between multiple agents
• Task-focused agent boundaries
Sequential Handoffs
• Internal agent decision-making
• Allow agents to have the entire context
• Fewer agent-to-agent passes
• Allow agents to have the entire context
• Fewer agent-to-agent passes
SendMessageHandoff tools only. The agent.handoffs parameter is not supported to avoid confusion.
Benefits of the Hybrid Approach
- Internal Transfer: Agents can independently use handoffs to access necessary context and tools without additional agent-to-agent passes.
- Maintained Control: Some agents can receive a short summary of the response to avoid hallucinations while others can receive full context to increase response accuracy and coverage.
- Clean Separation of Concerns: High-level coordination remains simple while detailed specialist work happens independently within appropriate agents.
Conclusion
Agency Swarm’s hybrid paradigm resolution enables multi-agent architectures that would be difficult to achieve with either pattern alone. By understanding how SendMessage tools and Sequential Handoffs work together, you can build systems that combine the best of both orchestration and sequential transfer patterns, giving you the flexibility to design complex multi-agent workflows.For more details on individual patterns, see the Overview page. For implementation examples, check the Common Use Cases page.