ScriptsApr 7, 2026·2 min read

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.

TL;DR
Qwen-Agent provides tool calling, code execution, RAG, and browser control for building agents with Qwen models.
§01

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.

§02

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.

§03

How to use

  1. Install the package:
pip install qwen-agent
  1. 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)
  1. Add custom tools and configure MCP integrations as needed.
§04

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)
§05

Related on TokRepo

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.

§06

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

What models does Qwen-Agent support?+

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.

Does Qwen-Agent support MCP?+

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.

Can I create custom tools for Qwen-Agent?+

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.

Does Qwen-Agent include RAG support?+

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.

Is Qwen-Agent free to use?+

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)
🙏

Source & Thanks

Created by Alibaba Qwen Team. Licensed under Apache 2.0.

QwenLM/Qwen-Agent — 6k+ stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets