Model Switcher
Switch the OpenClaw default model with backup, validation, and automatic rollback.
Workflow
Step 1: Validate Model Name
Read ~/.openclaw/openclaw.json. Extract:
- Current model from
agents.defaults.model.primary - Available models from
models.providerslist
Match user request against available models (exact, alias, or partial match):
- Exact:
zai/glm-5→ direct hit - Alias: "GLM 5" →
zai/glm-5; "doubao" →volcengine-plan/doubao-seed-2.0-pro - Partial: "deepseek" →
volcengine-plan/deepseek-v3.2
Step 2: Abort if Not Found
If no match, stop and report:
- List all available models
- Ask user to pick one
Never guess or execute blindly.
Step 3: Execute Switch
python3 scripts/model_switch.py <full-model-name> --retry 3
The script handles: backup → modify config → restart gateway → health check → auto-rollback on failure.
Step 4: Expect Session Interruption
Gateway restart kills the current session. This is normal. The session resumes automatically after Gateway recovers.
Constraints
- Only modify
agents.defaults.model.primary— never touch the provider list - Always validate model exists before switching
- Backups stored in
~/.openclaw/config_backups/ - Script has full backup + rollback — config will never be lost
