Bug
openclaw models auth order set writes the correct order to ~/.openclaw/agents/<agentId>/agent/auth-profiles.json, but the running gateway overwrites it on the next saveAuthProfileStore() call (triggered by any API call that updates usage stats, cooldowns, or lastGood).
Root Cause
In src/agents/auth-profiles/store.ts, resolveAuthProfileOrder() uses:
const storedOrder = findNormalizedProviderValue(store.order, providerKey);
const configuredOrder = findNormalizedProviderValue(cfg?.auth?.order, providerKey);
const explicitOrder = storedOrder ?? configuredOrder;
The in-memory store.order takes priority over cfg.auth.order. When the CLI command writes to the file, it does not update the running gateway's in-memory runtimeAuthStoreSnapshots. The next saveAuthProfileStore() call then persists the stale in-memory order back to disk, reverting the CLI change.
Steps to Reproduce
- Configure two Anthropic auth profiles (
anthropic:default and anthropic:secondary)
- Set order:
openclaw models auth order set --agent main --provider anthropic anthropic:default anthropic:secondary
- Verify file has correct order ✅
- Wait for any API call (or trigger one manually)
- Check file again — order is reverted to the previous in-memory state ❌
Gateway restart also reverts, because:
- Running gateway overwrites the file before the restart kills it
- New gateway loads the (now-reverted) file
Expected Behavior
openclaw models auth order set should either:
- Hot-reload the running gateway's in-memory auth store (preferred), or
- At minimum, the gateway should re-read
auth.order from openclaw.json on startup and use it as authoritative over the persisted store order
Workaround
Stop the gateway before setting the order, then start it:
openclaw gateway stop
openclaw models auth order set --agent main --provider anthropic anthropic:default anthropic:secondary
openclaw gateway start
This ensures the file is written while no gateway process can overwrite it, and the fresh gateway loads the correct order into memory.
Environment
- OpenClaw v2026.3.12 (6472949)
- Two Anthropic static token profiles
- Linux x64, Node v22.19.0
Bug
openclaw models auth order setwrites the correct order to~/.openclaw/agents/<agentId>/agent/auth-profiles.json, but the running gateway overwrites it on the nextsaveAuthProfileStore()call (triggered by any API call that updates usage stats, cooldowns, orlastGood).Root Cause
In
src/agents/auth-profiles/store.ts,resolveAuthProfileOrder()uses:The in-memory
store.ordertakes priority overcfg.auth.order. When the CLI command writes to the file, it does not update the running gateway's in-memoryruntimeAuthStoreSnapshots. The nextsaveAuthProfileStore()call then persists the stale in-memory order back to disk, reverting the CLI change.Steps to Reproduce
anthropic:defaultandanthropic:secondary)openclaw models auth order set --agent main --provider anthropic anthropic:default anthropic:secondaryGateway restart also reverts, because:
Expected Behavior
openclaw models auth order setshould either:auth.orderfromopenclaw.jsonon startup and use it as authoritative over the persisted store orderWorkaround
Stop the gateway before setting the order, then start it:
openclaw gateway stop openclaw models auth order set --agent main --provider anthropic anthropic:default anthropic:secondary openclaw gateway startThis ensures the file is written while no gateway process can overwrite it, and the fresh gateway loads the correct order into memory.
Environment