@roman-yakobnyuk

Openclaw Mode Switcher

Self-escalating model routing — upgrades to a smarter model when it's needed, reverts automatically when it's done.

Current version
v1.2.2
code-pluginCommunitysource-linked

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-conversation
  • before_model_resolve hook overrides the active model for boosted turns
  • before_prompt_build injects a live countdown so the agent tracks its remaining turns
  • Auto-reverts to baseline after N turns — no manual reset needed
  • extend pseudo-mode resets the countdown without changing mode
  • State survives compaction via after_compaction hook
  • 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:

  1. The plugin records the new mode in session state
  2. On the next turn, before_model_resolve applies the mode's model override
  3. before_prompt_build prepends a status reminder with turns remaining
  4. After maxTurns turns, 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: true is required — without it the mode status reminder won't be injected into prompts.

Mode config fields:

FieldTypeDescription
descriptionstringShown in the tool definition the agent sees
modelstring | nullModel to use when this mode is active. null = session default
providerstring | nullProvider to use (e.g. "anthropic", "openai"). null = session default
maxTurnsnumber | nullTurns 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

License

MIT — Roman Yakobnyuk / Scriptive

Source and release

Source repository

scriptive-au/openclaw-mode-switcher

Open repo

Source commit

d07091fd65eee78cf851ed364545dcc136a3c4dc

View commit

Install command

openclaw plugins install clawhub:openclaw-mode-switcher

Metadata

  • Package: openclaw-mode-switcher
  • Created: 2026/04/09
  • Updated: 2026/04/09
  • Executes code: Yes
  • Source tag: main

Compatibility

  • Built with OpenClaw: 2026.3.31
  • Plugin API range: >=2026.3.24-beta.2
  • Tags: latest
  • Files: 7