Qwen-Agent Architecture & Features
Core Components
┌─────────────────────────────────────┐
│ Agent Layer │
│ Assistant │ ReActChat │ Router │
├─────────────────────────────────────┤
│ Tool Layer │
│ Function Calling │ Code Interpreter│
│ Web Search │ MCP Tools │ Custom │
├─────────────────────────────────────┤
│ LLM Layer │
│ Qwen-Max │ Qwen-Plus │ Local Qwen │
└─────────────────────────────────────┘Function Calling
Native function calling with automatic schema parsing:
from qwen_agent.tools import BaseTool, register_tool
@register_tool("get_weather")
class WeatherTool(BaseTool):
description = "Get weather for a city"
parameters = [{"name": "city", "type": "string", "required": True}]
def call(self, params, **kwargs):
city = params["city"]
return f"Weather in {city}: 25°C, sunny"Code Interpreter
Executes Python code in an isolated Docker sandbox:
- Matplotlib/Seaborn chart generation
- Pandas data analysis
- File I/O in sandboxed environment
- Automatic output capture and display
RAG (Retrieval Augmented Generation)
Built-in document understanding pipeline:
- PDF, DOCX, HTML, Markdown parsing
- Chunking with configurable overlap
- Vector similarity search
- Citation tracking in responses
MCP Support
Connect external tools via Model Context Protocol:
agent = Assistant(
llm={"model": "qwen-max"},
mcp_servers=[{
"url": "http://localhost:8080/mcp",
"tools": ["search", "calculator"]
}]
)Built-in GUI
Launch a Gradio chat interface instantly:
from qwen_agent.gui import WebUI
WebUI(agent).run(server_port=7860)Multi-Agent Orchestration
Route tasks to specialized agents:
from qwen_agent.agents import GroupChat, Router
agents = [coder_agent, researcher_agent, writer_agent]
router = Router(llm=llm, agents=agents)FAQ
Q: What is Qwen-Agent? A: Qwen-Agent is an open-source Python framework by Alibaba for building AI agents on Qwen models, featuring function calling, code interpretation, RAG, and MCP support. 15,800+ GitHub stars.
Q: Can I use Qwen-Agent with non-Qwen models? A: It's optimized for Qwen models but supports any OpenAI-compatible API endpoint. Best results come from Qwen-Max and Qwen-Plus which have native function calling.
Q: Is Qwen-Agent free? A: Yes, Apache-2.0 licensed. The Qwen models themselves have varying licenses — Qwen 3.0 is Apache-2.0 for most sizes.