openclaw - ✅(Solved) Fix [Bug]: Control UI model switcher sends wrong provider prefix for cross-provider model switching [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50050Fetched 2026-04-08 00:59:50
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Timeline (top)
commented ×2labeled ×2cross-referenced ×1

The Control UI model picker sends bare model IDs (e.g. k2p5) instead of full provider/model keys (e.g. kimi-coding/k2p5), causing the gateway to prepend the wrong provider and reject the switch with "model not allowed".

Error Message

Gateway log when switching to kimi:

Failed to set model: GatewayRequestError: model not allowed: openai-codex/k2p5

Gateway log when switching to opus:

Failed to set model: GatewayRequestError: model not allowed: openai-codex/claude-opus-4-6

Root causes identified in minified dist (verified by patching):

  1. K_() in control-ui/assets/index-*.js: <select> option value uses t.id instead of provider/t.id
  2. W_() and G_(): read session.model but ignore session.modelProvider
  3. getSessionDefaults() in reply-*.js: const DEFAULT_MODEL = "claude-opus-4-6" used as fallback when no explicit default is configured

Root Cause

Root causes identified in minified dist (verified by patching):

Fix Action

Fix / Workaround

The UI sends the bare model ID ("k2p5") via sessions.patch. The gateway prepends the current session's provider ("openai-codex") instead of the model's actual provider ("kimi-coding"), producing an invalid key "openai-codex/k2p5" which is not in the allowlist.

Root causes identified in minified dist (verified by patching):

Affected: All users with multiple providers who use the Control UI model dropdown Severity: High (completely blocks cross-provider model switching via UI) Frequency: 100% repro on any multi-provider setup Consequence: Users cannot switch models across providers in the Control UI. Workaround is using /model command in TUI.

PR fix notes

Fix: Control UI Model Picker Sends Bare Model ID Instead of provider/model

Problem

The Control UI model dropdown sends bare model IDs (e.g. k2p5) via sessions.patch instead of fully-qualified keys (e.g. kimi-coding/k2p5). The gateway then prepends the current session's provider instead of the model's actual provider, producing an invalid key that is rejected by the allowlist.

Error: Failed to set model: GatewayRequestError: model not allowed: openai-codex/k2p5

Root Causes

LocationBugEffect
K_() in control-ui/assets/index-*.js<select> option value uses t.id instead of provider/t.idWrong provider prepended on switch
W_() / G_()Read session.model but ignore session.modelProviderDuplicate entries in dropdown
getSessionDefaults() in reply-*.jsHardcoded DEFAULT_MODEL = "claude-opus-4-6" used as fallbackShows wrong default when no global default is set

Workaround (Until Official Patch)

Use the TUI /model command instead of the Control UI dropdown:

/model kimi-coding/k2p5
/model anthropic/claude-opus-4-6

Or via the session_status tool with the full provider/model key.


Manual Patch (Advanced)

Locate the minified dist file:

find ~/.npm -name "index-*.js" | grep control-ui
# or
find /usr/local/lib -name "index-*.js" | grep openclaw

Patch 1 — Fix K_(): option value missing provider prefix

- value={t.id}
+ value={`${provider}/${t.id}`}

Patch 2 — Fix W_() / G_(): combine modelProvider + model

- return session.model
+ return session.modelProvider
+   ? `${session.modelProvider}/${session.model}`
+   : session.model

Patch 3 — Fix getSessionDefaults(): remove hardcoded fallback

- const DEFAULT_MODEL = "claude-opus-4-6"
- return { model: DEFAULT_MODEL }
+ const defaultModelExplicit = agents.defaults?.model?.primary ?? null
+ return { model: defaultModelExplicit }

This prevents the UI from showing Default (claude-opus-4-6) when no global default is configured.


Config Reference

Ensure each agent has a fully-qualified model.primary in ~/.openclaw/openclaw.json:

{
  "agents": {
    "list": [
      {
        "name": "main",
        "model": {
          "primary": "openai-codex/gpt-5.4",
          "fallbacks": [
            "anthropic/claude-opus-4-6",
            "kimi-coding/k2p5"
          ]
        }
      }
    ]
  }
}

Verification

After applying patches, restart the gateway and test cross-provider switching:

openclaw gateway restart
  1. Open Control UI → Chat tab
  2. Switch model dropdown from openai-codex/gpt-5.4kimi-coding/k2p5
  3. Confirm no error banner appears
  4. Confirm next message uses kimi-coding/k2p5

UX Suggestion

When no global default is configured:

  • Hide the Default option from the dropdown entirely
  • Label the agent's primary model with (primary) instead

References

  • Related issues: #48369, #48256, #46480, #46453, #47620
  • Affected: all users with multiple providers using the Control UI model dropdown
  • Severity: High — 100% repro on any multi-provider setup
  • Version: 2026.3.13 (61d171a)

Code Example

Gateway log when switching to kimi:
> Failed to set model: GatewayRequestError: model not allowed: openai-codex/k2p5

Gateway log when switching to opus:
> Failed to set model: GatewayRequestError: model not allowed: openai-codex/claude-opus-4-6

Root causes identified in minified dist (verified by patching):

1. K_() in control-ui/assets/index-*.js: <select> option value uses `t.id` instead of `provider/t.id`
2. W_() and G_(): read `session.model` but ignore `session.modelProvider`
3. getSessionDefaults() in reply-*.js: `const DEFAULT_MODEL = "claude-opus-4-6"` used as fallback when no explicit default is configured
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

The Control UI model picker sends bare model IDs (e.g. k2p5) instead of full provider/model keys (e.g. kimi-coding/k2p5), causing the gateway to prepend the wrong provider and reject the switch with "model not allowed".

Steps to reproduce

  1. Configure multiple providers in openclaw.json (e.g. anthropic, openai-codex, kimi-coding)
  2. Set agent primary model to openai-codex/gpt-5.4
  3. Open the Control UI Chat tab
  4. Use the model dropdown to switch to a model from a different provider (e.g. k2p5 · kimi-coding)
  5. Observe the error banner

Expected behavior

Model switches successfully to kimi-coding/k2p5. The dropdown reflects the new selection and the next message uses the selected model.

Actual behavior

Error banner: "Failed to set model: GatewayRequestError: model not allowed: openai-codex/k2p5"

The UI sends the bare model ID ("k2p5") via sessions.patch. The gateway prepends the current session's provider ("openai-codex") instead of the model's actual provider ("kimi-coding"), producing an invalid key "openai-codex/k2p5" which is not in the allowlist.

Additional issues after page refresh:

  • W_() and G_() also return bare model IDs (ignoring modelProvider), creating duplicate entries in the dropdown
  • getSessionDefaults() falls back to hardcoded DEFAULT_MODEL = "claude-opus-4-6" when agents.defaults.model.primary is not set, showing "Default (claude-opus-4-6)" regardless of the agent's actual primary

OpenClaw version

2026.3.13 (61d171a)

Operating system

Debian 12 (bookworm) / amd64

Install method

npm global

Model

openai-codex/gpt-5.4, anthropic/claude-opus-4-6, kimi-coding/k2p5

Provider / routing chain

openclaw -> openai-codex / anthropic / kimi-coding (direct)

Config file / key location

~/.openclaw/openclaw.json ; agents.defaults.models ; agents.list[].model.primary

Additional provider/model setup details

Three providers configured: anthropic (claude-sonnet-4-6, claude-opus-4-6), openai-codex (gpt-5.4), kimi-coding (k2p5). Agent "main" has model.primary = "openai-codex/gpt-5.4" with fallbacks to anthropic and kimi. No agents.defaults.model.primary set (per-agent config only).

Logs, screenshots, and evidence

Gateway log when switching to kimi:
> Failed to set model: GatewayRequestError: model not allowed: openai-codex/k2p5

Gateway log when switching to opus:
> Failed to set model: GatewayRequestError: model not allowed: openai-codex/claude-opus-4-6

Root causes identified in minified dist (verified by patching):

1. K_() in control-ui/assets/index-*.js: <select> option value uses `t.id` instead of `provider/t.id`
2. W_() and G_(): read `session.model` but ignore `session.modelProvider`
3. getSessionDefaults() in reply-*.js: `const DEFAULT_MODEL = "claude-opus-4-6"` used as fallback when no explicit default is configured

BELOW 👇 What it looks like when fixed (with no agents.defaults.primary.model but a primary model defined per agent).

<img width="1255" height="864" alt="Image" src="https://github.com/user-attachments/assets/8de7948e-31d0-4360-8bdf-c55199488026" />

Impact and severity

Affected: All users with multiple providers who use the Control UI model dropdown Severity: High (completely blocks cross-provider model switching via UI) Frequency: 100% repro on any multi-provider setup Consequence: Users cannot switch models across providers in the Control UI. Workaround is using /model command in TUI.

Additional information

Related issues: #48369, #48256, #46480, #46453, #47620

Workaround: Use /model provider/model-id in the TUI or session_status tool.

Local patches applied and verified on dist files:

  • K_(): changed option value from t.id to provider/t.id
  • W_()/G_(): combined modelProvider + '/' + model
  • getSessionDefaults(): added defaultModelExplicit flag, returns null when not explicitly configured
  • Added agentModelProvider/agentModel to sessions.list defaults for per-agent primary resolution

UX suggestion: when no global default is set, hide the "Default" option and label the agent's primary model with "(primary)" in the dropdown.

extent analysis

Fix Plan

To resolve the issue, we need to modify the code to send the full provider/model keys instead of bare model IDs. Here are the steps:

  • Modify the K_() function in control-ui/assets/index-*.js to use provider/t.id instead of t.id for the <select> option value.
  • Update the W_() and G_() functions to combine modelProvider + '/' + model instead of ignoring session.modelProvider.
  • Modify the getSessionDefaults() function in reply-*.js to add a defaultModelExplicit flag and return null when no explicit default is configured.
  • Add agentModelProvider and agentModel to sessions.list defaults for per-agent primary resolution.

Example code changes:

// control-ui/assets/index-*.js
function K_() {
  // ...
  option.value = `${provider}/${t.id}`; // Changed from t.id to provider/t.id
  // ...
}

// reply-*.js
function W_() {
  // ...
  const modelKey = `${session.modelProvider}/${session.model}`; // Combined modelProvider and model
  // ...
}

function G_() {
  // ...
  const modelKey = `${session.modelProvider}/${session.model}`; // Combined modelProvider and model
  // ...
}

function getSessionDefaults() {
  // ...
  const defaultModelExplicit = agents.defaults.model.primary !== undefined;
  if (!defaultModelExplicit) {
    return null; // Return null when no explicit default is configured
  }
  // ...
}

Verification

To verify the fix, follow these steps:

  1. Apply the code changes and restart the application.
  2. Configure multiple providers in openclaw.json.
  3. Set the agent primary model to a model from a different provider.
  4. Open the Control UI Chat tab and switch to a model from a different provider using the model dropdown.
  5. Verify that the model switches successfully and the dropdown reflects the new selection.

Extra Tips

To prevent similar issues in the future, make sure to:

  • Always use full provider/model keys when sending requests to the gateway.
  • Verify that the modelProvider is correctly set and used in the code.
  • Test the application with multiple providers and models to ensure that the model switching works correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Model switches successfully to kimi-coding/k2p5. The dropdown reflects the new selection and the next message uses the selected model.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING