How to Fix OpenClaw Response Times by Reducing Context Bloat

Problem: Silent Context Truncation Causing Slow Responses
A developer running OpenClaw 24/7 on a Mac Mini M4 experienced 10-minute response times to simple messages. Investigation revealed the workspace bootstrap file MEMORY.md was 26,421 characters (exceeding the 20,000 character limit) and being silently truncated in injected context. Approximately 47,000 characters of workspace files were being injected into every message before any user input, with MEMORY.md alone at 26,755 characters.
Root Causes Identified
- MEMORY.md contained full deployment commands, financial breakdowns, and verbose project write-ups instead of serving as an index
- Standard workspace files were bloated with duplicate content (AGENTS.md had instructions duplicating system prompts, TOOLS.md contained Telegram groups already in MEMORY.md)
- No hard caps on file sizes, allowing files to drift until hitting the default bootstrapMaxChars limit of 20,000 and getting truncated silently
File Restructuring Results
The developer restructured files using the principle that MEMORY.md should contain pointers only. If information can be looked up in a project file when needed, it doesn't belong in MEMORY.md.
- MEMORY.md: Reduced from 26,755 characters to 3,456 characters
- AGENTS.md: Reduced from 8,436 characters to 2,538 characters
- TOOLS.md: Reduced from 4,468 characters to 2,350 characters
- Total injected context: Reduced from ~47k characters to ~16k characters
Created non-standard files (PROJECTS.md, LESSONS.md, VOICE.md) for venture status, Telegram IDs, automations, and infrastructure. These files are not auto-injected but are searchable via memory_search when relevant.
Configuration Changes
Add these settings to ~/.openclaw/openclaw.json under agents.defaults:
{
"bootstrapMaxChars": 8000,
"bootstrapTotalMaxChars": 40000,
"compaction": {
"mode": "safeguard",
"reserveTokensFloor": 20000,
"memoryFlush": {
"enabled": true,
"softThresholdTokens": 4000,
"systemPrompt": "Session nearing compaction. Store durable memories now.",
"prompt": "Write any lasting notes to memory/YYYY-MM-DD.md; reply with NO_REPLY if nothing to store."
}
},
"memorySearch": {
// Configuration continues from source
}
}
Research Insights
The developer researched multiple sources before implementing changes:
- OpenClaw official docs for memory.md, agent-workspace.md, compaction docs, and context docs
- r/AI_Agents post "8 Ways OpenClaw Reduces Context Loss in Long-Running Agents" with the insight: "Context is a new kind of resource, like RAM."
- r/ClaudeAI post "How I solved context loss in long-running Claude agent sessions" which introduced reserveTokensFloor and a lightweight conversation-state.md session bookmark
- Arxiv paper 2602.11988v1 on agent memory management found that context files reduce task success rates by ~3% and increase inference costs by 20%+
📖 Read the full source: r/clawdbot
👀 See Also

12GB VRAM Benchmarks: Running Qwen 3.6 and Gemma 4 Models on a RTX 4070 Super
A Reddit user shares detailed speed benchmarks for Qwen3.6-35B-A3B, Qwen3.6-27B, Gemma 4 26B, and Gemma 4 31B on a 12GB RTX 4070 Super using llama.cpp with optimized settings.

One-Soup One-Dish: A Japanese Cooking Principle for AI Fatigue
Takuya applies the Japanese 'Ichiju Issai' cooking principle to combat AI fatigue — simplify your tech stack to one primary tool and one side tool, just like a meal of rice, soup, and one dish.

OpenClaw: Your Ultimate Quick Reference Cheatsheet
Dive into the nitty-gritty of OpenClaw with our handy reference cheatsheet. Extract critical features and functionalities to streamline your AI coding experience.

Treating OpenClaw Subagents as Stateless Functions Instead of Persistent Team Members
A developer shares their experience shifting from treating OpenClaw subagents as persistent team members with personalities to viewing them as stateless function calls with specialized purposes.