Overview
Qwen-Agent provides powerful multi-agent orchestration capabilities, allowing you to build systems where multiple specialized agents work together to solve complex tasks. The framework supports various coordination patterns including routing, group chat, and custom orchestration.Multi-Agent Patterns
Qwen-Agent supports three main multi-agent patterns:- Router: Intelligent routing to specialized agents
- GroupChat: Collaborative conversation between agents
- MultiAgentHub: Custom multi-agent orchestration
Router Pattern
The Router pattern (qwen_agent/agents/router.py:36) automatically selects the best agent for each task.
Quick Start
How Router Works
The Router acts as a coordinator (examples/multi_agent_router.py:44):
Router Configuration
Complete Router Example
From the codebase (examples/multi_agent_router.py):
GroupChat Pattern
GroupChat (qwen_agent/agents/group_chat.py:29) enables multiple agents to have conversations.
Quick Start
Agent Selection Methods
GroupChat supports multiple selection strategies (qwen_agent/agents/group_chat.py:36):
Mentioning Agents
Agents can explicitly mention others using@ syntax:
Human-in-the-Loop
Include human participants in group chats:Complete GroupChat Example
From the codebase (examples/group_chat_demo.py:51):
MultiAgentHub
MultiAgentHub (qwen_agent/multi_agent_hub.py:22) is the base class for custom multi-agent orchestration.
Creating Custom Multi-Agent Systems
MultiAgentHub Properties
The MultiAgentHub provides useful properties:Advanced Patterns
Hierarchical Multi-Agent Systems
Parallel Processing
Specialized Agent Pipeline
Best Practices
Multi-Agent Design Tips
- Give each agent a clear, specific role and description
- Use descriptive agent names (helps LLM routing)
- Start with 2-3 agents, add more as needed
- Set max_round limits to prevent infinite loops
- Use Router for task-based delegation
- Use GroupChat for collaborative problem-solving
- Monitor conversation flow during development
Debugging Multi-Agent Systems
Verbose Mode
Logging
Performance Considerations
Token Usage
Latency
Next Steps
- Learn about Building Agents to create specialized agents
- Explore Custom Tools to extend agent capabilities
- See GUI Deployment to build multi-agent interfaces