Skip to content

[Bug]: Model switching reuses the current/default provider prefix across different providers, causing model not allowed #48369

@azzazi98

Description

@azzazi98

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When multiple providers are configured in the same OpenClaw instance, switching from a model under one provider to a model under another provider fails.

OpenClaw appears to reuse the current/default provider prefix when resolving the next model, instead of preserving the explicitly selected full model reference.

This causes valid models to be rewritten into invalid refs and then rejected with:

Failed to set model: GatewayRequestError: model not allowed: <wrong-provider>/<model>

This is reproducible even when using slash commands, not only the model dropdown.

Steps to reproduce

  1. Configure two providers in the same OpenClaw instance, for example:

    • openai-codex via OAuth
    • opencode-go via API key
  2. Add valid model refs from both providers to agents.defaults.models.

  3. Set the default model to:
    openai-codex/gpt-5.4

  4. Try to switch to one of these models:

    • opencode-go/kimi-k2.5
    • opencode-go/glm-5
    • opencode-go/minimax-m2.5
  5. Observe that OpenClaw fails with:

    • Failed to set model: GatewayRequestError: model not allowed: openai-codex/kimi-k2.5
    • Failed to set model: GatewayRequestError: model not allowed: openai-codex/glm-5
    • Failed to set model: GatewayRequestError: model not allowed: openai-codex/minimax-m2.5
  6. Now change the default model to one of the opencode-go/* models.

  7. Try switching back to:
    openai-codex/gpt-5.4

  8. Observe that OpenClaw fails with:

    • Failed to set model: GatewayRequestError: model not allowed: opencode-go/gpt-5.4

Notes:

  • I reproduced this through slash commands as well, not just the dropdown.
  • The config validates successfully.
  • Restarting the gateway does not fix the issue.

Expected behavior

When I explicitly select a full model ref such as:

  • openai-codex/gpt-5.4
  • opencode-go/kimi-k2.5
  • opencode-go/glm-5
  • opencode-go/minimax-m2.5

OpenClaw should use that exact full ref as-is.

The currently active/default provider should not be reused to rewrite the selected model into a different provider namespace.

Actual behavior

OpenClaw appears to resolve the next selected model relative to the current/default provider.

Examples of wrong rewritten refs I am getting:

  • openai-codex/kimi-k2.5
  • openai-codex/glm-5
  • openai-codex/minimax-m2.5
  • opencode-go/gpt-5.4

These are invalid provider/model combinations, so the gateway rejects them with model not allowed.

Also, whichever provider is currently the default tends to be the only one that works correctly at that moment.


OpenClaw version

2026.3.13

Operating system

Ubuntu on WSL2 (running on Windows)

Install method

Local gateway install / local mode (open-Liner)

Model

Working individually when aligned with the current default: - openai-codex/gpt-5.4 - opencode-go/kimi-k2.5 - opencode-go/glm-5 - opencode-go/minimax-m2.5 Cross-provider switching fails.

Provider / routing chain

Configured providers: - openai-codex (mode: oauth) - opencode-go (mode: api_key)

Config file / key location

json { "auth": { "profiles": { "opencode-go:default": { "provider": "opencode-go", "mode": "api_key" }, "openai-codex:default": { "provider": "openai-codex", "mode": "oauth" } } }, "agents": { "defaults": { "model": { "primary": "openai-codex/gpt-5.4", "fallbacks": [ "opencode-go/kimi-k2.5", "opencode-go/glm-5", "opencode-go/minimax-m2.5" ] }, "models": { "openai-codex/gpt-5.4": { "alias": "gpt54" }, "opencode-go/kimi-k2.5": { "alias": "Kimi" }, "opencode-go/glm-5": { "alias": "GLM" }, "opencode-go/minimax-m2.5": { "alias": "MiniMax" } } } } }

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

I already verified the following:

  • openclaw config validate passes
  • openclaw gateway restart succeeds
  • the intended models are present in agents.defaults.models
  • the config file is valid
  • each provider works correctly when it is the current/default provider
  • the failure appears specifically when switching across providers

Commands used during validation:

openclaw config validate
openclaw gateway restart
openclaw config get agents.defaults.models
openclaw config get agents.defaults.model

This makes me suspect the issue is in model resolution or session/provider state handling, not just in the UI.

It looks like the selected model is being resolved under the current/default provider namespace instead of respecting the explicit full provider/model ref.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    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