Configuration System
Qwen Code uses a sophisticated hierarchical configuration system that allows customization at multiple levels with clear precedence rules.Overview
The configuration system provides:- Hierarchical Loading: Multiple configuration sources with defined precedence
- Type Safety: Full TypeScript type definitions
- Validation: Automatic validation of configuration values
- Dynamic Updates: Some settings can be changed at runtime
- Environment Integration: Seamless environment variable support
Configuration Hierarchy
Configuration is loaded from multiple sources with this precedence (highest to lowest):Example:
Configuration File Format
User Settings
Location:~/.qwen/settings.json
Purpose: Global settings across all projects
Project Settings
Location:.qwen/settings.json in project root
Purpose: Project-specific overrides
Configuration Categories
General Settings
UI Settings
Model Settings
Context Settings
Tool Settings
Privacy Settings
Advanced Settings
Environment Variables
Core Variables
Variable Naming Convention
- Qwen-specific:
QWEN_* - OpenAI compatibility:
OPENAI_* - Development:
DEBUG,DEV,VERBOSE
CLI Arguments
Override any setting via command-line arguments:Configuration API
Access configuration programmatically:Storage System
TheStorage class manages file paths:
Approval Modes
Control when user confirmation is required:File Filtering
Control which files are accessible:Tool Restrictions
Core Tools (Allowlist)
Restrict to specific tools:Exclude Tools (Blocklist)
Block specific tools or commands:Validation
Configuration is validated on load:- Temperature: 0.0 ≤ value ≤ 2.0
- Top P: 0.0 ≤ value ≤ 1.0
- Max tokens: value > 0
- File size: value > 0
- Model: non-empty string
Context Files
Special markdown files for persistent context:- QWEN.md: User preferences, project info, saved memories
- AGENTS.md: Agent configurations and instructions
- PROJECT.md: Project overview and guidelines
Best Practices
User Settings
Use for personal preferences:Project Settings
Use for project-specific configuration:Environment Variables
Use for sensitive data or environment-specific settings:CLI Arguments
Use for one-off overrides:Troubleshooting
View Effective Configuration
Configuration Validation Errors
If you see validation errors:- Check for typos in setting names
- Verify value types (number vs string)
- Ensure values are within valid ranges
- Check for syntax errors in JSON files
Precedence Issues
If settings aren’t taking effect:- Check for overrides in higher-priority sources
- Use
/settingsto see effective values - Use
--debugto see configuration loading
Next Steps
- Testing Guide - Testing with different configurations
- Tools System - Configuring tool access
- Subagents System - Agent configurations
