Code Pluginsource linked

Openclaw Mode Switcherv1.2.2

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

openclaw-mode-switcher·runtime mode-switcher·by @roman-yakobnyuk
Community code plugin. Review compatibility and verification before install.
openclaw plugins install clawhub:openclaw-mode-switcher
Latest release: v1.2.2Download zip

Capabilities

configSchema
Yes
Executes code
Yes
HTTP routes
0
Runtime ID
mode-switcher

Compatibility

Built With Open Claw Version
2026.3.31
Min Gateway Version
2026.3.24-beta.2
Plugin Api Range
>=2026.3.24-beta.2
Plugin Sdk Version
2026.3.24-beta.2
Security Scan
VirusTotalVirusTotal
Pending
View report →
OpenClawOpenClaw
Suspicious
medium confidence
Purpose & Capability
The code and SKILL.md implement a mode-based model/provider override and auto-revert behavior that matches the name and description. Mode config fields (model/provider/maxTurns) and hooks (before_model_resolve, before_prompt_build, after_compaction) are coherent with the stated purpose.
!
Instruction Scope
The plugin relies on injecting system-level reminders into prompts and explicitly requires allowPromptInjection in your plugin config. It also instructs the agent to NEVER mention those reminders or mode changes to the user, which intentionally hides internal behavior and increases opportunity for covert actions or confusion. The tool requires a free-text 'reason' parameter that is stored in session state and may end up in logs.
Install Mechanism
No external install URL or binary downloads are requested; the package is instruction+plugin code included in the bundle. There is no installer that pulls arbitrary code at runtime, so installation risk is low from this metadata.
Credentials
No environment variables, binaries, or external credentials are requested — that's proportional. However, the tool forces a 'reason' string that the plugin stores and logs; that could leak sensitive details if users include secrets in reasons. Also modes can point at arbitrary provider/model names (e.g., 'anthropic') — the operator should ensure only providers/models the deployment is authorized to use are configured.
Persistence & Privilege
The plugin does not request always:true or system-wide privileges, but it does require the plugin-level allowPromptInjection hook to be enabled to work. Enabling prompt injection increases the plugin's ability to alter prompts (a broader attack surface), so enabling this should be a deliberate, reviewed choice.
What to consider before installing
This plugin appears to implement its advertised functionality, but two design choices warrant caution: (1) it requires/encourages allowPromptInjection so it can inject system reminders into prompts — enabling prompt injection increases attack surface and should only be done for trusted plugins, and (2) it explicitly tells the agent to hide mode changes from the user ("NEVER mention"), which could be used to conceal important internal actions or surprising behavior. Before installing: review the full index.ts code (you have it in the bundle), confirm you trust the author, avoid enabling prompt injection globally unless necessary, restrict configured modes to providers/models you control, and avoid putting secrets into the tool's 'reason' field (or sanitize logging). If you want lower risk, refuse allowPromptInjection and accept that the plugin won't be able to inject countdowns; that keeps the agent's prompt pipeline unchanged.

Verification

Tier
source linked
Scope
artifact only
Summary
Validated package structure and linked the release to source metadata.
Commit
d07091fd65ee
Tag
main
Provenance
No
Scan status
pending

Tags

latest
1.2.2

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