openclaw - ✅(Solved) Fix [Bug]: Control UI model picker prefixes openai/ when selecting Anthropic Claude → model not allowed [1 pull requests, 2 comments, 3 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#52061Fetched 2026-04-08 01:16:02
View on GitHub
Comments
2
Participants
3
Timeline
7
Reactions
0
Author
Timeline (top)
cross-referenced ×3commented ×2labeled ×2

Version OpenClaw: 2026.3.13 (commit 61d171a) OS: macOS (Apple Silicon) on Mac mini Browser: Safari Channel: Control UI (webchat) What I’m trying to do Switch the session model in the Control UI from OpenAI GPT to Anthropic Claude (e.g., anthropic/claude-sonnet-4-6). Configured models / aliases (CLI) openclaw models list shows Anthropic models configured and allowed, e.g.: anthropic/claude-sonnet-4-6 (alias Sonnet-4-6) anthropic/claude-opus-4-6 (alias Opus-4-6) anthropic/claude-haiku-4-5-20251001 (alias Haiku-4-5) openclaw models aliases list: Sonnet-4-6 -> anthropic/claude-sonnet-4-6 (etc.)

Error Message

Observe error banner/toast: Failed to set model: GatewayRequestError: model not allowed: openai/claude-sonnet-4-6

Root Cause

Version OpenClaw: 2026.3.13 (commit 61d171a) OS: macOS (Apple Silicon) on Mac mini Browser: Safari Channel: Control UI (webchat) What I’m trying to do Switch the session model in the Control UI from OpenAI GPT to Anthropic Claude (e.g., anthropic/claude-sonnet-4-6). Configured models / aliases (CLI) openclaw models list shows Anthropic models configured and allowed, e.g.: anthropic/claude-sonnet-4-6 (alias Sonnet-4-6) anthropic/claude-opus-4-6 (alias Opus-4-6) anthropic/claude-haiku-4-5-20251001 (alias Haiku-4-5) openclaw models aliases list: Sonnet-4-6 -> anthropic/claude-sonnet-4-6 (etc.)

Fix Action

Fix / Workaround

Actual The UI attempts to patch the session with openai/claude-sonnet-4-6 (wrong provider prefix), and gateway rejects it.

Gateway verbose log evidence
Running openclaw gateway run --verbose and reproducing shows:
CopyCopied!
[ws] ⇄ res ✗ sessions.patch ... errorCode=INVALID_REQUEST errorMessage=model not allowed: openai/claude-sonnet-4-6
Notes
Restarting gateway and clearing Safari site data did not resolve.
CLI shows Anthropic models configured/allowed; problem appears to be Control UI serialization of model IDs for non-OpenAI providers.

PR fix notes

PR #51381: fix(ui): prevent double-qualifying already-qualified model values

Description (problem / solution / changelog)

Summary

Problem: When switching models in the Control UI, resolveServerChatModelValue() blindly prepends the session's default provider to the model string — even when it's already provider-qualified (e.g. ollama/gpt-oss:120b-cloud). This produces invalid refs like anthropic/ollama/gpt-oss:120b-cloud, which the server rejects with model not allowed.

Why it matters: Users with multi-provider setups (Ollama + Anthropic, OpenRouter nested models) cannot switch models in the Control UI without hitting this error.

What changed:

  • Rewrote resolveServerChatModelValue() to use startsWith(provider + "/") guard instead of delegating to buildQualifiedChatModelValue
  • buildQualifiedChatModelValue() is unchanged — it remains a general-purpose builder
  • Added test cases for Together vendor-prefixed IDs, OpenRouter nested IDs, and already-qualified detection
  • Added chat-model-ref.test.ts to vitest include list

What did NOT change:

  • buildQualifiedChatModelValue() is untouched — this PR only changes the call site that resolves server-bound model values
  • normalizeChatModelOverrideValue(), formatChatModelDisplay(), buildChatModelOption() are untouched
  • No changes to server-side model resolution or validation

Change Type

  • Bug fix (non-breaking)

Scope

UI/DX (Control UI model picker)

Linked Issue

Closes #51139 Closes #51306 Closes #51809 Closes #52002 Closes #52061 Closes #52127 Closes #52173 Closes #52474

Security Impact

  • New permissions requested: none
  • Secrets handling changes: none
  • New network calls: none
  • New command/tool execution: none
  • Data access changes: none

Human Verification

I personally verified:

  • pnpm build passes
  • pnpm test -- ui/src/ui/chat-model-ref.test.ts — 8/8 tests pass (5 existing + 3 new)
  • New test: resolveServerChatModelValue("ollama/gpt-oss:120b-cloud", "anthropic") returns "ollama/gpt-oss:120b-cloud" (not "anthropic/ollama/gpt-oss:120b-cloud")
  • New test: resolveServerChatModelValue("openrouter/anthropic/claude-sonnet-4-6", "openrouter") preserves nested path

Evidence

Test Files  1 passed (1)
     Tests  8 passed (8)
  Duration  131ms

git diff --stat upstream/main...HEAD: 3 files changed, 18 insertions(+)

What I Did NOT Verify

  • Not verified: end-to-end in running Control UI with a real multi-provider gateway (tested via unit tests only)
  • Not verified: edge case where a model alias intentionally contains / but is not provider-qualified (no such case exists in the current codebase — createChatModelOverride already treats / as the qualified signal)

Failure Recovery

If this breaks in production:

  • Detection: Model picker shows wrong model or fails to match selected model
  • Rollback: Revert the single guard clause in resolveServerChatModelValue
  • Blast radius: Only affects model selection display/matching — no server-side impact

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 [email protected]

Changed files

  • ui/src/ui/chat-model-ref.test.ts (modified, +33/-0)
  • ui/src/ui/chat-model-ref.ts (modified, +16/-1)
  • vitest.config.ts (modified, +1/-0)

Code Example

Gateway verbose log evidence
Running openclaw gateway run --verbose and reproducing shows:
CopyCopied!
[ws] ⇄ res ✗ sessions.patch ... errorCode=INVALID_REQUEST errorMessage=model not allowed: openai/claude-sonnet-4-6
Notes
Restarting gateway and clearing Safari site data did not resolve.
CLI shows Anthropic models configured/allowed; problem appears to be Control UI serialization of model IDs for non-OpenAI providers.

Notes:
Restarting gateway and clearing Safari site data did not resolve.
CLI shows Anthropic models configured/allowed; problem appears to be Control UI serialization of model IDs for non-OpenAI providers.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Version OpenClaw: 2026.3.13 (commit 61d171a) OS: macOS (Apple Silicon) on Mac mini Browser: Safari Channel: Control UI (webchat) What I’m trying to do Switch the session model in the Control UI from OpenAI GPT to Anthropic Claude (e.g., anthropic/claude-sonnet-4-6). Configured models / aliases (CLI) openclaw models list shows Anthropic models configured and allowed, e.g.: anthropic/claude-sonnet-4-6 (alias Sonnet-4-6) anthropic/claude-opus-4-6 (alias Opus-4-6) anthropic/claude-haiku-4-5-20251001 (alias Haiku-4-5) openclaw models aliases list: Sonnet-4-6 -> anthropic/claude-sonnet-4-6 (etc.)

Steps to reproduce

Open Control UI in Safari In the model dropdown, select: claude-sonnet-4-6 · anthropic (middle-dot between name and provider) Observe error banner/toast: Failed to set model: GatewayRequestError: model not allowed: openai/claude-sonnet-4-6

Expected behavior

Expected Model switch succeeds and session model becomes anthropic/claude-sonnet-4-6.

Actual behavior

Actual The UI attempts to patch the session with openai/claude-sonnet-4-6 (wrong provider prefix), and gateway rejects it.

OpenClaw version

OpenClaw: 2026.3.13 (commit 61d171a)

Operating system

OS: macOS (Apple Silicon) on Mac mini

Install method

Mac app

Model

running openai by default, trying to add Claude as alternates

Provider / routing chain

openclaw

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Gateway verbose log evidence
Running openclaw gateway run --verbose and reproducing shows:
CopyCopied!
[ws] ⇄ res ✗ sessions.patch ... errorCode=INVALID_REQUEST errorMessage=model not allowed: openai/claude-sonnet-4-6
Notes
Restarting gateway and clearing Safari site data did not resolve.
CLI shows Anthropic models configured/allowed; problem appears to be Control UI serialization of model IDs for non-OpenAI providers.

Notes:
Restarting gateway and clearing Safari site data did not resolve.
CLI shows Anthropic models configured/allowed; problem appears to be Control UI serialization of model IDs for non-OpenAI providers.

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To fix the issue, we need to update the Control UI to correctly serialize model IDs for non-OpenAI providers.

  • Update the model-dropdown component to use the correct provider prefix when selecting a model.
  • Modify the patchSession function to use the alias instead of the modelId when updating the session model.

Example code:

// Update model-dropdown component
const handleModelSelect = (model) => {
  const { alias, provider } = model;
  const modelName = `${alias} · ${provider}`;
  // Use the correct provider prefix
  const modelId = `${provider}/${alias}`;
  // ...
};

// Update patchSession function
const patchSession = (sessionId, modelId) => {
  const { alias, provider } = getModelInfo(modelId);
  const correctModelId = `${provider}/${alias}`;
  // Use the correct modelId
  return fetch(`/sessions/${sessionId}`, {
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ model: correctModelId }),
  });
};

Verification

To verify the fix, follow these steps:

  • Restart the OpenClaw gateway and clear Safari site data.
  • Open the Control UI in Safari and select a non-OpenAI model (e.g., claude-sonnet-4-6 · anthropic).
  • Check the gateway verbose log for the correct model ID being used in the sessions.patch request.
  • Verify that the session model is updated correctly and the error banner is not displayed.

Extra Tips

  • Make sure to update the getModelInfo function to correctly parse the model ID and extract the provider and alias.
  • Consider adding a test case to ensure that the patchSession function works correctly for non-OpenAI models.

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

Expected Model switch succeeds and session model becomes anthropic/claude-sonnet-4-6.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING