openclaw icon indicating copy to clipboard operation
openclaw copied to clipboard

Feature: Gateway-level /switch command to change auth accounts without AI

Open jgottapu opened this issue 10 months ago • 1 comments

Problem

When the upstream AI model is unreachable (rate limits, auth errors, network issues), users have no way to switch to a backup account because:

  1. WhatsApp/Telegram messages go through Gateway → AI model → response
  2. If the model is dead, nothing processes
  3. Chicken-and-egg: need AI to change config, but can't reach AI

This caused a full day of downtime today - the system was stuck hitting rate limits on one account with no way to switch to the other.

Proposed Solution

Add gateway-level commands that bypass the AI entirely:

/switch primary     # Switch to primary Anthropic account
/switch secondary   # Switch to secondary account  
/switch toggle      # Toggle between accounts
/switch status      # Show current account

These commands should:

  • Be intercepted at the gateway level before reaching the AI
  • Modify auth.order.anthropic in config
  • Restart the gateway automatically
  • Work even when the AI model is completely unreachable

Current Workaround

Created a shell script that modifies config and restarts gateway, triggered via iOS Shortcut over SSH. Works, but requires SSH access and isn't as seamless as a native command.

Why This Matters

Multi-account setups exist precisely for redundancy. But if the failover mechanism requires the failing component to work, it's not really redundant. The gateway should be able to switch accounts independently of AI availability.

Additional Context

  • Config path: auth.order.anthropic: ["secondary", "primary"]
  • First account in array is used
  • Just need to swap the order and restart

jgottapu avatar Feb 02 '26 23:02 jgottapu

Closing this as implemented after Codex review.

Current OpenClaw already provides gateway-handled, no-model account switching and status for auth profiles, plus persistent config+restart commands for global auth-order changes.

What I checked:

  • Gateway handles slash commands/directives before the model: Docs state commands are handled by the Gateway, directives are stripped before the model sees them, and inline shortcuts run immediately before normal model flow. (docs/tools/slash-commands.md:9, 00bd2cf7a376)
  • Fast path bypasses queue and model: Docs explicitly say command-only messages from allowlisted senders are handled immediately with a bypass of queue and model. (docs/tools/slash-commands.md:197, 00bd2cf7a376)
  • Per-session auth-profile switching already exists: FAQ documents /model opus@anthropic:default and /model opus@anthropic:work, and says /model status shows which auth profile is active/next. (docs/help/faq.md:2329, 00bd2cf7a376)
  • Model/profile switch is persisted and acknowledged without agent output: Directive handling persists the requested model/auth-profile override and immediately returns a reply like Model set ... Auth profile set .... (src/auto-reply/reply/get-reply-directives-apply.ts:251, 00bd2cf7a376)
  • Global auth-order edits and restart are already exposed as gateway commands: Docs expose /config show|get|set|unset for openclaw.json and /restart; the handlers write validated config to disk and trigger gateway restart. auth.order[provider] is the explicit rotation order knob. (src/auto-reply/reply/commands-config.ts:169, cec34821754a)

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against cec34821754a; fix evidence: release v2026.4.22, commit 00bd2cf7a376.

steipete avatar Apr 24 '26 16:04 steipete