Skip to main content

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

The Storage class manages file paths:

Approval Modes

Control when user confirmation is required:
Setting Approval Mode:

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:
Common Validation Rules:
  • 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:
These files are automatically included in model 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:
  1. Check for typos in setting names
  2. Verify value types (number vs string)
  3. Ensure values are within valid ranges
  4. Check for syntax errors in JSON files

Precedence Issues

If settings aren’t taking effect:
  1. Check for overrides in higher-priority sources
  2. Use /settings to see effective values
  3. Use --debug to see configuration loading

Next Steps