Skip to content

fix(higress): strip provider prefix from extra-provider model names - #8

Merged
nattiini45 merged 1 commit into
mainfrom
fix/extra-provider-model-prefix-strip
Jul 17, 2026
Merged

fix(higress): strip provider prefix from extra-provider model names#8
nattiini45 merged 1 commit into
mainfrom
fix/extra-provider-model-prefix-strip

Conversation

@nattiini45

Copy link
Copy Markdown
Owner

What this fixes

OpenAI-compatible upstreams (Ollama Cloud, MiMo, Vanchin/StreamLake) reject model names carrying the <provider>/ routing prefix with a 404 — they expect the bare upstream name (e.g. gpt-oss:120b, not ollama/gpt-oss:120b). The extra-provider AI routes created by setup-higress.sh matched on the prefixed name for routing but left modelMapping empty, so the prefixed name was forwarded upstream unchanged. This is the OpenClaw bug #67435 / #72353 pattern applied to custom openai-type providers.

The fix

Each extra-provider AI route now carries a regex modelMapping:

"modelMapping": {"~^<provider>/(.+)$":"$1"}

This strips the <provider>/ prefix before the upstream call, while the route's modelPredicate still matches the prefixed name for routing. Applied to both the POST (new route) and PUT (upgrade existing route) paths in setup-higress.sh.

How it was verified

  • Higress ai-proxy source (provider.go:getMappedModel): supports ~regex keys with $1 capture via Go's regexp.ReplaceAllString. Confirmed by reading the source.
  • Simulated with real Go regexp semantics (not Python's \1):
    • ollama/gpt-oss:120bgpt-oss:120b
    • ollama/glm-5.2glm-5.2
    • ollama/kimi-k2.7-codekimi-k2.7-code
    • mimo/mimo-v2.5-promimo-v2.5-pro
    • vanchin/kat-coder-pro-v2kat-coder-pro-v2
    • vanchin/kat-coder-pro-v2.5kat-coder-pro-v2.5
  • bash -n setup-higress.sh — syntax valid
  • go build ./... — compiles clean
  • go vet ./... — clean
  • go test ./internal/agentconfig/... — passes
  • Generated route JSON — validated

Model catalog (also fixed)

Updated the 3 source spots (known-models.json, manager-openclaw.json.tmpl, agentconfig/generator.go presets + lists) with the real provider model IDs and correct context windows / maxTokens. The prior provisional entries used ollama/gpt-oss:120b-cloud (the -cloud suffix doesn't exist upstream) and mimo/MiMo-V2.5-Pro (capitalized; MiMo's API wants lowercase mimo-v2.5-pro) — both would 404 even after this fix.

New entries:

  • ollama/gpt-oss:120b, ollama/glm-5.2, ollama/glm-5.1, ollama/kimi-k2.7-code
  • mimo/mimo-v2.5, mimo/mimo-v2.5-pro
  • vanchin/kat-coder-pro-v2 (reasoning:false, 32k max), vanchin/kat-coder-pro-v2.5 (reasoning:false, 64k max)

Files changed (4)

  • manager/scripts/init/setup-higress.shmodelMapping regex on POST + PUT paths
  • manager/configs/known-models.json — real model IDs, correct ctx/max
  • manager/configs/manager-openclaw.json.tmpl — same
  • hiclaw-controller/internal/agentconfig/generator.go — presets + lists

go vet clean, agentconfig tests pass.

🤖 This PR was generated by Rumi (Caspar's AI assistant) after live-verifying all 4 upstream providers against the actual APIs and confirming the root cause against the Higress source code.

OpenAI-compatible upstreams (Ollama Cloud, MiMo, Vanchin/StreamLake)
reject model names carrying the "<provider>/" routing prefix with a
404 — they expect the bare upstream name. The extra-provider routes
created by setup-higress.sh matched on the prefixed name for routing
but left modelMapping empty, so the prefixed name was forwarded
upstream unchanged. This is the OpenClaw bug #67435 / #72353 pattern
applied to custom openai-type providers.

Fix: each extra-provider AI route now carries a regex modelMapping
{"~^<provider>/(.+)$":"$1"} that strips the prefix before the upstream
call, while the route's modelPredicate still matches the prefixed name
for routing. Verified against Higress ai-proxy provider.go
(getMappedModel ~regex branch, re.ReplaceAllString expands $1) and
simulated for ollama/glm-5.2, mimo/mimo-v2.5-pro,
vanchin/kat-coder-pro-v2.5, etc.

Also update the model catalog (known-models.json,
manager-openclaw.json.tmpl, agentconfig/generator.go presets + lists)
to the real provider model IDs (plain, lowercase, no fake -cloud
suffix) with correct context windows and maxTokens — the prior
provisional entries used "ollama/gpt-oss:120b-cloud" / "mimo/MiMo-V2.5-Pro"
which never existed upstream and would 404 even after this fix.

- manager/scripts/init/setup-higress.sh: modelMapping regex on POST
  + PUT (upgrade) paths
- manager/configs/known-models.json: real model IDs, correct ctx/max
- manager/configs/manager-openclaw.json.tmpl: same
- hiclaw-controller/internal/agentconfig/generator.go: presets + lists

go vet clean, agentconfig tests pass.
@kilo-code-bot

kilo-code-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Clean fix that correctly strips the <provider>/ routing prefix from model names before forwarding to OpenAI-compatible upstreams. The regex ~^<provider>/(.+)$$1 is verified correct for Go's regexp.ReplaceAllString. Both POST (new route) and PUT (upgrade) paths are covered. Model catalog entries are consistent across all 3 catalog files (generator.go, known-models.json, manager-openclaw.json.tmpl).

Files Reviewed (4 files)
  • hiclaw-controller/internal/agentconfig/generator.go — model presets + lists updated
  • manager/configs/known-models.json — model catalog JSON
  • manager/configs/manager-openclaw.json.tmpl — model catalog template
  • manager/scripts/init/setup-higress.sh — modelMapping regex on POST + PUT paths

Reviewed by mimo-v2.5-pro · Input: 65.3K · Output: 15K · Cached: 386.9K

@nattiini45
nattiini45 merged commit 17d4134 into main Jul 17, 2026
10 checks passed
nattiini45 added a commit that referenced this pull request Jul 31, 2026
- CreateProviderRoute was creating AI routes with empty modelMapping,
  so prefixed model names (ollama/glm-5.2) were forwarded upstream
  unchanged and rejected with 404.
- Add the ~regex prefix-strip ({'~^<provider>/(.+)$':'$1'}) matching
  the existing fix in setup-higress.sh (PR #8), on both POST and PUT paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant