-
-
Notifications
You must be signed in to change notification settings - Fork 57.4k
Closed
Description
Summary
OpenClaw's Ollama connector drops custom provider headers (e.g. X-OLLAMA-KEY) whenever the agent falls back to createOllamaStreamFn. Gateways behind HAProxy/TLS expect that header, otherwise the server replies 403 (Verification failed). Currently only direct REST calls (e.g. curl) work, because the CLI takes the header from the provider config; internal chat runs ignore it.
Impact
- Any OpenClaw deployment using a protected Ollama endpoint fails to run agents (403 errors on
/v1/chat/completions). - Admins can't finish the installer or start the gateway without manually editing bundled JS files.
- Affects all entry points (
reply-*.js,pi-embedded-*.js,subagent, plugin SDK) since they all callcreateOllamaStreamFn(baseUrl)with no headers.
Repro
- Configure a custom provider in
openclaw.json:{ "models": { "providers": { "ollama": { "baseUrl": "https://ollama.example.com/v1", "headers": { "X-OLLAMA-KEY": "SECRET" } } } } } - Start OpenClaw (
openclaw gateway). - Send any chat request.
- Ollama logs show
403because the header was never forwarded.
Direct curl with the header works:
curl -H "X-OLLAMA-KEY: SECRET" https://ollama.example.com/v1/modelsRoot Cause
createOllamaStreamFn(baseUrl) ignores provider headers. All agent runners only pass the base URL, so Ollama never receives auth tokens.
Proposed Fix
- Update
createOllamaStreamFn(in all bundled locations) to accept an optionaldefaultHeadersmap, merge it with per-request headers, and attach them to every fetch. - Pass
providerConfig?.headerswhenever a stream function is created:const providerConfig = cfg?.models?.providers?.[model.provider]; const ollamaBaseUrl = model.baseUrl || providerConfig?.baseUrl || OLLAMA_NATIVE_BASE_URL; agent.streamFn = createOllamaStreamFn(ollamaBaseUrl, providerConfig?.headers);
- Update the plugin SDK
.d.tsso third-party skills can also set headers.
Hotfix / Diff Summary
- Added
normalizeHeaderRecord()+defaultHeadersparameter in:dist/model-selection-*.jsdist/model-auth-*.jsdist/plugin-sdk/model-selection-*.jsdist/auth-profiles-*.js
- Patched all
activeSession.agent.streamFn = createOllamaStreamFn(...)calls to passproviderConfig?.headers(reply-*.js,pi-embedded-*.js,subagent-registry, plugin SDK). - Adjusted
plugin-sdk/agents/ollama-stream.d.tssignature.
Without this change, any secured Ollama server is unusable with OpenClaw.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels