Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.
Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.
中文 | English
💜 Qwen Chat | 🤗 Hugging Face | 🤖 ModelScope | 📑 Blog | 📖 Documentation
📊 Benchmark | 💬 WeChat (微信) | 🫨 Discord
Qwen-Agent is a framework for developing LLM applications based on the instruction following, tool usage, planning, and memory capabilities of Qwen. It also comes with example applications such as Browser Assistant, Code Interpreter, and Custom Assistant. Now Qwen-Agent plays as the backend of Qwen Chat.
reasoning_content field; adjust the default Function Call template, which is applicable to the Qwen2.5 series general models and QwQ-32B. If you need to use the old version of the template, please refer to the example for passing parameters.pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]"
# Or use `pip install -U qwen-agent` for the minimal requirements.
# The optional requirements, specified in double brackets, are:
# [gui] for Gradio-based GUI support;
# [rag] for RAG support;
# [code_interpreter] for Code Interpreter support;
# [mcp] for MCP support.git clone https://github.com/QwenLM/Qwen-Agent.git
cd Qwen-Agent
pip install -e ./"[gui,rag,code_interpreter,mcp]"
# Or `pip install -e ./` for minimal requirements.You can either use the model service provided by Alibaba Cloud's DashScope, or deploy and use your own model service using the open-source Qwen models.
If you choose to use the model service offered by DashScope, please ensure that you set the environment
variable DASHSCOPE_API_KEY to your unique DashScope API key.
Alternatively, if you prefer to deploy and use your own model service, please follow the instructions provided in the README of Qwen2 for deploying an OpenAI-compatible API service.
Specifically, consult the vLLM section for high-throughput GPU deployment or the Ollama section for local CPU (+GPU) deployment.
For the QwQ and Qwen3 model, it is recommended to do not add the --enable-auto-tool-choice and --tool-call-parser hermes parameters, as Qwen-Agent will parse the tool outputs from vLLM on its own.
For Qwen3-Coder, it is recommended to enable both of the above parameters, use vLLM's built-in tool parsing, and combine with the use_raw_api parameter usage.
Qwen-Agent offers atomic components, such as LLMs (which inherit from class BaseChatModel and come with function calling) and Tools (which inherit
from class BaseTool), along with high-level components like Agents (derived from class Agent).
The following example illustrates the process of creating an agent capable of reading PDF files and utilizing tools, as well as incorporating a custom tool:
…In addition to using built-in agent implementations such as class Assistant, you can also develop your own agent implemetation by inheriting from class Agent.
The framework also provides a convenient GUI interface, supporting the rapid deployment of Gradio Demos for Agents. For example, in the case above, you can quickly launch a Gradio Demo using the following code:
from qwen_agent.gui import WebUI
WebUI(bot).run() # bot is the agent defined in the above code, we do not repeat the definition here for saving space.Now you can chat with the Agent in the web UI. Please refer to the examples directory for more usage examples.
We implement a code interpreter tool based on local Docker containers. You can enable the built-in code interpreter tool for your agent, allowing it to autonomously write code according to specific scenarios, execute it securely within an isolated sandbox environment, and return the execution results.
⚠️ Note: Before using this tool, please ensure that Docker is installed and running on your local operating system. The time required to build the container image for the first time depends on your network conditions. For Docker installation and setup instructions, please refer to the official documentation.
You can select the required tools on the open-source MCP server website and configure the relevant environment.
Example of MCP invocation format:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
},
"sqlite" : {
"command": "uvx",
"args": [
"mcp-server-sqlite",
"--db-path",
"test.db"
]
}
}
}For more details, you can refer to the MCP usage example
The dependencies required to run this example are as follows:
# Node.js (Download and install the latest version from the Node.js official website)
# uv 0.4.18 or higher (Check with uv --version)
# Git (Check with git --version)
# SQLite (Check with sqlite3 --version)
# For macOS users, you can install these components using Homebrew:
brew install uv git sqlite3
# For Windows users, you can install these components using winget:
winget install --id=astral-sh.uv -e
winget install git.git sqlite.sqliteYes. The LLM classes provide function calling. Additionally, some Agent classes also are built upon the function calling capability, e.g., FnCallAgent and ReActChat.
The current default tool calling template natively supports Parallel Function Calls.
…We have released a fast RAG solution, as well as an expensive but competitive agent, for doing question-answering over super-long documents. They have managed to outperform native long-context models on two challenging benchmarks while being more efficient, and perform perfectly in the single-needle "needle-in-the-haystack" pressure test involving 1M-token contexts. See the blog for technical details.
BrowserQwen is a browser assistant built upon Qwen-Agent. Please refer to its documentation for details.
The Docker container-based code interpreter mounts only the specified working directory and implements basic sandbox isolation, but it should still be used with caution in production environments.
DialogueRetrievalAgent reuses history filename for independent default-session runs in the same second
ReActChat crashes on empty model output, including after a completed tool call
MCP tool discovery ignores nextCursor and omits tools after the first page
Feature request: YOLO mode (you can keep the branding!) - easily configurable no-sandboxing mode
Keyword and hybrid retrieval crash when document tokenization yields an empty vocabulary
Empty-query search crashes for plain text and page-list documents
Proposal / Feature Request]: Latent Space (Vector) Communication Protocol for Multi-Agent & Intra-Model Systems
[DeepPlanning] LLM report→JSON conversion silently drops drafts and copies the few-shot budget (2400/…/6700), inflating travelplanning scores
RFC: Optional tool lifecycle hooks for auditable execution receipts
coder.qwen.ai "Publish to GitHub" fail,s