qwen-agent-docs/website/content/en/guide/get_started/configuration.md
This document explains all configuration parameters of Agent.
This part explains all configuration parameters used when setting up an LLM backend in Qwen-Agent via the llm_cfg dictionary.
| Parameter | Type | Required | Description |
|---|---|---|---|
model | str | β Yes | The model name to use. |
e.g., 'qwen3-max', 'qwen3-vl-plus', 'qwen3-omni-flash', 'qwen3-coder-plus' | |||
model_type | str | β Yes | Specifies the model provider, and binds with model capability. |
Use Alibaba Cloudβs DashScope API:
β’ 'qwen_dashscope': LLM, support Text --> Text.
β’ 'qwenvl_dashscope': VLM, support Text/Image/Video --> Text.
β’ 'qwenaudio_dashscope': Omni models, support Text/Image/Video/Audio --> Text.
Use an OpenAI-compatible API:
β’ 'oai': LLM, support Text --> Text.
β’ 'qwenvl_oai': VLM, support Text/Image/Video --> Text.
β’ 'qwenaudio_oai': Omni models, support Text/Image/Video/Audio --> Text. |
| model_server | str | β Conditionally | Required only for OpenAI-compatible API, e.g.,
β’ 'http://localhost:8000/v1': local server,
β’ 'https://dashscope.aliyuncs.com/compatible-mode/v1': OpenAI-compatible API of DashScope. |
| api_key | str | β No | API key for authentication.
β’ DashScope: Can be provided here or via the DASHSCOPE_API_KEY environment variable
β’ OpenAI-compatible API: Can be provided here or via the OPENAI_API_KEY environment variable. |
| generate_cfg | dict | β No | Controls generation behavior and parsing logic (see below) |
generate_cfg β Generation & Parsing Control| Parameter | Type | Default | Description |
|---|---|---|---|
max_input_tokens | int | 90000 | The maximum context length of the agent, when the context exceeds this length, context management will be automatically performed. This parameter should be lower than the maximum input length supported by the model to ensure the normal operation of the agent. |
use_raw_api | bool | False | Whether to use the model serverβs native tool-call parsing (e.g., vLLMβs built-in parser). |
We recommend set True for models in the qwen3-coder, qwen3-max, and subsequent series. It will be changed to the default True in the future. | |||
| enable thinking | β | β | Enables "thinking mode" if supported by the model. Depends on the parameter protocol of the model service side. |
β’ DashScope: enable_thinking=True | |||
β’ OpenAI-compatible API of DashScope: 'extra_body': {'enable_thinking': True} | |||
β’ OpenAI-compatible API of vLLM: 'extra_body': {'chat_template_kwargs': {'enable_thinking': True}} | |||
| (Other params) | β | β | Parameters directly transmitted to the model service, such as top_p, temperature, max_tokens, etc |
llm_cfg = {
'model': 'qwen3-max-preview',
'model_type': 'qwen_dashscope',
# 'api_key': 'your-key', # Optional if DASHSCOPE_API_KEY env var is set
'generate_cfg': {
'enable_thinking': 'True',
'use_raw_api': 'True',
'top_p': 0.8,
}
}
llm_cfg = {
'model': 'Qwen3-8B',
'model_server': 'http://localhost:8000/v1',
'api_key': 'EMPTY',
'generate_cfg': {
'top_p': 0.85,
'extra_body': {'chat_template_kwargs': {'enable_thinking': True}},
}
}
For working examples, see the examples/ directory in the Qwen-Agent repository.
When initializing an Assistant (or any agent that supports tool calling), you can specify available tools via the function_list parameter.
This parameter supports three distinct formats, and the system automatically detects and loads the corresponding tools accordingly.
Below is a detailed explanation of the supported formats and usage examples.
The function_list accepts a list, where each element can be one of the following three types:
str) β Reference a Pre-registered Built-in ToolTOOL_REGISTRY.@register_tool)."code_interpreter"
dict) β Configure a Registered Tool or MCP ServersThere are two subtypes of dictionary formats:
{
"name": "tool_name", # Required: Name of a pre-registered tool
"other_config": ... # Optional: Additional configuration parameters
}
name must correspond to a tool already in TOOL_REGISTRY.{
"name": "weather",
"api_key": "your_key"
}
'mcpServers'){
"mcpServers": {
"server_alias_1": {
"command": "executable",
"args": ["arg1", "arg2", ...]
},
"server_alias_2": { ... }
}
}
MCPManager().initConfig(...) to launch MCP services and auto-discover available tools.mcpServers (e.g., "time", "fetch") represents a separate MCP tool server.{
"mcpServers": {
"time": {
"command": "uvx",
"args": ["mcp-server-time", "--local-timezone=Asia/Shanghai"]
},
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"]
}
}
}
BaseTool Instance β Directly Provide a Tool ObjectBaseTool.my_tool = CustomSearchTool(config={...})
# Then include my_tool directly in function_list
β οΈ Note: Avoid tools with the same name!
tools = [
# Type 1: String reference to a built-in tool
"code_interpreter",
# Type 2a: Dictionary-based configuration for a registered tool
{
"name": "weather",
"api_key": "your_openweather_key"
},
# Type 2b: MCP server configuration
{
"mcpServers": {
"time": {
"command": "uvx",
"args": ["mcp-server-time", "--local-timezone=Asia/Shanghai"]
},
"file": {
"command": "uvx",
"args": ["mcp-server-filesystem"]
}
}
},
# Type 3: Direct BaseTool instance (optional)
# MyCustomTool(config={...})
]
bot = Assistant(
llm=llm_cfg,
function_list=tools
)
| Error | Cause | Solution |
|---|---|---|
ValueError: Tool xxx is not registered. | Attempted to use a tool name not present in TOOL_REGISTRY | Ensure the tool is registered, or use MCP / BaseTool instead |
| MCP server fails to start | Incorrect command/args, or missing MCP server in environment | Verify the command works in your terminal; ensure tools like mcp-server-time are installed (e.g., via uvx) |
The function_list parameter is designed to flexibly support multiple tool integration strategies:
mcpServers to plug into the MCP ecosystem.BaseTool instances for complete control.By combining these approaches, you can build powerful, extensible tool-calling agents.