Qwen-Agent
Type: full-code · Vendor: Alibaba Qwen team (QwenLM) · Language: Python · License: Apache-2.0 · Status: active · Status in practice: emerging · First released: 2023-09-22
Provide a Python framework for building LLM applications that exercise the instruction-following, tool-use, planning, and memory capabilities of Alibaba's Qwen models, with built-in support for function calling, MCP, a Docker-sandboxed code interpreter, and RAG over very long documents.
Description. Qwen-Agent is the Apache-2.0 framework maintained by Alibaba's Qwen team for building agentic applications on top of Qwen models (Qwen >= 3.0). It ships in two languages — the English README and a parallel 中文 README_CN — and centres on three first-class capabilities advertised in the GitHub repo description: Function Calling, MCP, Code Interpreter, RAG. Distinctive characteristics: tight coupling to Qwen's native tool-call template (parallel function calls supported by default), Mandarin-first documentation with full Chinese-language abstractions and prompts, and a bundled fast-RAG pipeline aimed at super-long-document QA rather than generic vector-store glue.
Agent loop shape. Class-hierarchy-based imperative loop. The Agent base class defines an iterator interface; subclasses compose function calling, ReAct-style reasoning, and RAG: FnCallAgent is the function-calling base, ReActChat wraps the loop in a ReAct Thought/Action/Observation prompt, Assistant layers RAG over function-calling. Multi-agent shapes (group_chat, group_chat_auto_router, router) live in sibling modules.
Primary use cases
- Qwen-model-native function calling and tool use
- RAG over super-long documents
- ReAct-style agents with sandboxed code execution
- agentic apps with Mandarin-first prompts and docs
Key concepts
- class Agent (docs) — Base class: 'An agent can receive messages and provide response by LLM or Tools. Different agents have distinct workflows for processing messages and generating responses in the _run method.'
- class FnCallAgent (docs) — Function-calling base agent integrating LLM and tool use.
- class Assistant → agentic-rag (docs) — Default agent class integrating RAG and function calling.
- class ReActChat → react (docs) — ReAct-format agent carrying the embedded Thought/Action/Action Input/Observation prompt template.
- Code Interpreter tool → code-as-action (docs) — Docker-sandboxed code execution as a built-in tool the agent invokes autonomously.
Patterns this full-code implements —
- ★★Agentic RAG
Bundled fast-RAG pipeline aimed at super-long-document QA; the default Assistant class integrates RAG and function calling. A dedicated qwen_agent/agents/doc_qa/ subpackage exists.
- ★Code-as-Action Agent
The agent autonomously writes code and executes it in a Docker sandbox via the built-in Code Interpreter tool; observation = execution result.
- ★★Model Context Protocol
MCP is one of the four headline features in the repo's own one-line description; users configure MCP servers from the open-source MCP catalog.
- ★★ReAct
ReActChat is a named, exported agent class carrying the canonical ReAct prompt template (Thought / Action / Action Input / Observation).
- ★★Tool Use
Function calling is built into the LLM base class; FnCallAgent, ReActChat, and Assistant all inherit from it.
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.