Skip to content

[Bug] Model selector in Control UI uses wrong provider prefix when switching models #46480

@Yatkonglai

Description

@Yatkonglai

Description

When switching models in the Control UI chat page, the model selector sends an incorrect provider prefix in the sessions.patch request. It uses the current default provider's prefix instead of the selected model's actual provider prefix.

Steps to Reproduce

  1. Configure multiple providers (e.g., zai, kimi-coding, openai-codex)
  2. Set zai/glm-5 as the default model
  3. Open the Control UI at http://127.0.0.1:18789/chat
  4. Try to switch to k2p5 · kimi-coding from the model dropdown

Expected Behavior

The UI should send:

{"type":"sessions.patch","payload":{"session":"agent:main:main","model":"kimi-coding/k2p5"}}

Actual Behavior

The UI sends:

{"type":"sessions.patch","payload":{"session":"agent:main:main","model":"zai/k2p5"}}

This results in error:

Failed to set model: GatewayRequestError: model not allowed: zai/k2p5

Gateway Logs

[ws] ⇄ res ✗ sessions.patch 26ms errorCode=INVALID_REQUEST errorMessage=model not allowed: zai/k2p5

Same issue occurs when switching to other models:

  • Selecting gpt-5.4 · openai-codex sends zai/gpt-5.4 (wrong)
  • Should send openai-codex/gpt-5.4 (correct)

Workaround

Use CLI to switch models:

openclaw config set agents.defaults.model.primary "kimi-coding/k2p5"
pkill -f openclaw; openclaw start

Environment

Root Cause Analysis

The model selector dropdown appears to be using the currently active/default provider prefix instead of the selected model's actual provider when constructing the sessions.patch request payload.

Looking at the UI code, the model dropdown correctly displays models with their provider suffix (e.g., "k2p5 · kimi-coding"), but when the selection is made, the provider resolution logic seems to default to the current primary provider rather than parsing the selected model's provider.

Configuration Files

// openclaw.json
"agents": {
  "defaults": {
    "model": {
      "primary": "zai/glm-5",
      "fallbacks": ["openai-codex/gpt-5.4", "kimi-coding/k2p5", ...]
    }
  }
}

The bug occurs regardless of which provider is set as primary - it always uses the primary provider's prefix when switching to a different model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions