openclaw - ✅(Solved) Fix [Bug]: Ollama integration issues: context window ignored + tool support blocking local models [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#68344Fetched 2026-04-18 05:53:10
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2cross-referenced ×1

Hi OpenClaw team,

I wanted to report a set of issues I encountered while trying to use OpenClaw with a local Ollama setup. I’m documenting this step-by-step so it’s easy to reproduce.

Environment macOS (Apple Silicon) OpenClaw v2026.4.15 Ollama (local, default port 127.0.0.1:11434) Model: llama3 (custom variant with increased context) Issue 1 — Context window mismatch

I created a custom Ollama model with:

FROM llama3:latest PARAMETER num_ctx 32768

Verified in Ollama:

ollama run llama3-32k:latest /show info → context length: 32768

However, OpenClaw still reports:

openclaw models list → ollama/llama3-32k:latest … 8k

And the agent fails with:

Model context window too small (8192 tokens). Minimum is 16000.

This suggests OpenClaw is not detecting or respecting the overridden num_ctx value from Ollama.

Issue 2 — Ollama provider requires API key

OpenClaw would not properly use Ollama until I set:

export OLLAMA_API_KEY="ollama-local"

This is confusing because:

Ollama is local and does not require authentication The error message implies authentication is required

It would help if this were either:

optional, or clearly documented as a registration flag rather than actual authentication Issue 3 — Tool support blocking usage

After resolving context issues, I encountered:

does not support tools

This prevents using the model in the default chat/agent UI.

From what I can tell:

OpenClaw assumes tool-capable models Ollama models like llama3 do not support tools There is no fallback to plain text / non-tool mode

This effectively blocks using OpenClaw with local models for simple generation tasks.

Overall impact

At the moment, a local Ollama workflow in OpenClaw is difficult because:

Context overrides are not recognized Provider requires a dummy API key Non-tool models are rejected by the agent system

This makes it hard to use OpenClaw for basic local inference (e.g., content generation) without switching to cloud providers.

Suggestions Detect and respect num_ctx overrides from Ollama Clarify or remove the OLLAMA_API_KEY requirement for local mode Add a fallback “no tools / plain inference” mode in the UI Allow non-tool models to work in chat for simple use cases

Error Message

The error message implies authentication is required The error message implies authentication is required

Root Cause

This is confusing because:

Fix Action

Fixed

PR fix notes

PR #68349: Ollama: honor Modelfile num_ctx and auto-detect tool support

Description (problem / solution / changelog)

Summary

  • Problem: On a local Ollama setup, a Modelfile PARAMETER num_ctx 32768 override was ignored during discovery (only the base model's .context_length was read), which tripped context-window-guard with "Model context window too small (8192 tokens)". Non-tool models (e.g. plain llama3) also hit "does not support tools" with no auto-fallback, even though Ollama already reports capabilities on /api/show.
  • Why it matters: Local Ollama is a supported provider and these two gaps made common local setups (large-context custom Modelfiles, non-tool base models) fail out of the box. Issue #68344 captured both, plus a third point (OLLAMA_API_KEY requirement) that is already addressed at HEAD via DEFAULT_API_KEY = "ollama-local" / OLLAMA_LOCAL_AUTH_MARKER — so that part is a docs clarification only.
  • What changed:
    • queryOllamaModelShowInfo now also parses Ollama's parameters string from /api/show and lets a positive num_ctx <value> override win over model_info[*.context_length] (last-wins, matching Ollama's own generation-time semantics).
    • buildOllamaModelDefinition now auto-sets compat.supportsTools: false when /api/show returns a non-empty capabilities array that does not include "tools". Models with missing or empty capabilities keep compat undefined (existing permissive default).
    • Docs: added a Modelfile num_ctx note to the Context windows accordion, added a Tool support row to the implicit-discovery capability table, and clarified that OLLAMA_API_KEY is optional for local-only setups (reachable local hosts rely on the synthetic local auth marker).
    • Setup: bumped the synthetic pre-discovery capability fallback for kimi-k2.5:cloud from ["vision"] to ["vision", "tools"] so the new capability-driven compat gate does not wrongly flag Kimi as non-tool-supporting during cloud onboarding before its first /api/show refresh.
  • What did NOT change (scope boundary):
    • No change to OLLAMA_DEFAULT_CONTEXT_WINDOW, OLLAMA_DEFAULT_MAX_TOKENS, DEFAULT_API_KEY, SSRF policy, reachability checks, or the fetch/timeout contract on /api/show.
    • No change to supportsModelTools gating logic in core — only the discovered compat payload shape.
    • No change to config schema, Plugin SDK public surface, generated baselines, or CODEOWNERS-protected surfaces.

Change Type (select all)

  • Bug fix
  • Docs

Scope (select all touched areas)

  • Integrations

Linked Issue/PR

  • Closes #68344
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause (num_ctx): queryOllamaModelShowInfo only inspected model_info[*.context_length] from Ollama's /api/show. The real user-authored override lives in the separate parameters string (multi-line Modelfile params), which was never read. Base-model context_length therefore beat a user's larger num_ctx 32768, and downstream context-window-guard blocked the run.
  • Root cause (tool support): buildOllamaModelDefinition already consumed the capabilities array from /api/show for vision detection but ignored the tools bit, so non-tool models required manual compat.supportsTools: false. Ollama's own capability signal is authoritative here.
  • Missing detection / guardrail: no test case covered the parameters override path on /api/show, and no test exercised capability-based tool-support detection for discovered models.
  • Contributing context: docs recommended setting compat.supportsTools: false by hand for non-tool local models and did not mention Modelfile overrides at all; OLLAMA_API_KEY="ollama-local" was presented as mandatory when it is actually just a compatibility placeholder.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: extensions/ollama/src/provider-models.test.ts
  • Scenario the test should lock in:
    • PARAMETER num_ctx 32768 in /api/show parameters beats llama.context_length: 8192 (and handles repeat/last-wins plus malformed values).
    • Capabilities without "tools" set compat.supportsTools: false; capabilities with "tools" leave compat undefined; missing or empty capabilities preserve the existing permissive default.
  • Why this is the smallest reliable guardrail: these are pure data-shape mappings in a single helper, with no network/FS coupling; unit coverage in the same file as the existing enrichment tests is exactly the right level and stays fast in pnpm test:extension ollama.
  • Existing test that already covers this (if any): none — prior tests only exercised model_info[*.context_length] and vision capability detection.

User-visible / Behavior Changes

  • Local/self-hosted Ollama models created with a Modelfile PARAMETER num_ctx <value> override now report that context window in openclaw models list and stop hitting Model context window too small (8192 tokens) when the override is large enough.
  • Discovered Ollama models whose /api/show capabilities omit tools now get compat.supportsTools: false automatically and no longer fail tool-capable flows with "does not support tools"; tool-capable models behave exactly as before.
  • Docs-only: Ollama provider page now documents Modelfile num_ctx behavior, the tools capability auto-flag, and that OLLAMA_API_KEY is optional for local-only setups.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No — same /api/show endpoint, same fetchWithSsrFGuard policy, same per-host allowlist, same timeout.
  • Command/tool execution surface changed? No — supportsModelTools gating in core is unchanged; only the auto-populated compat.supportsTools value flows through the existing check.
  • Data access scope changed? No.
  • Behavior is runtime-enforced, not prompt-derived: parseOllamaNumCtxParameter is a pure regex/integer extractor (^num_ctx\s+(-?\d+)\b) that drops non-positive and non-finite values; the result is used only as a numeric context budget. compat.supportsTools: false is consumed by the existing runtime helper (src/agents/model-tool-support.ts) to skip sending tool schemas — not by any prompt text.

Repro + Verification

Environment

  • OS: macOS 25.3.0 (Apple Silicon)
  • Runtime/container: local repo, pnpm + Vitest
  • Model/provider: Ollama local (http://127.0.0.1:11434)
  • Integration/channel (if any): none
  • Relevant config (redacted): default

Steps

  1. Create a Modelfile: FROM llama3:latest / PARAMETER num_ctx 32768; ollama create llama3-32k -f ....
  2. Run openclaw models list --provider ollama.
  3. Start a chat against ollama/llama3-32k:latest.

Expected

  • Model listed with contextWindow = 32768.
  • Non-tool-capable base models work for plain chat without a manual compat.supportsTools: false entry.

Actual (before fix)

  • Model listed at 8192, run blocked with Model context window too small (8192 tokens; source=model). Minimum is 16000..
  • Non-tool models return does not support tools until the user edits config.

Evidence

Exact tests run locally on this branch:

  • pnpm vitest run extensions/ollama/src/provider-models.test.ts → 12 passed (4 new)
  • pnpm vitest run src/agents/models-config.providers.ollama.test.ts → 13 passed (regression baseline unchanged)
  • pnpm test:extension ollama → 118 passed across 10 files
  • pnpm test:contracts:plugins → 364 passed across 82 files
  • pnpm exec oxlint extensions/ollama/src/provider-models.ts extensions/ollama/src/provider-models.test.ts extensions/ollama/src/setup.ts → 0 warnings, 0 errors
  • pnpm format:check on all 5 touched files → clean after pnpm format

Note: pnpm tsgo surfaces pre-existing errors in extensions/qa-lab/src/providers/aimock/server.ts on plain origin/main (verified by re-running against the stashed baseline); those are unrelated to this change.

Human Verification (required)

  • Verified scenarios: num_ctx override wins over model_info; repeat num_ctx lines pick the last positive integer; malformed or non-positive num_ctx values fall back to the base context_length; capabilities without tools produce compat.supportsTools: false; capabilities with tools and missing capabilities leave compat undefined; existing capability-driven visioninput: ["text", "image"] behavior unchanged; setup-time Kimi cloud seed still presents as vision + tool capable so its persisted config is unchanged; all 10 existing ollama extension test files remain green.
  • Edge cases checked: empty/whitespace parameters string, repeated num_ctx (last-wins), negative/zero num_ctx, parameters not a string, capabilities present but empty, capabilities missing entirely.
  • What I did not verify: a live Ollama host call; behavior is covered by the new unit tests against mocked /api/show responses that mirror Ollama's real payload shape.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes — discovered Ollama configs without Modelfile overrides or capability arrays behave exactly as before.
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: An Ollama build reports capabilities: ["completion"] for a model that actually does support tools, causing OpenClaw to skip tool schemas for it.
    • Mitigation: matches Ollama's own advertised capability; users can still override explicitly by configuring models.providers.ollama.models[].compat.supportsTools: true. We only act on a non-empty capabilities array — the old permissive default still applies when capabilities are missing.
  • Risk: parameters parsing misinterprets a future Ollama field value.
    • Mitigation: parser requires ^num_ctx\s+<int> with a positive value after Number.parseInt, rejects malformed lines, and only overrides the computed contextWindow when the parsed value is a finite positive integer; tested against the three main Modelfile shapes plus malformed input.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • docs/providers/ollama.md (modified, +23/-10)
  • extensions/ollama/src/provider-models.test.ts (modified, +90/-0)
  • extensions/ollama/src/provider-models.ts (modified, +43/-0)
  • extensions/ollama/src/setup.ts (modified, +4/-2)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Hi OpenClaw team,

I wanted to report a set of issues I encountered while trying to use OpenClaw with a local Ollama setup. I’m documenting this step-by-step so it’s easy to reproduce.

Environment macOS (Apple Silicon) OpenClaw v2026.4.15 Ollama (local, default port 127.0.0.1:11434) Model: llama3 (custom variant with increased context) Issue 1 — Context window mismatch

I created a custom Ollama model with:

FROM llama3:latest PARAMETER num_ctx 32768

Verified in Ollama:

ollama run llama3-32k:latest /show info → context length: 32768

However, OpenClaw still reports:

openclaw models list → ollama/llama3-32k:latest … 8k

And the agent fails with:

Model context window too small (8192 tokens). Minimum is 16000.

This suggests OpenClaw is not detecting or respecting the overridden num_ctx value from Ollama.

Issue 2 — Ollama provider requires API key

OpenClaw would not properly use Ollama until I set:

export OLLAMA_API_KEY="ollama-local"

This is confusing because:

Ollama is local and does not require authentication The error message implies authentication is required

It would help if this were either:

optional, or clearly documented as a registration flag rather than actual authentication Issue 3 — Tool support blocking usage

After resolving context issues, I encountered:

does not support tools

This prevents using the model in the default chat/agent UI.

From what I can tell:

OpenClaw assumes tool-capable models Ollama models like llama3 do not support tools There is no fallback to plain text / non-tool mode

This effectively blocks using OpenClaw with local models for simple generation tasks.

Overall impact

At the moment, a local Ollama workflow in OpenClaw is difficult because:

Context overrides are not recognized Provider requires a dummy API key Non-tool models are rejected by the agent system

This makes it hard to use OpenClaw for basic local inference (e.g., content generation) without switching to cloud providers.

Suggestions Detect and respect num_ctx overrides from Ollama Clarify or remove the OLLAMA_API_KEY requirement for local mode Add a fallback “no tools / plain inference” mode in the UI Allow non-tool models to work in chat for simple use cases

Steps to reproduce

Steps to reproduce Install and run Ollama locally on macOS (default at http://127.0.0.1:11434)

Pull base model:

ollama pull llama3

Create a custom model with increased context:

cat > ~/Modelfile <<'EOF' FROM llama3:latest PARAMETER num_ctx 32768 EOF

ollama create llama3-32k -f ~/Modelfile

Verify context in Ollama:

ollama run llama3-32k:latest /show info

→ confirms context length is 32768

Configure OpenClaw to use the model:

openclaw config set gateway.mode local openclaw config set agents.defaults.model.primary "ollama/llama3-32k:latest"

Set Ollama provider flag (required to proceed):

export OLLAMA_API_KEY="ollama-local"

Start OpenClaw:

openclaw gateway

In a separate terminal:

openclaw dashboard

Observe model detection:

openclaw models list

→ shows ollama/llama3-32k:latest … 8k

Attempt to send a message in the UI Result

Agent fails with:

Model context window too small (8192 tokens). Minimum is 16000.

In some cases also:

does not support tools Expected behavior OpenClaw should detect the overridden num_ctx = 32768 Model should be usable for basic chat/inference without requiring tool support

Expected behavior

Be able to use the Ollama Model with Openclaw

Actual behavior

Hi OpenClaw team,

I wanted to report a set of issues I encountered while trying to use OpenClaw with a local Ollama setup. I’m documenting this step-by-step so it’s easy to reproduce.

Environment macOS (Apple Silicon) OpenClaw v2026.4.15 Ollama (local, default port 127.0.0.1:11434) Model: llama3 (custom variant with increased context) Issue 1 — Context window mismatch

I created a custom Ollama model with:

FROM llama3:latest PARAMETER num_ctx 32768

Verified in Ollama:

ollama run llama3-32k:latest /show info → context length: 32768

However, OpenClaw still reports:

openclaw models list → ollama/llama3-32k:latest … 8k

And the agent fails with:

Model context window too small (8192 tokens). Minimum is 16000.

This suggests OpenClaw is not detecting or respecting the overridden num_ctx value from Ollama.

Issue 2 — Ollama provider requires API key

OpenClaw would not properly use Ollama until I set:

export OLLAMA_API_KEY="ollama-local"

This is confusing because:

Ollama is local and does not require authentication The error message implies authentication is required

It would help if this were either:

optional, or clearly documented as a registration flag rather than actual authentication Issue 3 — Tool support blocking usage

After resolving context issues, I encountered:

does not support tools

This prevents using the model in the default chat/agent UI.

From what I can tell:

OpenClaw assumes tool-capable models Ollama models like llama3 do not support tools There is no fallback to plain text / non-tool mode

This effectively blocks using OpenClaw with local models for simple generation tasks.

Overall impact

At the moment, a local Ollama workflow in OpenClaw is difficult because:

Context overrides are not recognized Provider requires a dummy API key Non-tool models are rejected by the agent system

This makes it hard to use OpenClaw for basic local inference (e.g., content generation) without switching to cloud providers.

Suggestions Detect and respect num_ctx overrides from Ollama Clarify or remove the OLLAMA_API_KEY requirement for local mode Add a fallback “no tools / plain inference” mode in the UI Allow non-tool models to work in chat for simple use cases

OpenClaw version

latest

Operating system

macOS m2 2022

Install method

terminal

Model

ollama

Provider / routing chain

openclaw

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

To resolve the issues with using OpenClaw with a local Ollama setup, update OpenClaw to detect and respect the overridden num_ctx value from Ollama, clarify or remove the OLLAMA_API_KEY requirement for local mode, and add a fallback for non-tool models.

Guidance

  1. Verify Ollama Configuration: Ensure that the custom Ollama model with increased context (num_ctx 32768) is correctly configured and recognized by Ollama itself, as shown by the /show info command.
  2. Check OpenClaw Documentation: Review OpenClaw's documentation to see if there are any specific settings or configurations needed to properly detect and use the overridden num_ctx value from Ollama.
  3. Test Without Tool Support: Attempt to use the model in a plain text or non-tool mode to see if OpenClaw can handle models without tool support, potentially bypassing the "does not support tools" error.
  4. Investigate OLLAMA_API_KEY Requirement: Look into why OLLAMA_API_KEY is required for local mode and if there's an option to make it optional or clearly document it as a registration flag rather than an authentication requirement.

Example

No specific code example is provided due to the nature of the issue, which seems to be more about configuration and compatibility between OpenClaw and Ollama rather than a coding problem.

Notes

The solution may involve updates to OpenClaw to better support local Ollama models, especially regarding context window detection and tool support. The OLLAMA_API_KEY requirement for local setups seems unnecessary and could be clarified or removed.

Recommendation

Apply a workaround by manually configuring OpenClaw to recognize the custom num_ctx value and temporarily using a dummy OLLAMA_API_KEY until a more permanent solution is found, considering the potential need for updates to OpenClaw for full compatibility with local Ollama 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

Be able to use the Ollama Model with Openclaw

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 [Bug]: Ollama integration issues: context window ignored + tool support blocking local models [1 pull requests, 2 comments, 3 participants]