openclaw - ✅(Solved) Fix [Bug]: Web gateway: OpenRouter model picker sends wrong model ref (missing openrouter/ prefix) → model not allowed [3 pull requests, 1 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#49379Fetched 2026-04-08 00:55:47
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
cross-referenced ×2labeled ×2referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #49694: test(ui): cover provider-qualified OpenRouter chat model refs

Description (problem / solution / changelog)

Summary

  • add regression coverage for provider-qualified OpenRouter chat model option values
  • assert session model resolution preserves nested model ids
  • assert the chat header picker patches sessions with the fully-qualified OpenRouter model ref

Closes #49379

Changed files

  • ui/src/ui/chat-model-ref.test.ts (modified, +16/-0)
  • ui/src/ui/views/chat.test.ts (modified, +40/-0)

PR #49760: Fix OpenRouter model picker sending wrong provider reference (#49379)

Description (problem / solution / changelog)

Summary

  • Fixes #49379: OpenRouter model picker in Control UI sends wrong model reference
  • When user selects an OpenRouter model from the Control UI dropdown (e.g., anthropic/claude-opus-4.6 · openrouter), the picker sends modelOverride: "anthropic/claude-opus-4.6" with providerOverride: "openrouter"
  • resolveSessionModelRef() was incorrectly parsing the model string through parseModelRef(), which split on / and extracted { provider: "anthropic" }, discarding the stored providerOverride="openrouter"
  • This caused "model not allowed" errors because users have no credentials for the anthropic provider when they intended to use OpenRouter

Root Cause

The issue was in resolveSessionModelRef() at src/gateway/session-utils.ts:796-810. When an explicit providerOverride was recorded, the code still parsed the modelOverride string through parseModelRef(), which incorrectly extracted the vendor prefix as the provider for OpenRouter's nested model IDs.

Fix

Modified resolveSessionModelRef() to check for an explicit providerOverride first. If present, use it directly without re-parsing the model string. This preserves the user's intended provider selection from the UI.

Test Plan

  • Added test case preserves openrouter providerOverride when modelOverride contains vendor prefix (#49379)
  • All existing tests pass (48 tests in session-utils.test.ts)
  • TypeScript compilation passes

🤖 Generated with Claude Code

Changed files

  • src/config/types.models.ts (modified, +23/-11)
  • src/gateway/session-utils.test.ts (modified, +64/-1)
  • src/gateway/session-utils.ts (modified, +15/-5)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

环境

  • OpenClaw 版本:(例如 2026.3.13,或 openclaw --version
  • 使用 Web 网关 / Control UI 选择模型

现象

在模型下拉里选择带「· openrouter」的项(例如 anthropic/claude-opus-4.6 · openrouter)后,设置失败: GatewayRequestError: model not allowed: anthropic/claude-opus-4.6

预期

从 OpenRouter 列表选择的模型应提交为 openrouter/anthropic/claude-opus-4.6(与 agents.defaults.models 白名单一致),或网关应把「OpenRouter 分区」的选项统一解析为 openrouter/<id>

实际

似乎只提交了 anthropic/claude-opus-4.6,被解析成 Anthropic 官方 provider,导致不在白名单内。

复现

  1. agents.defaults.models 中仅允许 openrouter/anthropic/claude-opus-4.6 等带 openrouter/ 前缀的键
  2. Web 网关下拉里点选 anthropic/claude-opus-4.6 · openrouter
  3. 报错 model not allowed

备注

命令行 /model openrouter/anthropic/claude-opus-4.6 可正常工作。

<img width="2148" height="854" alt="Image" src="https://github.com/user-attachments/assets/b363aeef-c5bd-41ac-9633-030af092ba2d" />

Steps to reproduce

正确的完整模型标识:openrouter/anthropic/claude-opus-4.6(provider = openrouter) ❌ UI 实际发送的:anthropic/claude-opus-4.6(provider = anthropic) OpenClaw 的规则是第一个 / 左边是 provider,所以 anthropic/claude-opus-4.6 会被解析为 provider=anthropic,model=claude-opus-4.6。如果你没有单独配置 anthropic 这个 provider(只配了 openrouter),那自然就报 "model not allowed"。

这是个 Web UI 的 bug——它在展示 OpenRouter 下的模型列表时,点选后没有把 openrouter/ 前缀拼回去就发给了后端。

Expected behavior

预期

从 OpenRouter 列表选择的模型应提交为 openrouter/anthropic/claude-opus-4.6(与 agents.defaults.models 白名单一致),或网关应把「OpenRouter 分区」的选项统一解析为 openrouter/<id>

Actual behavior

实际

似乎只提交了 anthropic/claude-opus-4.6,被解析成 Anthropic 官方 provider,导致不在白名单内。

OpenClaw version

2026.3.13

Operating system

macOS 26.3.1

Install method

No response

Model

minimax

Provider / routing chain

openclaw -> http-proxy -> openrouter

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To fix the issue, we need to modify the Web UI to include the openrouter/ prefix when submitting the model selection. Here are the steps:

  • Modify the Web UI code to parse the selected model and check if it belongs to the OpenRouter partition.
  • If it does, prepend the openrouter/ prefix to the model ID before submitting it to the backend.
  • Update the UI code to handle the modified model ID submission.

Example code snippet:

# Assuming 'model_id' is the selected model ID
if '· openrouter' in model_id:
    # Remove the '· openrouter' suffix and prepend the 'openrouter/' prefix
    model_id = 'openrouter/' + model_id.replace('· openrouter', '')
# Submit the modified model ID to the backend

Verification

To verify that the fix worked, follow these steps:

  • Select a model from the OpenRouter partition in the Web UI.
  • Check the submitted model ID in the backend logs or using a debugger.
  • Verify that the model ID now includes the openrouter/ prefix.

Extra Tips

  • Make sure to update the UI code to handle any potential errors or edge cases when modifying the model ID submission.
  • Consider adding a test case to ensure that the fix works correctly for different model selections and partitions.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING