OpenClaw

OpenClaw silently compresses context and loses work

When history exceeds the context window, OpenClaw silently compresses older messages into a summary, destroying active task state so the agent starts hallucinating or repeating itself. Set maxContextTokens to roughly 80% of the model's limit for headroom, pin critical instructions with [PINNED] tags so they survive, set compactMessageCount: -1 to disable auto-compaction, and mount a persistent volume for memory.

Likely cause

When history exceeds the context window, OpenClaw silently compresses older messages into a summary, destroying active task state so the agent starts to hallucinate or repeat itself.

The fix

  1. 1 Set maxContextTokens to about 80% of the model's limit so compaction has headroom.
  2. 2 Pin critical instructions with [PINNED] tags so they survive compaction.
  3. 3 Set compactMessageCount: -1 to disable auto-compaction, and mount a persistent volume for memory.
compactMessageCount: -1
Full guideOpenClaw Memory Compaction Explained

Hit a different error?

Paste any agent error and get the cause and fix in seconds.

Open the decoder

Frequently asked questions

My agent suddenly forgets the task and repeats steps. What happened?

It likely hit the context window and OpenClaw silently compacted older messages into a summary, dropping the active task state. Pin the key instructions and leave headroom with maxContextTokens so compaction doesn't destroy live work.

How do I keep critical instructions from being summarized away?

Wrap them in [PINNED] tags. Pinned content survives compaction, so the agent keeps the goal and constraints even after older history is compressed.

Can I just turn auto-compaction off?

Yes - set compactMessageCount: -1 to disable it, but then you must keep sessions under the context limit yourself. Pair it with a persistent volume so long-term memory lives outside the window.

Stop firefighting agent errors

Decoding errors one at a time is the manual version of what BetterClaw automates. Run your OpenClaw agents hosted with managed models, retries and config validation built in.

$19/month per agent · BYOK · 7-day money-back guarantee