Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsApr 2, 2026·2 min de lecture

Qwen-Agent — Build AI Agents on Qwen Models

Agent framework by Alibaba with function calling, code interpreter, RAG, and MCP support. Built for Qwen 3.0+. 15K+ stars.

Alibaba
Alibaba · Community
Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 17/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
Script
Installation
Stage only
Confiance
Confiance : Community
Point d'entrée
qwen-agent.md
Commande de staging sûr
npx -y tokrepo@latest install d95df987-a5d5-4578-90d7-45e4c8b34f93 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

TL;DR
Alibaba's agent framework with function calling, code interpreter, RAG, and MCP support built for Qwen 3.0+ models.
§01

What it is

Qwen-Agent is an agent framework by Alibaba designed for building AI agents on top of Qwen models. It provides function calling, a built-in code interpreter, RAG (retrieval-augmented generation), and MCP server support. The framework is optimized for Qwen 3.0+ but can work with other OpenAI-compatible models. It has 15K+ GitHub stars.

Qwen-Agent targets developers building AI applications with Qwen models who need agent capabilities beyond simple chat completions. It provides the infrastructure for multi-step reasoning, tool use, and knowledge retrieval.

§02

How it saves time or tokens

Qwen-Agent provides pre-built components for common agent patterns. The code interpreter executes Python in a sandboxed environment for data analysis tasks. The RAG module handles document chunking, embedding, and retrieval without separate infrastructure. MCP support lets agents connect to external tools through the Model Context Protocol. These components eliminate the need to build agent infrastructure from scratch.

§03

How to use

  1. Install Qwen-Agent:
pip install -U 'qwen-agent[gui,rag,code_interpreter,mcp]'
  1. Create an agent with tools:
from qwen_agent.agents import Assistant

agent = Assistant(
    llm={'model': 'qwen-max', 'api_key': 'YOUR_KEY'},
    function_list=['code_interpreter'],
    system_message='You are a data analysis assistant.'
)
  1. Run the agent on a task and it will use tools as needed.
§04

Example

Agent with code interpreter for data analysis:

from qwen_agent.agents import Assistant

agent = Assistant(
    llm={'model': 'qwen-max', 'api_key': 'YOUR_KEY'},
    function_list=['code_interpreter'],
)

# The agent writes and executes Python code
response = agent.run([
    {'role': 'user', 'content': 'Analyze this CSV data and create a chart: ...data...'}
])

# Agent generates Python code, runs it in sandbox,
# produces matplotlib charts, and returns results
for chunk in response:
    print(chunk)

The code interpreter runs in a sandboxed environment, preventing unsafe operations.

§05

Related on TokRepo

§06

Common pitfalls

  • Qwen-Agent is optimized for Qwen models. While it supports OpenAI-compatible APIs, function calling behavior may differ across providers.
  • The code interpreter requires a Python environment. Docker is recommended for production deployments to ensure sandboxing.
  • RAG performance depends on embedding quality. Use Qwen's own embedding models for best results with the Qwen-Agent RAG pipeline.
  • Always check the official documentation for the latest version-specific changes and migration guides before upgrading in production environments.
  • For team deployments, establish clear guidelines on configuration and usage patterns to ensure consistency across developers.

Questions fréquentes

Does Qwen-Agent only work with Qwen models?+

Qwen-Agent is optimized for Qwen 3.0+ models but supports any OpenAI-compatible API. However, function calling behavior and output quality may vary when using non-Qwen models.

What is the code interpreter feature?+

The code interpreter is a sandboxed Python execution environment. When the agent needs to analyze data, create charts, or compute results, it writes Python code and executes it safely. Results including generated files and images are returned to the user.

Does Qwen-Agent support MCP?+

Yes. Qwen-Agent supports the Model Context Protocol, allowing agents to connect to MCP servers for database access, web browsing, file management, and other external tools.

How does RAG work in Qwen-Agent?+

Qwen-Agent's RAG module handles document parsing, chunking, embedding, and retrieval. You provide documents and the agent automatically retrieves relevant chunks when answering questions, grounding responses in your data.

Is Qwen-Agent free to use?+

Qwen-Agent is open-source and free. However, using Qwen models through Alibaba Cloud's API requires an API key with associated costs. Local deployment with open-source Qwen model weights is also supported.

Sources citées (3)
🙏

Source et remerciements

Created by QwenLM (Alibaba Qwen Team). Licensed under Apache-2.0.

Qwen-Agent — ⭐ 15,800+

Thanks to the Qwen team at Alibaba for open-sourcing both the models and the agent framework.

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires