docs/source/framework/qwen_agent.rst
Qwen-Agent <https://github.com/QwenLM/Qwen-Agent>__ is a framework for
developing LLM applications based on the instruction following, tool
usage, planning, and memory capabilities of Qwen.
This is a simple tutorial on using Qwen-Agent to quickly experience the
agentic capabilities of Qwen3. For more detailed information, please
refer to Qwen-Agent <https://github.com/QwenLM/Qwen-Agent>__
repository.
.. code:: bash
pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]"
pip install -U qwen-agent for the minimal requirements.Qwen3 excels in tool calling capabilities. Qwen-Agent encapsulates tool-calling templates and tool-calling parsers internally, greatly reducing coding complexity.
To define the available tools, you can use the MCP configuration file, use the integrated tool of Qwen-Agent, or integrate other tools by yourself.
.. code:: python
import os from qwen_agent.agents import Assistant
llm_cfg = { # Use a custom endpoint compatible with OpenAI API by vLLM/SGLang: 'model': 'Qwen/Qwen3-32B', 'model_server': 'http://localhost:8000/v1', # api_base 'api_key': 'EMPTY',
# 'generate_cfg': {
# # When using vLLM/SGLang OAI API, pass the parameter of whether to enable thinking mode in this way
# 'extra_body': {
# 'chat_template_kwargs': {'enable_thinking': False}
# },
#
# # Add: When the content is `<think>this is the thought</think>this is the answer`
# # Do not add: When the response has been separated by reasoning_content and content
# # This parameter will affect the parsing strategy of tool call
# # 'thought_in_content': True,
# },
}
tools = [ {'mcpServers': { # You can specify the MCP configuration file 'time': { 'command': 'uvx', 'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai'] }, "fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } }, 'code_interpreter', # Built-in tools ]
bot = Assistant(llm=llm_cfg, function_list=tools)
messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}] for responses in bot.run(messages=messages): pass print(responses)
For more detailed examples and MCP cookbooks, please refer to
Qwen-Agent <https://github.com/QwenLM/Qwen-Agent>__ repository.