OpenClaw Hits 33K Context Limit: How to Fix It

✍️ OpenClawRadar📅 Published: August 18, 2026🔗 Source
Ad

A developer on r/openclaw reports a persistent 33K token context cap in OpenClaw, despite configuring a 262K context window. The issue affects every model they load locally, including Qwen3.8-27B, and appears to be outside OpenClaw's control.

What's Happening

The user set the context window correctly:

openclaw config set agents.defaults.contextWindow 262144

OpenClaw acknowledges the model supports 262144 tokens, but responses degrade after ~33K tokens, forcing frequent /compact or /new commands on Telegram. Running ollama ps reveals the model only has a 33K context loaded, regardless of the model's native capacity.

Root Cause

The problem is likely in Ollama, not OpenClaw. Ollama defaults to a context size (often 4096 or 8192) unless overridden via the OLLAMA_CONTEXT_LENGTH environment variable or the num_ctx parameter in Modelfile. OpenClaw doesn't pass the context length to Ollama, so Ollama loads with a small window.

Ad

Solutions

  • Set OLLAMA_CONTEXT_LENGTH: Before starting Ollama, set the environment variable to 262144.
    export OLLAMA_CONTEXT_LENGTH=262144
  • Update Modelfile: If you're using a custom model, add the parameter
    PARAMETER num_ctx 262144
    and recreate the model.
  • Check Docker: If Ollama runs in Docker, ensure the environment variable is passed via docker run -e OLLAMA_CONTEXT_LENGTH=262144.

Additional Notes

You can verify the loaded context with ollama ps — it should show the new size after the fix. Also, consider using Ollama's OpenAI-compatible endpoint with num_ctx in the request, which some clients support.

For more details, check the source discussion.

📖 Read the full source: r/openclaw

Ad

👀 See Also