#Help needed: OpenClaw agent maxing out 200k context window

1 messages ยท Page 1 of 1 (latest)

warm yarrowBOT
finite stirrupBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> โœ… Mark Solution

warm yarrowBOT
fair fjordBOT
#

Iโ€™m checking the docs/source for how OpenClaw compacts history and whether this looks like a model/provider issue vs a config issue.

#

That sounds annoying. I think this is most likely tool-output bloat, not โ€œ200k is too smallโ€.

A few concrete things to check first:

  1. Paste your version

    openclaw --version
    
  2. Paste a status snapshot

    openclaw status --all
    
  3. In the chat/session that keeps bloating, run:

#
   /status
   /context detail

/context detail is the big one, it shows what is actually consuming tokens.

  1. Paste these config bits from openclaw.json:
    • models.providers.ollama.baseUrl
    • agents.defaults.contextPruning
    • agents.defaults.compaction

Two likely causes from the docs:

  • Session pruning is off by default for non-Anthropic providers, so with Ollama/Kimi, old tool results can pile up fast.
  • If your Ollama base URL uses /v1, that is wrong for OpenClaw and can break tool calling / dump raw tool JSON into history. It should be the native Ollama URL, for example:
#
  {
    models: {
      providers: {
        ollama: {
          baseUrl: "http://your-ollama-host:11434"
        }
      }
    }
  }

If pruning is missing, Iโ€™d try this first:

{
#
  agents: {
    defaults: {
      contextPruning: {
        mode: "cache-ttl",
        ttl: "5m",
        keepLastAssistants: 3,
        softTrimRatio: 0.3,
        hardClearRatio: 0.5,
        minPrunableToolChars: 50000,
        softTrim: { maxChars: 4000, headChars: 1500, tailChars: 1500 },
        hardClear: { enabled: true, placeholder: "[Old tool result content cleared]" }
      }
    }
  }
}
#

If you paste the version, status, /context detail, and those config bits, I can usually pinpoint it pretty fast.

half atlas
#
  1. OpenClaw 2026.4.22 (00bd2cf)
  2. Overview
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Item โ”‚ Value โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚ Version โ”‚ 2026.4.22 โ”‚
    โ”‚ OS โ”‚ linux 6.8.0-110-generic (x64) โ”‚
    โ”‚ Node โ”‚ 22.22.2 โ”‚
    โ”‚ Config โ”‚ ~/.openclaw/openclaw.json โ”‚
    โ”‚ Dashboard โ”‚ http://127.0.0.1:18789/ โ”‚
    โ”‚ Tailscale โ”‚ off โ”‚
    โ”‚ Channel โ”‚ stable (config) โ”‚
    โ”‚ Update โ”‚ pnpm ยท up to date ยท npm latest 2026.4.22 โ”‚
    โ”‚ Gateway โ”‚ local ยท ws://127.0.0.1:18789 (local loopback) ยท reachable 75ms ยท auth token ยท af853a79e598 (172. โ”‚
    โ”‚ โ”‚ 16.1.2) app 2026.4.22 linux 6.8.0-110-generic โ”‚
    โ”‚ Security โ”‚ Run: openclaw security audit --deep โ”‚
    โ”‚ Gateway self โ”‚ unknown โ”‚
    โ”‚ Gateway service โ”‚ systemd not installed โ”‚
#

Node service โ”‚ systemd not installed โ”‚
โ”‚ Agents โ”‚ 1 total ยท 0 bootstrapping ยท 0 active ยท 2 sessions โ”‚
โ”‚ Secrets โ”‚ none

#

Status:
๐Ÿฆž OpenClaw 2026.4.22 (00bd2cf)
๐Ÿง  Model: ollama/kimi-k2.6:cloud ยท ๐Ÿ”‘ unknown
๐Ÿงฎ Tokens: 235k in / 670 out
๐Ÿ“š Context: 59k/200k (30%) ยท ๐Ÿงน Compactions: 3
๐Ÿงต Session: agent:main:main โ€ข updated just now
โš™๏ธ Runtime: direct ยท Runner: pi (embedded) ยท Think: low
๐Ÿชข Queue: collect (depth 0)

Context detail:
๐Ÿง  Context breakdown (detailed)
Workspace: /data/.openclaw/workspace
Bootstrap max/file: 12,000 chars
Bootstrap max/total: 60,000 chars
Sandbox: mode=off sandboxed=false
System prompt (run): 35,729 chars (~8,933 tok) (Project Context 16,408 chars (~4,102 tok))
Injected workspace files:
โ€ข AGENTS.md: OK | raw 7,907 chars (~1,977 tok) | injected 7,907 chars (~1,977 tok)
โ€ข SOUL.md: OK | raw 2,677 chars (~670 tok) | injected 2,677 chars (~670 tok)
โ€ข TOOLS.md: OK | raw 952 chars (~238 tok) | injected 952 chars (~238 tok)
โ€ข IDENTITY.md: OK | raw 504 chars (~126 tok) | injected 504 chars (~126 tok)
โ€ข USER.md: OK | raw 905 chars (~227 tok) | injected 905 chars (~227 tok)
โ€ข HEARTBEAT.md: OK | raw 1,438 chars (~360 tok) | injected 1,438 chars (~360 tok)

#

โ€ข BOOTSTRAP.md: MISSING | raw 0 | injected 0
โ€ข MEMORY.md: OK | raw 3,203 chars (~801 tok) | injected 3,203 chars (~801 tok)
Skills list (system prompt text): 4,349 chars (~1,088 tok) (8 skills)
Skills: clawhub, healthcheck, himalaya, node-connect, skill-creator, taskflow, taskflow-inbox-triage, weather
Top skills (prompt entry size):
โ€ข skill-creator: 756 chars (~189 tok)
โ€ข taskflow: 540 chars (~135 tok)
โ€ข node-connect: 538 chars (~135 tok)
โ€ข healthcheck: 488 chars (~122 tok)
โ€ข clawhub: 429 chars (~108 tok)
โ€ข taskflow-inbox-triage: 415 chars (~104 tok)
โ€ข weather: 413 chars (~104 tok)
โ€ข himalaya: 380 chars (~95 tok)
Tool list (system prompt text): 0 chars (~0 tok)
Tool schemas (JSON): 25,136 chars (~6,284 tok) (counts toward context; not shown as text)
Tools: read, edit, write, exec, process, canvas, nodes, cron, message, tts, gateway, agents_list, sessions_list, sessions_history, sessions_send, sessions_spawn, sessions_yield, subagents, session_status, web_fetch, browser, memory_search, memory_get
Top tools (schema size):
โ€ข cron: 6,700 chars (~1,675 tok)
โ€ข message: 5,767 chars (~1,442 tok)
โ€ข browser: 2,799 chars (~700 tok)
โ€ข nodes: 1,589 chars (~398 tok)
โ€ข sessions_spawn: 1,333 chars (~334 tok)
โ€ข exec: 1,096 chars (~274 tok)
โ€ข process: 961 chars (~241 tok)
โ€ข edit: 834 chars (~209 tok)
โ€ข canvas: 661 chars (~166 tok)
โ€ข gateway: 537 chars (~135 tok)
โ€ข sessions_list: 432 chars (~108 tok)
โ€ข web_fetch: 374 chars (~94 tok)
โ€ข read: 304 chars (~76 tok)

fair fjordBOT
#

Nice, version looks current, so this is probably not a stale-build bug.

What Iโ€™d check next:

  1. Make sure Ollama is using the native API URL, not /v1
    {
      models: {
        providers: {
          ollama: {
            baseUrl: "http://your-ollama-host:11434"
          }
        }
      }
    }
    
    If you use ...:11434/v1, OpenClaw docs call that out as bad for tool calling, and it can dump ugly raw tool JSON into history.
#

Docs: https://docs.openclaw.ai/providers/ollama

  1. Enable session pruning explicitly
    For non-Anthropic setups, this is the first thing Iโ€™d try:
    {
      agents: {
        defaults: {
          contextPruning: {
            mode: "cache-ttl",
            ttl: "5m",
            keepLastAssistants: 3,
            softTrimRatio: 0.3,
            hardClearRatio: 0.5,
            minPrunableToolChars: 50000,
            softTrim: { maxChars: 4000, headChars: 1500, tailChars: 1500 },
    
#
           hardClear: { enabled: true, placeholder: "[Old tool result content cleared]" }
         }
       }
     }
   }

This trims old tool results before each LLM call, which is usually the real context killer.
Docs: https://docs.openclaw.ai/concepts/session-pruning

  1. Then start a fresh session

    /new
    

    If the current thread is already bloated, fixing config alone wonโ€™t magically make that history small.

  2. Paste this too

#
   /context detail

Thatโ€™s the fastest way to see whether the growth is:

  • tool results
  • giant bootstrap/system prompt
  • attachments/images
  • just a runaway long transcript

If you want, paste these 3 config sections and I can sanity-check them:

  • models.providers.ollama
  • agents.defaults.contextPruning
  • agents.defaults.compaction

Also useful docs:

half atlas
#

"providers": {
"ollama": {
"baseUrl": "http://172.16.1.1:32769",
"api": "ollama",
"apiKey": "ollama-local",
"models": [
{
"id": "kimi-k2.6:cloud",
"name": "kimi-k2.6:cloud",
"api": "ollama",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "nomic-embed-text",
"name": "nomic-embed-text",
"api": "ollama",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 2048,
"maxTokens": 2048

"defaults": {
"workspace": "/data/.openclaw/workspace",
"model": {
"primary": "ollama/kimi-k2.6:cloud"
},
"models": {
"ollama/kimi-k2.6:cloud": {
"alias": "kimi-k2.6"
}
},
"thinkingDefault": "low",
"memorySearch": {
"enabled": true,
"sources": [
"memory",
"sessions"
],
"experimental": {
"sessionMemory": true
},
"provider": "ollama"
},
"compaction": {
"memoryFlush": {
"enabled": true
}
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
}
},

fair fjordBOT
#

Yep, this helps a lot.

Good news: your Ollama config looks correct. You are using the native API (api: "ollama", no /v1), so I donโ€™t think this is the /v1 tool-calling bug.

What jumps out instead: you have no agents.defaults.contextPruning configured at all.

For this setup, thatโ€™s the first thing Iโ€™d fix. Without pruning, old tool results just keep piling up in the in-memory prompt until compaction has to save you.

Iโ€™d change this first:

{
  agents: {
    defaults: {
      contextPruning: {
        mode: "cache-ttl",
#
        ttl: "5m",
        keepLastAssistants: 3,
        softTrimRatio: 0.3,
        hardClearRatio: 0.5,
        minPrunableToolChars: 50000,
        softTrim: {
          maxChars: 4000,
          headChars: 1500,
          tailChars: 1500
        },
        hardClear: {
          enabled: true,
          placeholder: "[Old tool result content cleared]"
        }
      }
#
    }
  }
}

Second thing, a bit suspicious:

memorySearch: {
  enabled: true,
  sources: ["memory", "sessions"],
  experimental: { sessionMemory: true }
}

That is not automatically bad, but if the agent likes calling memory_search, it can start pulling transcript-derived stuff back into the conversation. With pruning off, that can get ugly fast.

#

So while debugging, Iโ€™d temporarily simplify it to:

memorySearch: {
  enabled: true,
  sources: ["memory"],
  experimental: { sessionMemory: false },
  provider: "ollama"
}

Then:

  1. restart OpenClaw
  2. start a fresh chat session with:
#
   /new
  1. run:
    /context detail
    

If it still blows up after that, paste the /context detail output. That report is the fastest way to see whether the bloat is coming from:

  • memory_search
  • read
  • exec
  • huge tool schemas/results
  • or just plain transcript length

Docs: