Qwen-Agent — Multi-Tool AI Agent Framework
Build AI agents with Alibaba Qwen models featuring tool calling, code execution, RAG, and browser control. Supports MCP protocol and custom tool development.
What it is
Qwen-Agent is an agent framework built around Alibaba's Qwen large language models. It provides tool calling, code execution (code interpreter), retrieval-augmented generation (RAG), and browser control capabilities. The framework supports the MCP protocol for tool integration and allows building custom tools in Python.
Qwen-Agent targets developers who want to build AI agents using Qwen models (qwen-max, qwen-plus, qwen-turbo) with built-in tool use capabilities. It provides a higher-level abstraction than raw API calls, handling tool dispatch, code sandboxing, and multi-turn conversations.
How it saves time or tokens
Qwen-Agent handles the boilerplate of tool integration: parsing tool calls from model output, executing tools, and feeding results back to the model. The built-in code interpreter runs Python code in a sandbox without external infrastructure. RAG support handles document chunking and retrieval automatically. This eliminates the need to build these capabilities from scratch for each agent project.
How to use
- Install the package:
pip install qwen-agent
- Create a basic agent:
from qwen_agent.agents import Assistant
bot = Assistant(
llm={'model': 'qwen-max'},
function_list=['code_interpreter', 'image_gen'],
)
messages = [{'role': 'user', 'content': 'Draw a sine wave plot'}]
for response in bot.run(messages=messages):
print(response)
- Add custom tools and configure MCP integrations as needed.
Example
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool
@register_tool('weather')
class WeatherTool(BaseTool):
description = 'Get current weather for a city'
parameters = [{
'name': 'city',
'type': 'string',
'description': 'City name',
'required': True
}]
def call(self, params, **kwargs):
city = params['city']
return f'Weather in {city}: 22C, partly cloudy'
bot = Assistant(
llm={'model': 'qwen-max'},
function_list=['weather', 'code_interpreter'],
)
for response in bot.run([{'role': 'user', 'content': 'What is the weather in Beijing?'}]):
print(response)
Related on TokRepo
- AI Agent Tools — Frameworks for building AI agents
- Multi-Agent Frameworks — Compare multi-agent orchestration options
This tool integrates with standard development workflows and requires minimal configuration to get started. It is available as open-source software with documentation and community support through the official repository. The project follows semantic versioning for stable releases.
For teams evaluating this tool, the key advantage is reducing manual work in repetitive tasks. The automation provided by the built-in features means less custom code to maintain and fewer integration points to manage. This translates directly to lower maintenance costs and faster iteration cycles.
Common pitfalls
- Qwen-Agent requires a Qwen API key from Alibaba Cloud (DashScope); it does not work with OpenAI or Anthropic models out of the box.
- The code interpreter executes Python code locally; ensure sandboxing is configured appropriately for production use.
- MCP support is available but may require manual configuration; check the documentation for the latest integration instructions.
Frequently Asked Questions
Qwen-Agent is built for Alibaba's Qwen models: qwen-max, qwen-plus, qwen-turbo, and other Qwen variants. It uses the DashScope API for model access. Custom model endpoints can be configured for self-hosted Qwen instances.
Yes. Qwen-Agent supports the Model Context Protocol (MCP) for tool integration. You can connect MCP servers as tool providers, giving the agent access to external tools and services via the MCP standard.
Yes. Use the @register_tool decorator to define custom tools as Python classes. Each tool specifies a description, parameters, and a call method. The agent automatically discovers and uses registered tools.
Yes. Qwen-Agent provides built-in document retrieval capabilities for RAG. It handles document chunking, embedding, and retrieval, so you can build knowledge-augmented agents without external vector stores.
The Qwen-Agent framework is open-source and free. However, using Qwen models via the DashScope API incurs API costs based on token usage. Self-hosted Qwen models can be used without API fees.
Citations (3)
- Qwen-Agent GitHub— Qwen-Agent provides tool calling, code execution, and RAG for Qwen models
- Qwen Documentation— Qwen models available via DashScope API
- Qwen-Agent README— Qwen-Agent supports MCP protocol for tool integration
Related on TokRepo
Source & Thanks
Created by Alibaba Qwen Team. Licensed under Apache 2.0.
QwenLM/Qwen-Agent — 6k+ stars
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.