Compaction Can’t Fix Context That Was Never in the Transcript: Diagnosing OpenClaw Context Overflows

A recent r/openclaw report highlights a critical distinction: context and conversation history are not the same thing. The user's session hit a compaction loop—"Compacting context (0 messages)"—because the model prompt already exceeded its budget before any conversation began. With ~34,500 characters of system prompt and only an 8,000-token budget, preflight estimated ~10,700 tokens. Compaction found no conversation messages to summarize, so each retry returned to the exact same overflow condition.
OpenClaw's context includes more than just chat turns. The full prompt packs in the system prompt, injected workspace files (AGENTS.md, SOUL.md, IDENTITY.md, USER.md), skill metadata, tool definitions and schemas, tool calls/results, and attachments. Compaction only summarizes older conversation turns—if the dominant cost lives in the always-loaded system prompt, compacting an empty transcript will never reduce it.
Diagnose with Built-in Commands
Before switching models or tweaking compaction settings, inspect the actual context contributors:
/status
/context list
/context detail
/context map
Run /context map after at least one normal model run so it has a captured report to visualize.
Find the Real Culprit
Once you have the breakdown, act on the dominant category:
- Conversation history dominates → compaction or pruning old tool results helps.
- Injected workspace files dominate → remove duplicated instructions and move background reference material out of always-loaded files. Full skill instructions are designed to load on demand—don't keep them in injected files.
- Tool schemas dominate → audit which tools that agent genuinely needs. Schemas consume context even though they're not visible as prompt text.
- Base system prompt + reserved output budget already exceed usable model budget → changing the transcript is the wrong layer. This becomes a model-window, reserve-budget, or tool-surface problem.
Make Repairs Reversible
The author recommends an iterative approach that preserves your current configuration:
- Save your current setup.
- Change one contributor category at a time.
- Start a fresh session and repeat the same small task.
- Compare
/context detail, Gateway compaction logs, and the actual task result before/after.
A lower token count isn't a success if the agent loses required instructions or tools. Verification requires all three:
- Prompt fits the available budget
- Compaction loop does not recur
- The same bounded task completes correctly
Have you run /context detail? What actually dominates your OpenClaw context: workspace files, tools/skills, or conversation history? Share your findings in the thread.
📖 Read the full source: r/openclaw
👀 See Also

Token Master: Architecture Concept to Save 30-70% on AI Agent Costs
A detailed architectural approach to intelligent multi-model routing that can dramatically reduce token consumption.

If OpenClaw Still Needs Your Next Prompt, It Is Not Autonomous Yet — A Setup Prompt for Persistent Workflows
Treat OpenClaw as a coordinator, not a chat surface. Use GOALS.md as a shared roadmap, one Codex goal at a time.

Browser Agents Ate My API Budget: The Hidden Cost of Observation Loops
Running AI agents on real web tasks? A Reddit user reports that browser observation loops — not the model — are the dominant cost driver. Every click, wait, and observe triggers a round trip, and poor snapshot quality creates a compounding failure spiral that inflates token usage. Isolated browser environments and faster agent execution are key cost-saving measures.

Enforcing Hard Guardrails for OpenClaw AI Agents: Approval Gating and Concurrency Limits
An r/openclaw user asks how to enforce hard rules like email approval and concurrency limits on a Discord-connected OpenClaw bot running Ollama with GLM. The answer: move enforcement outside the model's reasoning loop.