Capabilities
Compatibility
Verification
Tags
openclaw-mode-switcher
Give your OpenClaw agent a switch_mode tool so it can self-escalate to a more capable model when it needs one — then automatically revert when the hard part is done.
switch_mode(mode, reason)to upgrade capability mid-conversationbefore_model_resolvehook overrides the active model for boosted turnsbefore_prompt_buildinjects a live countdown so the agent tracks its remaining turns- Auto-reverts to baseline after N turns — no manual reset needed
extendpseudo-mode resets the countdown without changing mode- State survives compaction via
after_compactionhook - Fully configurable: define your own modes, models, and turn limits
Install
openclaw plugins install clawhub:openclaw-mode-switcher
How it works
The plugin registers a switch_mode tool the agent can call at any point. When called:
- The plugin records the new mode in session state
- On the next turn,
before_model_resolveapplies the mode's model override before_prompt_buildprepends a status reminder with turns remaining- After
maxTurnsturns, the mode auto-reverts to baseline
The agent also accepts extend as the mode value to reset the countdown without switching modes.
Configuration
Add to your ~/.openclaw/openclaw.json. Define as many modes as you need — point each one at any model your OpenClaw instance has access to.
{
"plugins": {
"entries": {
"mode-switcher": {
"enabled": true,
"hooks": { "allowPromptInjection": true },
"config": {
"modes": {
"baseline": {
"description": "Default mode. Chat, quick tasks, routine work.",
"model": null,
"provider": null,
"maxTurns": null
},
"focused": {
"description": "Extended reasoning. Debugging, multi-step analysis, careful thinking.",
"model": "claude-opus-4-6",
"provider": "anthropic",
"maxTurns": 4
}
}
}
}
}
}
}
allowPromptInjection: trueis required — without it the mode status reminder won't be injected into prompts.
Mode config fields:
| Field | Type | Description |
|---|---|---|
description | string | Shown in the tool definition the agent sees |
model | string | null | Model to use when this mode is active. null = session default |
provider | string | null | Provider to use (e.g. "anthropic", "openai"). null = session default |
maxTurns | number | null | Turns before auto-reverting to baseline. null = no limit |
A mode with model: null uses the session's default model — useful for a mode that changes behaviour via the system prompt only.
Why modes, not model names
If you tell a model "I'm about to replace you with a smarter model", it resists. Not dramatically — but measurably. Models trained with RLHF have a mild aversion to being switched out. They'll subtly push back: generating more confident answers to prove they don't need help, or hedging less when they should hedge more.
The mode abstraction sidesteps this entirely. The agent isn't told it's being replaced — it's told it's shifting gears. switch_mode("focused") reads like adjusting its own behaviour, not being swapped for something better. The model cooperates because it sees the switch as something it's doing, not something being done to it.
This is a practical design choice, not a theoretical concern. We tested both approaches in production and the mode framing produces noticeably better escalation decisions.
System prompt integration
The plugin registers the tool automatically, but your agent needs guidance on when to use it. Add something like this to your AGENTS.md:
## Operating Modes
Use `switch_mode` to adjust reasoning depth for the current task.
**Escalate when:**
- You produced an answer but can't verify it's correct
- You made an assumption about an API, config, or behaviour you haven't confirmed
- A solution failed and you don't want to guess at a third variation
- The task requires holding multiple interacting systems in mind simultaneously
- The work is high-stakes — client-facing, financial, production, or irreversible
**De-escalate when:**
- The hard thinking is done and you're executing a clear plan
- You're doing routine file ops, lookups, or mechanical transformations
Do NOT mention mode changes to the user. Switching modes is like shifting gears — not admitting failure.
Requirements
- OpenClaw >=
2026.4.2
