Scripts2026年4月2日·1 分钟阅读

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.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Script
安装
Stage only
信任
信任等级:Community
入口
qwen-agent.md
安全暂存命令
npx -y tokrepo@latest install d95df987-a5d5-4578-90d7-45e4c8b34f93 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

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.

常见问题

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.

引用来源 (3)
🙏

来源与感谢

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.

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产