openclaw - ✅(Solved) Fix Gateway prepends custom-provider prefix to /api/chat — follow-up to #67435 [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#72353Fetched 2026-04-27 05:31:08
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2closed ×1referenced ×1

Follow-up to #67435 (closed by #67457) — the fix in #67457 strips the literal "ollama/" prefix from model IDs in buildOllamaChatRequest, but the same bug class survives for custom-named Ollama-compatible providers (e.g. ollama-spark, ollama-studio2, ollama-remote). The custom provider name is still being prepended to the model field on outbound /api/chat requests, producing 404 {"error":"model '<provider>/<model>' not found"} at high volume in cron-fired contexts.

Filing as a separate issue rather than re-opening #67435 because the surface is broader: the strip in #67457 is hardcoded to "ollama/" rather than generalizing to any provider key.

Error Message

Follow-up to #67435 (closed by #67457) — the fix in #67457 strips the literal "ollama/" prefix from model IDs in buildOllamaChatRequest, but the same bug class survives for custom-named Ollama-compatible providers (e.g. ollama-spark, ollama-studio2, ollama-remote). The custom provider name is still being prepended to the model field on outbound /api/chat requests, producing 404 {"error":"model '<provider>/<model>' not found"} at high volume in cron-fired contexts. {"error":"model 'ollama-spark/qwen3:32b' not found"} The Ollama-side error format and sub-millisecond response latency matched the gateway's failure pattern verbatim during a passive packet-flow analysis (gateway log at one end + backend journalctl at the other) — same path (/api/chat), same source IP, same 404 latency profile, same error body shape.

Root Cause

Filing as a separate issue rather than re-opening #67435 because the surface is broader: the strip in #67457 is hardcoded to "ollama/" rather than generalizing to any provider key.

Fix Action

Fix / Workaround

In a 24h window before workaround was applied: 2,058 model_not_found events on /api/chat across the affected providers. Bursts of ~131 events per 30-min cron tick when ~18 cron-fired Maximus heartbeats fan out through the fallback chain.

Workaround currently in use: removed the affected models from custom-named providers' models arrays in openclaw.json so the broken routes never get tried. The fallback chain reaches anthropic/claude-haiku-4-5 instead. Volume of those specific 404s is now near-zero. Cost: cloud-cost on what should be a local route.

PR fix notes

PR #72368: fix(ollama): also strip custom-named ollama-compat provider prefixes (#72353)

Description (problem / solution / changelog)

Fixes #72353 (follow-up to #67457).

Summary

PR #67457 stripped the literal "ollama/" prefix from outbound chat model IDs in buildOllamaChatRequest, but the same bug class survives for custom-named ollama-compat providers (ollama-spark, ollama-studio2, ollama-remote, etc.) where the routing-side identifier arrives as <provider-key>/<model>. The Ollama backend responds with 404 {"error":"model '<provider>/<model>' not found"} on every /api/chat call.

The reporter measured 2,058 model_not_found events / 24h on a setup with two custom-named providers before applying a config-side workaround (cost: cloud-cost on what should be a local route).

Fix

Generalize both prefix strippers to a small regex ^ollama(?:-[a-zA-Z0-9_-]+)?\/:

  • normalizeOllamaWireModelId in extensions/ollama/src/stream.ts (chat path).
  • normalizeEmbeddingModel in extensions/ollama/src/embedding-provider.ts (embedding path — kept symmetric with chat so a follow-on bug there doesn't have to repeat the same investigation).

The pattern is conservative — it only strips ollama and ollama-<key> prefixes, leaving real Ollama registry namespaces such as library/llama3 untouched.

Tests

Added two regression tests in stream-runtime.test.ts:

  • ollama-spark/qwen3:32b, ollama-studio2/qwen3:32b, ollama-remote/llama3.2:8b → bare model name.
  • library/llama3 → unchanged (Ollama registry namespace survives).

Existing ollama/qwen3:14b-q8_0 → qwen3:14b-q8_0 test still passes.

Test Files  1 passed (1)
     Tests  49 passed (49)

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/ollama/src/embedding-provider.ts (modified, +2/-1)
  • extensions/ollama/src/stream-runtime.test.ts (modified, +24/-0)
  • extensions/ollama/src/stream.ts (modified, +9/-1)

Code Example

# Works (bare model name):
$ curl -s -X POST http://10.x.x.4:11434/api/chat \
    -H 'Content-Type: application/json' \
    -d '{"model":"qwen3:32b","messages":[{"role":"user","content":"ping"}],"stream":false}'
# HTTP 200, normal response

# Fails (mimics gateway sending the prefixed name):
$ curl -s -X POST http://10.x.x.4:11434/api/chat \
    -H 'Content-Type: application/json' \
    -d '{"model":"ollama-spark/qwen3:32b","messages":[{"role":"user","content":"ping"}],"stream":false}'
{"error":"model 'ollama-spark/qwen3:32b' not found"}
# HTTP 404, ~5ms latency (Ollama catalog miss fast path)
RAW_BUFFERClick to expand / collapse

Summary

Follow-up to #67435 (closed by #67457) — the fix in #67457 strips the literal "ollama/" prefix from model IDs in buildOllamaChatRequest, but the same bug class survives for custom-named Ollama-compatible providers (e.g. ollama-spark, ollama-studio2, ollama-remote). The custom provider name is still being prepended to the model field on outbound /api/chat requests, producing 404 {"error":"model '<provider>/<model>' not found"} at high volume in cron-fired contexts.

Filing as a separate issue rather than re-opening #67435 because the surface is broader: the strip in #67457 is hardcoded to "ollama/" rather than generalizing to any provider key.

Reproduction

# Works (bare model name):
$ curl -s -X POST http://10.x.x.4:11434/api/chat \
    -H 'Content-Type: application/json' \
    -d '{"model":"qwen3:32b","messages":[{"role":"user","content":"ping"}],"stream":false}'
# HTTP 200, normal response

# Fails (mimics gateway sending the prefixed name):
$ curl -s -X POST http://10.x.x.4:11434/api/chat \
    -H 'Content-Type: application/json' \
    -d '{"model":"ollama-spark/qwen3:32b","messages":[{"role":"user","content":"ping"}],"stream":false}'
{"error":"model 'ollama-spark/qwen3:32b' not found"}
# HTTP 404, ~5ms latency (Ollama catalog miss fast path)

The Ollama-side error format and sub-millisecond response latency matched the gateway's failure pattern verbatim during a passive packet-flow analysis (gateway log at one end + backend journalctl at the other) — same path (/api/chat), same source IP, same 404 latency profile, same error body shape.

Environment

  • OpenClaw: 2026.4.24 (cbcfdf6) — also reproduced on 2026.4.21 and 2026.4.22 prior to upgrade
  • Host: macOS 15.x, Apple Silicon
  • Affected providers in openclaw.json: ollama-spark, ollama-studio2 (custom-named, all "api": "ollama")
  • Routing fired from agent context (cron-isolated heartbeats fanning out through fallback chain)

Volume + impact

In a 24h window before workaround was applied: 2,058 model_not_found events on /api/chat across the affected providers. Bursts of ~131 events per 30-min cron tick when ~18 cron-fired Maximus heartbeats fan out through the fallback chain.

Workaround currently in use: removed the affected models from custom-named providers' models arrays in openclaw.json so the broken routes never get tried. The fallback chain reaches anthropic/claude-haiku-4-5 instead. Volume of those specific 404s is now near-zero. Cost: cloud-cost on what should be a local route.

Suspected root cause

PR #67457 added stripOllamaPrefix(modelId) (or equivalent) that pattern-matches the literal string "ollama/". For custom-named ollama providers, the upstream-keyed string is "ollama-spark/qwen3:32b" (or similar), which doesn't match the literal pattern and passes through to the request body unchanged.

Suggested generalization: strip <provider-key>/ for any provider whose effective api resolves to "ollama", not just the literal "ollama" provider key.

Tested not the cause

  • Ollama backend reachability — direct curl with bare name returns 200 from the same machine
  • Model name correctness — qwen3:32b is the exact name shown by ollama list on the backend
  • HTTP path — confirmed via backend journalctl that gateway hits /api/chat, same as my direct curl
  • Backend capacity — backend serves bare-name requests successfully even under parallel load (5x concurrent /api/chat with bare name → all 200)

Related

  • #67435 — original ollama/ prefix bug (CLOSED by #67457 on 2026-04-16)
  • #57811 — separate but related: No API provider registered for api: ollama in cron context (OPEN since 2026-03-30; works around by switching to api: openai-completions)
  • #52471 — Control UI sent wrong provider prefix ollama/ instead of ollama-remote/ (CLOSED 2026-04-25)

Suggested fix area

Wherever PR #67457 introduced the literal-ollama/ strip in buildOllamaChatRequest — generalize to strip any leading <provider-key>/ segment, gated on the resolved api being "ollama". The provider key is already known at request-build time (it's the routing key that delivered us into buildOllamaChatRequest). A regression test mirroring #67457's tests but with a custom-named ollama-remote (or similar) provider would lock this in.


Filed by DSS as a follow-up to a closed bug. Happy to provide additional logs, configuration, or coordinate with maintainers on testing a fix candidate.

extent analysis

TL;DR

Generalize the stripOllamaPrefix function to remove any leading <provider-key>/ segment for providers with an api resolving to "ollama".

Guidance

  • Identify the code location where stripOllamaPrefix was introduced in PR #67457 and modify it to strip any leading provider key.
  • Add a condition to check if the resolved api is "ollama" before stripping the provider key.
  • Create a regression test with a custom-named ollama-remote provider to ensure the fix works as expected.
  • Review the buildOllamaChatRequest function to ensure it correctly handles the generalized prefix stripping.

Example

function stripProviderPrefix(modelId, providerKey, api) {
  if (api === 'ollama') {
    return modelId.replace(`${providerKey}/`, '');
  }
  return modelId;
}

Notes

The suggested fix assumes that the provider key is known at request-build time and can be used to strip the prefix. Additional logging or debugging may be necessary to ensure the fix works correctly in all scenarios.

Recommendation

Apply the workaround by generalizing the stripOllamaPrefix function to handle custom-named Ollama providers, as this will fix the issue without introducing new dependencies or upgrades.

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

openclaw - ✅(Solved) Fix Gateway prepends custom-provider prefix to /api/chat — follow-up to #67435 [1 pull requests, 2 comments, 3 participants]