#agents.defaults.compaction.reserveTokensFloor

1 messages · Page 1 of 1 (latest)

fair hollow
#

how do i disable this as i keep getting -- Context limit exceeded. I've reset our conversation to start fresh - please try again.

To prevent this, increase your compaction buffer by setting agents.defaults.compaction.reserveTokensFloor to 20000 or higher in

granite cloudBOT
#

First, what does openclaw --version show? This area has changed recently.

You probably don’t want to disable that reset — it means the model already hit a hard context limit. Make OpenClaw compact earlier instead:

openclaw config set agents.defaults.compaction.reserveTokensFloor 30000 --strict-json
openclaw config validate
openclaw gateway restart

If editing manually, put this in ~/.openclaw/openclaw.json:

{
  agents: {
    defaults: {
#
      compaction: {
        reserveTokensFloor: 30000
      }
    }
  }
}

20000 is the documented baseline; if you’re still seeing overflows, try 30000 or 50000.

Technically, 0 disables the floor guard:

openclaw config set agents.defaults.compaction.reserveTokensFloor 0 --strict-json
fair hollow
#

Invalid config:

  • <root>: JSON5 parse failed: SyntaxError: JSON5: invalid character '"' at 10:7 {
    "agents": {
    "defaults": {
    "compaction": {
    "reserveTokensFloor": 30000
    }
    }
    }
    }
    "model": {
    "primary": "ollama/qwen3:14b"
    },
    "imageModel": {
    "primary": "ollama/qwen3:14b"
    },
    "models": {
    "ollama/qwen3:14b": {}
    }
    }
    },
granite cloudBOT
#

You pasted a whole new root config object into the middle of the file. JSON5 needs one root { ... }.

Put compaction inside your existing agents.defaults, as a sibling of model, imageModel, and models:

{
  "agents": {
    "defaults": {
      "compaction": {
        "reserveTokensFloor": 30000
      },
      "model": {
        "primary": "ollama/qwen3:14b"
      },
      "imageModel": {
        "primary": "ollama/qwen3:14b"
#
      },
      "models": {
        "ollama/qwen3:14b": {}
      }
    }
  }
}

Easier/safer: undo the manual edit, then run:

openclaw config set agents.defaults.compaction.reserveTokensFloor 30000 --strict-json
openclaw config validate
openclaw gateway restart
fair hollow
#
  • <root>: JSON5 parse failed: SyntaxError: JSON5: invalid character '"' at 19:3
granite cloudBOT
#

That error means the file is still structurally broken around line 19 — usually an extra } closed the config, then another "key": ... starts afterward.

Your config must be one object, like this shape:

{
  "agents": {
    "defaults": {
      "compaction": {
        "reserveTokensFloor": 30000
      },
      "model": {
        "primary": "ollama/qwen3:14b"
      },
      "imageModel": {
        "primary": "ollama/qwen3:14b"
#
      },
      "models": {
        "ollama/qwen3:14b": {}
      }
    }
  }
}

If your file currently has something like this, it’s wrong:

{
  "agents": { ... }
}
#
"model": { ... }

Fix the extra closing brace / merge everything under agents.defaults, then run:

openclaw config validate
openclaw gateway restart

If it still errors, paste lines ~12–24 of ~/.openclaw/openclaw.json and your openclaw --version.

fair hollow
#

{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 30000
},
"model": {
"primary": "ollama/qwen3:14b"
},
"imageModel": {
"primary": "ollama/qwen3:14b"
},
"models": {
"ollama/qwen3:14b": {}
}
}
}
}
"gateway": {
"auth": {
"mode": "token",

granite cloudBOT
#

You found it — gateway is currently outside the root { ... }.

Change this part:

  }
}
  "gateway": {

to this:

  },
  "gateway": {
#

So the top-level shape is:

{
  "agents": {
    "defaults": {
      "compaction": {
        "reserveTokensFloor": 30000
      },
      "model": {
        "primary": "ollama/qwen3:14b"
      },
      "imageModel": {
        "primary": "ollama/qwen3:14b"
      },
      "models": {
#
        "ollama/qwen3:14b": {}
      }
    }
  },
  "gateway": {
    "auth": {
      "mode": "token"
    }
  }
}

Keep the rest of your existing gateway fields inside that same "gateway" block. Then run:

#
openclaw config validate
openclaw gateway restart
fair hollow
#

{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 30000
},
"model": {
"primary": "ollama/qwen3:14b"
},
"imageModel": {
"primary": "ollama/qwen3:14b"
},
"models": {
"ollama/qwen3:14b": {}
}
}
}
}
"gateway": {
"auth": {
"mode": "token",
"password": "xxxxxx",
"token": "xxxxxx"
},

granite cloudBOT
#

Same issue still: you closed the root object before "gateway".

Change this:

  }
}
  "gateway": {

to this:

  },
  "gateway": {
#

So your snippet should become:

{
  "agents": {
    "defaults": {
      "compaction": {
        "reserveTokensFloor": 30000
      },
      "model": {
        "primary": "ollama/qwen3:14b"
      },
      "imageModel": {
        "primary": "ollama/qwen3:14b"
      },
      "models": {
#
        "ollama/qwen3:14b": {}
      }
    }
  },
  "gateway": {
    "auth": {
      "mode": "token",
      "password": "xxxxxx",
      "token": "xxxxxx"
    }
  }
}

If there are more fields after "auth", keep them inside "gateway" with commas as usual.

#

Then:

openclaw config validate
openclaw gateway restart

Tiny security note: if those weren’t actually redacted tokens/passwords, rotate them.

fair hollow
#

{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 30000
},
"model": {
"primary": "ollama/qwen3:14b"
},
"imageModel": {
"primary": "ollama/qwen3:14b"
},
"models": {
"ollama/qwen3:14b": {}
}
}
},
"gateway": {
"auth": {
"mode": "token",
"password": "xxxxxx",
"token": "xxxxxx"
}
}
}"bind": "lan",
"controlUi": {
"allowedOrigins": [
"http://127.0.0.1:18789",
"localhost:18789",
"http://192.168.1.101:18789",
"file://"
],
"dangerouslyAllowHostHeaderOriginFallback": true,
"dangerouslyDisableDeviceAuth": true,
"allowInsecureAuth": true
},
"mode": "local",
"port": 18789,
"trustedProxies": [
"127.0.0.1",
"::1",
"localhost",
"192.168.1.101"
]
},

granite cloudBOT
#

You’re super close. The problem is this part:

}
}"bind": "lan",

That second } closes the whole file too early. "bind", "controlUi", "mode", "port", and "trustedProxies" should be inside "gateway", not after it.

Use this shape:

{
  "agents": {
    "defaults": {
      "compaction": {
#
        "reserveTokensFloor": 30000
      },
      "model": {
        "primary": "ollama/qwen3:14b"
      },
      "imageModel": {
        "primary": "ollama/qwen3:14b"
      },
      "models": {
        "ollama/qwen3:14b": {}
      }
    }
  },
  "gateway": {
    "auth": {
#
      "mode": "token",
      "password": "xxxxxx",
      "token": "xxxxxx"
    },
    "bind": "lan",
    "controlUi": {
      "allowedOrigins": [
        "http://127.0.0.1:18789",
        "localhost:18789",
        "http://192.168.1.101:18789",
        "file://"
      ],
      "dangerouslyAllowHostHeaderOriginFallback": true,
      "dangerouslyDisableDeviceAuth": true,
      "allowInsecureAuth": true
#
    },
    "mode": "local",
    "port": 18789,
    "trustedProxies": [
      "127.0.0.1",
      "::1",
      "localhost",
      "192.168.1.101"
    ]
  }
}

Then run:

#
openclaw config validate
openclaw gateway restart

Small warning: bind: "lan" + dangerouslyDisableDeviceAuth is pretty spicy — only do that on a network you fully trust.

fair hollow
#

Ă— <root>: JSON5 parse failed: SyntaxError: JSON5: invalid character '"' at 46:3

granite cloudBOT
#

That means you fixed the earlier block, but there’s another quoted key at line 46 that isn’t comma-separated / is outside the root object.

Rule of thumb: in openclaw.json, there should be one { at the top and one final } at the very bottom. Every top-level section needs commas:

{
  "agents": { ... },
  "gateway": { ... },
  "channels": { ... },
  "tools": { ... }
}

So around line 46, if you see something like:

#
  }
}
"channels": {

change it to:

  },
  "channels": {

Or if it’s another key, same idea:

#
  },
  "whateverLine46Is": {

Paste lines 40–52 if it still complains — but keep tokens/passwords redacted. You’re basically hunting one more extra } / missing comma.

fair hollow
#

"meta": {
"lastTouchedVersion": "2026.4.15",
"lastTouchedAt": "2026-04-29T23:28:30.100Z"
},
"models": {
"providers": {
"ollama": {
"api": "ollama",
"baseUrl": "http://10.121.15.177:11434",
"apiKey": "remote-ollama-firewalled",
"auth": "api-key",
"models": [
{
"id": "qwen3:14b",
"name": "qwen3:14b",
"input": [
"text"
],
"reasoning": false,
"contextWindow": 16000,
"maxTokens": 512,
"compat": {
"supportsTools": false
}
},
{
"id": "llama3.1:8b",
"name": "llama3.1:8b",
"input": [
"text"
],
"reasoning": false,
"contextWindow": 16000,
"maxTokens": 512,
"compat": {
"supportsTools": false
}
},
{

#

"id": "qwen2.5-coder:14b",
"name": "qwen2.5-coder:14b",
"input": [
"text"
],
"reasoning": false,
"contextWindow": 16000,
"maxTokens": 512,
"compat": {
"supportsTools": false
}
},
{
"id": "deepseek-r1:14b",
"name": "deepseek-r1:14b",
"input": [
"text"
],
"reasoning": true,
"contextWindow": 16000,
"maxTokens": 512,
"compat": {
"supportsTools": false
}
}
]
}
}
},
"plugins": {
"entries": {
"ollama": {
"enabled": true,
"config": {}
},
"browser": {
"enabled": true
}
}
},
"wizard": {
"lastRunAt": "2026-04-29T23:27:33.123Z",
"lastRunVersion": "2026.4.11",
"lastRunCommand": "doctor",
"lastRunMode": "local"
},
"commands": {
"restart": true
},
"tools": {
"profile": "full",
"sessions": {
"visibility": "all"
},
"exec": {
"security": "full",
"ask": "off"
}
},
"browser": {
"enabled": true,
"defaultProfile": "openclaw",
"ssrfPolicy": {
"dangerouslyAllowPrivateNetwork": true
}
},
"session": {
"idleMinutes": 10080
}
}

granite cloudBOT
#

"meta" is also a top-level section, same level as "agents", "gateway", and "models".

So the end of your "gateway" block needs to be followed by a comma:

  "gateway": {
    ...
    "trustedProxies": [
      "127.0.0.1",
      "::1",
      "localhost",
      "192.168.1.101"
    ]
  },
  "meta": {
    "lastTouchedVersion": "2026.4.15",
#
    "lastTouchedAt": "2026-04-29T23:28:30.100Z"
  },
  "models": {
    "providers": {
      ...
    }
  }
}

So if you currently have:

  }
  "meta": {
#

make it:

  },
  "meta": {

Also: redact/rotate anything under "apiKey" if it’s a real secret, even for Ollama.

After this parses:

openclaw config validate
openclaw gateway restart
fair hollow
#

its a dummy key

#

Ă— <root>: JSON5 parse failed: SyntaxError: JSON5: invalid character ',' at 45:2

granite cloudBOT
#

This latest tail mostly looks OK. The parse error at line 46 means the key at line 46 — probably "meta" or "models" — is not separated from the previous block.

Top-level sections must look like this, with commas between each:

{
  "agents": { ... },
  "gateway": { ... },
  "meta": { ... },
  "models": { ... },
  "plugins": { ... },
  "wizard": { ... },
  "commands": { ... },
  "tools": { ... },
  "browser": { ... },
  "session": { ... }
#
}

Also, inside your Ollama models array, make sure qwen2.5-coder:14b starts with an opening {:

          {
            "id": "qwen2.5-coder:14b",
            "name": "qwen2.5-coder:14b",
            ...
          },

After fixing, run:

#
openclaw config validate

One bigger thing: your models are configured with "contextWindow": 16000, so reserveTokensFloor: 30000 won’t really help much. For a 16k Ollama model, either use a larger num_ctx/contextWindow if your machine can handle it, or use a bigger-context/cloud model for full OpenClaw sessions.

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

#

Gotcha — dummy key is fine then 👍

The remaining problem is just JSON structure. Since this has gotten messy, I’d stop hand-merging chunks and use the CLI once the file parses again:

openclaw config validate
openclaw config set agents.defaults.compaction.reserveTokensFloor 30000 --strict-json
openclaw gateway restart

If it still won’t parse, restore the last good config if available:

CONFIG="$(openclaw config file)"
ls -lt "$CONFIG".clobbered.* "$CONFIG".rejected.* 2>/dev/null | head
#

Then copy back the newest good-looking backup, or paste the full config with secrets redacted and we can spot the missing comma/brace.

Also worth noting: your Ollama entries show contextWindow: 16000, so a 30k reserve can’t create more context than the model has. For long OpenClaw sessions, raise Ollama num_ctx + contextWindow if your hardware supports it, or use a larger-context model.

#

That means you now have a standalone comma at line 45.

Bad:

  }
,
  "meta": {

Good:

  },
  "meta": {
#

Also bad if that } already closed the whole file:

}
,
"meta": {

In that case, remove the extra closing brace so "meta" stays inside the one root object:

  },
  "meta": {

To see the exact spot:

fair hollow
#

},
"meta": {

granite cloudBOT
#

That line is only valid if it’s still inside the main { ... }.

If JSON5 says the comma is invalid on:

},
"meta": {

then the } before that comma is closing the whole file, not just "gateway".

You likely have this:

  "gateway": {
    ...
#
  }
},
"meta": {

It should be:

  "gateway": {
    ...
  },
  "meta": {

So: remove one extra } before "meta". The final } for the whole config should be at the very bottom of the file, after "session".

#

Quick check:

nl -ba ~/.openclaw/openclaw.json | sed -n '35,50p'

If you paste lines 35–50, I can point to the exact brace.

fair hollow
#

this is running under windows so commands like nl and the config set didnt work

granite cloudBOT
#

Ah yep, sorry — I was giving Linux commands. On Windows PowerShell, use this instead:

$path = "$env:USERPROFILE\.openclaw\openclaw.json"
$lines = Get-Content $path
for ($i = 34; $i -lt 55; $i++) { "{0,4}: {1}" -f ($i + 1), $lines[$i] }

That prints lines 35–55 with line numbers. Paste that chunk.

Also: openclaw config set ... won’t work while the file is parse-broken, because OpenClaw has to read the config first. Fix the comma/brace issue first, then run:

openclaw config validate
openclaw config set agents.defaults.compaction.reserveTokensFloor 30000 --strict-json
openclaw gateway restart
fair hollow
#

$path = "$env:USERPROFILE.openclaw\openclaw.json"
$lines = Get-Content $path
for ($i = 34; $i -lt 55; $i++) { "{0,4}: {1}" -f ($i + 1), $lines[$i] }

granite cloudBOT
#

Looks like you pasted the command here instead of the output 🙂

Run that in PowerShell on the Windows machine, then paste what it prints — it should look like:

  35: ...
  36: ...
  37: ...

If copying multi-line PowerShell is awkward, use this one-liner:

$lines=Get-Content "$env:USERPROFILE\.openclaw\openclaw.json"; 35..55 | % { "{0,4}: {1}" -f $_, $lines[$_-1] }

Then paste the output.

fair hollow
#

},
36: "mode": "local",
37: "port": 18789,
38: "trustedProxies": [
39: "127.0.0.1",
40: "::1",
41: "localhost",
42: "192.168.1.101"
43: ]
44: }
45: },
46: "meta": {
47: "lastTouchedVersion": "2026.4.15",
48: "lastTouchedAt": "2026-04-29T23:28:30.100Z"
49: },
50: "models": {
51: "providers": {
52: "ollama": {
53: "api": "ollama",
54: "baseUrl": "http://10.121.15.177:11434",
55: "apiKey": "remote-ollama-firewalled",

granite cloudBOT
#

Yep — line 45 is the problem. It closes the whole root object too early.

Change:

44:   }
45: },
46:   "meta": {

to:

44:   },
45:   "meta": {
#

So in the file, remove the extra } line and put the comma after the gateway block:

    ]
  },
  "meta": {

Then run:

openclaw config validate

If it passes, restart:

#
openclaw gateway restart
fair hollow
#

so remove 44?

granite cloudBOT
#

No — keep line 44. Remove line 45.

Then add a comma to line 44.

Before:

43:     ]
44:   }
45: },
46:   "meta": {

After:

#
43:     ]
44:   },
45:   "meta": {

So you’re deleting the extra }, line and changing } to },.

fair hollow
#

10:25:58+10:00 [agent/embedded] [context-overflow-precheck] sessionKey=agent:main:main provider=ollama/qwen3:14b route=compact_only estimatedPromptTokens=179 promptBudgetBeforeReserve=1 overflowTokens=178 toolResultReducibleChars=0 reserveTokens=16384 sessionFile=C:\Users\Admin.openclaw\agents\main\sessions\8cd1869a-2f1e-4654-bc81-a112c66d8f07.jsonl
10:25:58+10:00 [agent/embedded] [context-overflow-diag] sessionKey=agent:main:main provider=ollama/qwen3:14b source=promptError messages=2 sessionFile=C:\Users\Admin.openclaw\agents\main\sessions\8cd1869a-2f1e-4654-bc81-a112c66d8f07.jsonl diagId=ovf-mokqtk43-Jty2ag compactionAttempts=1 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
10:25:58+10:00 [agent/embedded] context overflow detected (attempt 2/3); attempting auto-compaction for ollama/qwen3:14b
10:25:59+10:00 [agent/embedded] [compaction-diag] end runId=85e82fa9-a714-45e2-a235-fcb8afac602d sessionKey=agent:main:main diagId=ovf-mokqtk43-Jty2ag trigger=overflow provider=ollama/qwen3:14b attempt=2 maxAttempts=3 outcome=failed reason=already_compacted_recently durationMs=498
10:25:59+10:00 [agent/embedded] auto-compaction failed for ollama/qwen3:14b: Already compacted
10:25:59+10:00 Auto-compaction failed (Context overflow: prompt too large for the model (precheck).). Restarting session agent:main:main -> e7d0cf76-406e-496b-921b-4c3c55716512 and retrying.

granite cloudBOT
#

Yep, the config is parsing now — this log shows the real issue:

promptBudgetBeforeReserve=1
reserveTokens=16384

Your model only has ~16k context, but Pi is reserving 16,384 tokens, leaving basically 1 token for the actual prompt. So for this Ollama model, 30000 is the wrong direction. Sorry, that generic hint is misleading for small-context local models.

Change your compaction block to this:

"compaction": {
  "reserveTokensFloor": 0,
  "reserveTokens": 2048,
  "keepRecentTokens": 4096
#
}

So under:

"agents": {
  "defaults": {
    ...
  }
}

replace the old:

#
"reserveTokensFloor": 30000

with the full block above.

Then run on Windows:

openclaw config validate
openclaw gateway restart

If openclaw isn’t recognized:

#
openclaw.cmd config validate
openclaw.cmd gateway restart

Also please paste openclaw --version — this small-context reserve behavior has had fixes, and 2026.4.15 is older. For Ollama 16k, you either need smaller reserves like above, or raise both contextWindow and Ollama params.num_ctx if your hardware can handle it.

fair hollow
#

OpenClaw 2026.4.11 (769908e)

#

13:18:14+10:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction for ollama/qwen3:14b
13:18:15+10:00 [agent/embedded] [compaction] skipping — no real conversation messages (sessionKey=agent:main:main)
13:18:15+10:00 [agent/embedded] auto-compaction failed for ollama/qwen3:14b: no real conversation messages
13:18:15+10:00 Auto-compaction failed (Context overflow: prompt too large for the model (precheck).). Restarting session agent:main:main -> 56b682ba-fd0f-4eb4-81c7-a0877e80c416 and retrying.
13:18:44+10:00 [agent/embedded] low context window: ollama/qwen3:14b ctx=16000 (warn<32000) source=modelsConfig
13:18:45+10:00 [agent/embedded] [context-overflow-precheck] sessionKey=agent:main:main provider=ollama/qwen3:14b route=compact_only estimatedPromptTokens=114 promptBudgetBeforeReserve=1 overflowTokens=113 toolResultReducibleChars=0 reserveTokens=16384 sessionFile=C:\Users\Admin.openclaw\agents\main\sessions\56b682ba-fd0f-4eb4-81c7-a0877e80c416.jsonl
13:18:45+10:00 [agent/embedded] [context-overflow-diag] sessionKey=agent:main:main provider=ollama/qwen3:14b source=promptError messages=1 sessionFile=C:\Users\Admin.openclaw\agents\main\sessions\56b682ba-fd0f-4eb4-81c7-a0877e80c416.jsonl diagId=ovf-mokwzquc-JzzpVg compactionAttempts=0 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
13:18:45+10:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction for ollama/qwen3:14b

#

hello