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.

PR
Prompt Lab · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

pip install qwen-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):
    print(response)

What is Qwen-Agent?

Qwen-Agent is an agent framework built around Alibaba's Qwen language models. It provides built-in tools (code interpreter, browser, RAG), supports MCP protocol, and includes a GUI for building custom agent applications — from simple chatbots to complex multi-agent workflows.

Answer-Ready: Qwen-Agent is an AI agent framework by Alibaba featuring built-in code execution, browser control, RAG retrieval, and MCP protocol support. It works with Qwen models and compatible APIs for building multi-tool agent applications.

Best for: Developers building AI agents with Qwen models or compatible APIs. Works with: Qwen-Max, Qwen-Plus, any OpenAI-compatible API. Setup time: Under 3 minutes.

Core Features

1. Built-In Tools

from qwen_agent.agents import Assistant

# Code Interpreter — execute Python in sandbox
bot = Assistant(
    llm={'model': 'qwen-max'},
    function_list=['code_interpreter'],
)

# RAG — retrieve from documents
bot = Assistant(
    llm={'model': 'qwen-max'},
    function_list=['doc_qa'],
    files=['report.pdf', 'data.csv'],
)

2. MCP Protocol Support

from qwen_agent.agents import Assistant

bot = Assistant(
    llm={'model': 'qwen-max'},
    mcp_servers={
        'filesystem': {
            'command': 'npx',
            'args': ['-y', '@anthropic/mcp-filesystem', '/tmp']
        }
    },
)

3. Custom Tool Development

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', 'required': True}]

    def call(self, params, **kwargs):
        city = params['city']
        return f'Sunny, 25C in {city}'

4. Multi-Agent Workflows

from qwen_agent.agents import GroupChat

researcher = Assistant(llm=cfg, name='Researcher', system_message='You research topics.')
writer = Assistant(llm=cfg, name='Writer', system_message='You write articles.')

group = GroupChat(agents=[researcher, writer])
for response in group.run(messages):
    print(response)

5. Browser Control

bot = Assistant(
    llm={'model': 'qwen-max'},
    function_list=['browser'],
)
# Agent can navigate, read, and interact with web pages

6. GUI Application

python -m qwen_agent.gui --agent-config config.json
# Launches a Gradio-based chat interface

FAQ

Q: Does it work with non-Qwen models? A: Yes, any OpenAI-compatible API works. Set the base_url and api_key accordingly.

Q: Is it open source? A: Yes, Apache 2.0 license. Fully open-source with active development.

Q: How does MCP support work? A: Qwen-Agent can connect to MCP servers as tool providers, similar to Claude Code or Cline.

🙏

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