openclaw - ✅(Solved) Fix [Bug]: OpenClaw v2026.3.13 still sends Ollama an oversized context window (~262144 / 265k), ignoring configured lower limits [2 pull requests, 2 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#52206Fetched 2026-04-08 01:14:18
View on GitHub
Comments
2
Participants
2
Timeline
10
Reactions
1
Timeline (top)
referenced ×3commented ×2cross-referenced ×2labeled ×2

OpenClaw v2026.3.13 still appears to send an extremely large context window to Ollama (around 262144 / 265k), even when a much lower context size is configured.

This looks very similar to the previously reported issue about OpenClaw forcing or propagating an oversized context window to Ollama. Although that issue was marked as fixed, I can still reproduce the behavior on the latest version.

Root Cause

OpenClaw v2026.3.13 still appears to send an extremely large context window to Ollama (around 262144 / 265k), even when a much lower context size is configured.

This looks very similar to the previously reported issue about OpenClaw forcing or propagating an oversized context window to Ollama. Although that issue was marked as fixed, I can still reproduce the behavior on the latest version.

Fix Action

Fixed

PR fix notes

PR #52392: fix: respect user-configured context window for Ollama native API

Description (problem / solution / changelog)

Summary

  • Ollama stream function (ollama-stream.ts) was using model.contextWindow directly for num_ctx, which is the model's advertised maximum (e.g. 262144 for qwen3.5)
  • This ignored user-configured limits set via models.providers.ollama.models[].contextWindow or agents.defaults.contextTokens
  • Result: massive VRAM usage making local Ollama impractical on consumer hardware

Fix

  • createOllamaStreamFn and createConfiguredOllamaStreamFn now accept an optional contextTokensOverride parameter
  • attempt.ts resolves the effective context window through resolveContextWindowInfo (which already existed and handles the config priority chain) before passing it to the Ollama stream
  • Override only applies when the user has explicitly configured a limit (modelsConfig or agentContextTokens source) — default behavior preserved for users without custom config

Test plan

  • New test: contextTokensOverride correctly sets num_ctx to 8192 instead of model's advertised 262144
  • Existing ollama-stream tests pass (32/32)
  • Existing attempt tests pass (45/45)
  • Context-window-guard tests pass (9/9)

Fixes #52206

🤖 Generated with Claude Code

Changed files

  • docs/guides/performance-tuning.md (added, +116/-0)
  • docs/guides/suppress-ollama-discovery.md (added, +84/-0)
  • extensions/moltassist/.gitignore (added, +1/-0)
  • extensions/moltassist/Cargo.lock (added, +1046/-0)
  • extensions/moltassist/Cargo.toml (added, +24/-0)
  • extensions/moltassist/README.md (added, +132/-0)
  • extensions/moltassist/src/board.rs (added, +120/-0)
  • extensions/moltassist/src/dispatch.rs (added, +89/-0)
  • extensions/moltassist/src/gene.rs (added, +104/-0)
  • extensions/moltassist/src/main.rs (added, +234/-0)
  • extensions/moltassist/src/manifest.rs (added, +93/-0)
  • extensions/moltassist/src/runner.rs (added, +223/-0)
  • extensions/moltassist/src/task.rs (added, +83/-0)
  • extensions/moltassist/src/verify.rs (added, +33/-0)
  • src/agents/cli-runner.ts (modified, +25/-12)
  • src/agents/models-config.providers.ollama-disable.test.ts (added, +47/-0)
  • src/agents/models-config.providers.ts (modified, +17/-0)
  • src/agents/ollama-stream.test.ts (modified, +40/-0)
  • src/agents/ollama-stream.ts (modified, +8/-2)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +15/-0)
  • src/config/types.models.ts (modified, +12/-0)

PR #52402: fix: respect user-configured context window for Ollama native API

Description (problem / solution / changelog)

Summary

  • Ollama stream function (ollama-stream.ts) was using model.contextWindow directly for num_ctx, which is the model's advertised maximum (e.g. 262144 for qwen3.5)
  • This ignored user-configured limits set via models.providers.ollama.models[].contextWindow or agents.defaults.contextTokens
  • Result: massive VRAM usage making local Ollama impractical on consumer hardware

Fix

  • createOllamaStreamFn and createConfiguredOllamaStreamFn now accept an optional contextTokensOverride parameter
  • attempt.ts resolves the effective context window through resolveContextWindowInfo before passing it to the Ollama stream
  • Override only applies for explicit user-configured sources (modelsConfig or agentContextTokens) — default behavior preserved

Changes

  • src/agents/ollama-stream.ts — add contextTokensOverride param, use it for num_ctx
  • src/agents/ollama-stream.test.ts — new test: override sets num_ctx to 8192 instead of model's 262k
  • src/agents/pi-embedded-runner/run/attempt.ts — resolve context via resolveContextWindowInfo, pass override

Test plan

  • New test: contextTokensOverride correctly overrides num_ctx
  • Existing ollama-stream tests pass (32/32)
  • Context-window-guard tests pass (9/9)
  • Clean rebase on latest main — no conflicts

Fixes #52206

🤖 Generated with Claude Code

Changed files

  • pnpm-lock.yaml (modified, +2/-0)
  • src/agents/ollama-stream.test.ts (modified, +119/-0)
  • src/agents/ollama-stream.ts (modified, +8/-2)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +23/-3)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

Summary

OpenClaw v2026.3.13 still appears to send an extremely large context window to Ollama (around 262144 / 265k), even when a much lower context size is configured.

This looks very similar to the previously reported issue about OpenClaw forcing or propagating an oversized context window to Ollama. Although that issue was marked as fixed, I can still reproduce the behavior on the latest version.

Environment

  • OpenClaw version: v2026.3.13
  • Ollama version: latest available on my system
  • OS: Windows (with WSL2 in my setup)
  • Backend: Ollama local
  • Models tested: multiple Ollama local models

Problem

When OpenClaw uses a local Ollama model, Ollama appears to receive/use a context window around 262144 / 265k instead of the lower value I configured.

This causes very high VRAM usage and makes local usage impractical on my hardware.

What would help

It would help to know:

  1. which exact config field currently controls the context sent to Ollama,
  2. whether there are multiple code paths for Ollama integration,
  3. and whether OpenClaw is intentionally reading the model's maximum advertised context and overriding the user value.

If needed, I can provide my configuration and logs.

Steps to reproduce

Steps to reproduce

  1. Install and run OpenClaw v2026.3.13
  2. Configure a local Ollama model in OpenClaw
  3. Set a lower context value in the OpenClaw configuration/UI
  4. Start a chat/task through OpenClaw
  5. Inspect Ollama behavior / logs / VRAM usage
  6. Observe that the effective context still appears to be around 262144 / 265k

Additional notes

  • I am seeing this on the latest version, so from my side the issue does not appear fully resolved.
  • This may be:
    • a regression,
    • a code path that still ignores the configured limit,
    • or OpenClaw using the model's advertised contextWindow instead of the user-configured effective context size.

Expected behavior

Expected behavior

OpenClaw should respect the configured context limit and pass that effective lower limit to Ollama.

For example, if I configure a smaller context such as 4096, 8192, or another lower value, Ollama should actually use that value instead of defaulting to ~262144.

Actual behavior

Actual behavior

Even after configuring a lower context, Ollama still appears to load/use a huge context window (262144 / 265k).

Symptoms include:

  • very high VRAM usage
  • local models loading with an unexpectedly large KV/cache allocation
  • behavior consistent with OpenClaw passing Ollama the model-advertised max context instead of the user-configured effective limit

OpenClaw version

2026.3.13

Operating system

Windows 11 (WSL2)

Install method

No response

Model

qwen3.5

Provider / routing chain

Openclaw and Ollama (local)

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 of OpenClaw sending an extremely large context window to Ollama, we need to ensure that the configured context size is respected and passed to Ollama.

Here are the steps:

  • Check the OpenClaw configuration file for the context size field and verify that it is set to the desired lower value.
  • Review the OpenClaw code to see if there are multiple code paths for Ollama integration that might be overriding the user-configured context size.
  • If necessary, modify the OpenClaw code to use the user-configured context size instead of the model's maximum advertised context.

Example code snippet to set the context size:

# Set the context size to the user-configured value
context_size = 4096  # or any other desired lower value
ollama_config = {"context_window": context_size}
  • Update the OpenClaw configuration to use the ollama_config dictionary when calling Ollama.

Verification

To verify that the fix worked:

  • Run OpenClaw with the updated configuration and code changes.
  • Inspect Ollama behavior, logs, and VRAM usage to ensure that the effective context size is now the configured lower value.
  • Test with different context sizes to confirm that OpenClaw is respecting the user-configured limit.

Extra Tips

  • Make sure to test the fix with different models and configurations to ensure that it works consistently.
  • Consider adding logging or debugging statements to the OpenClaw code to help identify any issues with the context size configuration.
  • If you're still experiencing issues, try resetting the OpenClaw configuration to its default values and then re-applying the desired changes.

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

OpenClaw should respect the configured context limit and pass that effective lower limit to Ollama.

For example, if I configure a smaller context such as 4096, 8192, or another lower value, Ollama should actually use that value instead of defaulting to ~262144.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING