Your agent nailed the first ten messages. By message eighty it was answering a question you did not ask, repeating itself, or quietly ignoring the instructions you gave at the start. So you restart the gateway, reinstall the plugin, swap the model. A day later it happens again.
The cause is almost always context overflow. Every model has a fixed context window, the maximum amount of text it can read in one turn, and OpenClaw fills that window with far more than your conversation. The system prompt, tool schemas, skill entries, your workspace files, every tool result, and the whole transcript all compete for the same space. When it runs out, you get no warning. The agent just gets slower, vaguer, and more expensive.
This is the walkthrough I wish I had when I first hit it. It shows what actually fills the window, how to inspect it with a single command, and the four fixes that reclaim the most space. Everything is copy-paste ready.
The Myth: “Just Use a Model With a Bigger Context Window”
The belief is simple: pick a 200K or 1M token model and the problem disappears. More room, more memory, smarter answers. It feels logical, and it is wrong for three reasons.
- You pay for it every turn. The whole window is re-sent to the model on each message. Input tokens are billed on every call, so a bloated window is not a one-time cost, it is a tax on every reply.
- Latency grows with the window. More tokens to read means a slower first token and a longer wait. A big window can make the agent feel sluggish even when nothing is technically broken.
- Attention is not uniform. Models recall the start and the end of a long context far better than the middle. That is the well documented “lost in the middle” effect. A 200K window does not give you 200K tokens of equally sharp focus.
And the hard limit still exists. OpenClaw also reserves part of the window for compaction, so the usable space is always a little smaller than the model’s headline number. A bigger window buys you time. It does not fix a full one.
What Is Actually Inside Your Context Window
Here is the part most tutorials skip. The context is not just your chat history. OpenClaw rebuilds the system prompt on every run, and that prompt is packed with things you never see.
- System prompt (OpenClaw-owned): rules, the tool list, the skills list, workspace location, time, and runtime metadata.
- Injected workspace files: your AGENTS.md, SOUL.md, USER.md, and MEMORY.md are read into the prompt.
- Tool schemas: every enabled tool ships a JSON schema so the model knows how to call it.
- Conversation history: your messages and the agent’s replies.
- Tool calls and results: file reads, command output, search results.
- Attachments and compaction summaries.
That overhead lands before you type a single word. In a normal OpenClaw setup, tool schemas alone run about 32,000 characters, roughly 8,000 tokens, and the assembled system prompt sits near 38,000 characters, about 9,600 tokens. That is around 17,000 tokens of fixed cost on every single turn.

The takeaway: context is a budget, not a bucket. Your job is to spend it on the conversation, not on scaffolding.
First, See Exactly What Is Eating Your Window
You cannot fix what you cannot see, so start with the built in inspector. In any OpenClaw chat:
/statusshows how full the window is plus the current session settings./context listbreaks down what is injected and its rough size./context detailgoes deeper: per-file sizes, per-tool schema sizes, per-skill entries, and compactable transcript counts./context maprenders a treemap image of the biggest contributors./usage tokensadds a per-reply token footer to normal replies.
Run /context list and you get something like this:
Read it top to bottom. “Bootstrap max/file” is the ceiling for injected files. Each workspace file shows raw size versus injected size. The skills line and the tool schema line tell you how much of the window is scaffolding rather than conversation. If tool schemas plus injected files are bigger than your actual chat, you have found the problem.
Fix 1: Trim the Overhead You Never See
The cheapest win is deleting context you are not using. Every enabled tool and every enabled skill adds text to the prompt on every turn.
- Disable tools you do not use. A lean tool set can cut thousands of tokens per turn. If the agent never touches the browser, turn the browser off.
- Remove skills you are not running. The skills list is metadata, but metadata still counts.
- Trim workspace files. MEMORY.md and AGENTS.md are read on every run, so a long file is an expensive file. Keep them curated and move reference material into files the agent reads on demand.
- Cap the bootstrap. The
bootstrapMaxCharssetting limits how many characters get injected per run. Set it and no oversized file can blow past the ceiling.
In my own config I keep bootstrapMaxChars at 20,000 for conversational agents. It is a hard backstop: the prompt can still grow from the conversation, but the static part can never run away again.
Fix 2: Manage the Transcript Itself
Once the scaffolding is lean, the conversation becomes the biggest line item. This is where /compact earns its keep.
Run /compact and OpenClaw summarizes the older part of the conversation into a single compact entry, then drops the raw messages it replaced. The mechanism matters here: you are trading detail for space. The agent keeps the gist of what happened, but it loses the exact wording of old turns. If a specific instruction from fifty messages ago still matters, restate it after you compact.

You can also automate session hygiene in config so you never think about it again:
session.resetclears the session on a schedule. Mine resets daily at 4am, so every morning starts clean.session.maintenanceprunes old entries automatically (pruneAfterof 30 days and amaxEntriescap).
When in doubt, just start a fresh session. A new session is the cleanest possible compaction because the window is empty again. Long lived sessions that stay open for weeks are how agents quietly rot. If you are still tuning how memory behaves across sessions, our guide to fixing OpenClaw memory and context covers the storage side.
Fix 3: Stop Re-Feeding the Same Big Document
The most expensive habit is pasting. Every time you drop a 40 page PDF into the chat, that text sits in the window and is re-sent on every later turn for the rest of the session.
- Put stable knowledge in a file the agent reads on demand, not in the prompt.
- Let the agent search memory with
memory_searchinstead of carrying facts in context forever. - Use sub-agents for heavy reads. A sub-agent does the big read in its own separate window and returns only the summary, so the main conversation stays light.
- Enable light context for scheduled work. A heartbeat that only needs a status check does not need the full window. That is exactly what the light context flag is for, and it is covered in our guide to OpenClaw scheduling with heartbeat, cron, and launchd.
If your hosting is the bottleneck: Kinsta keeps your site safe with automatic daily backups and one-click restore, so a bad update or a hack is a rollback, not a rebuild. Their support is top tier, and 24/7 live chat is staffed by WordPress engineers who will help fix the actual problem with you, so you are not stuck waiting on your developer to reply. Plans start at $35 per month.
If you run your OpenClaw gateway on the same small VPS as your WordPress site, the agent’s memory footprint competes directly with PHP and MySQL. When the host throttles, both the site and the agent crawl, and no amount of context tuning will fix a server that is simply out of room.
Common Mistakes
- Pasting an entire document “just this once.” There is no such thing. It stays in the session.
- Never compacting, then blaming the model when it gets vague.
- Running a single session for weeks and wondering why quality drifts.
- Chasing an ever bigger context window while the bill climbs every month.
- Deleting MEMORY.md to save space. That destroys recall. Trim it and move detail into files the agent can look up, do not delete your agent’s long term memory.
If cost is your real concern rather than speed, the same levers apply. A lean window is a cheap window, and cutting OpenClaw token costs starts with the exact same inspection step.
Context overflow and rising costs are the same problem seen from two angles. Our guide walks through the settings that actually reduce spend without losing output quality.
See Our GuideFAQ
A context window is everything OpenClaw sends to the model in one run: the system prompt, tool schemas, workspace files, conversation history, tool results, and attachments. It is bounded by the model’s token limit, so the window is a fixed budget that all of those pieces share.
Almost always context overflow. The window fills with fixed scaffolding and old history, so the model has less room for your current question and more tokens to read on every turn. The fix is to trim the overhead, compact the transcript, or start a fresh session.
Not by itself. A larger window delays the overflow but raises cost and latency, and model attention is weaker in the middle of a long context. A curated, lean window usually beats a huge, cluttered one.
It summarizes the older part of the conversation into a single compact entry and drops the raw messages it replaced. You keep the gist of the session and free up window space, at the cost of fine detail from older turns.
Run /status or /context list. If injected workspace files plus tool schemas take up a large share of the window, or the session token count is close to the model limit, you have overflow. Trim the overhead and compact, then re-check.
Final Thoughts
Context overflow is not a bug and it is not your model being “dumb.” It is a budget problem, and budgets respond to discipline. Inspect the window with /context list, trim the overhead you never see, compact or reset long sessions, and stop re-feeding the same big documents.
Do those four things and your agent gets faster, sharper, and cheaper at the same time. Start with the inspector, because once you can see the numbers, the rest of the fix is obvious.

