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

Optimizing GLM-4.7-Flash on M4 Mac Mini with 24GB RAM
A developer shares specific configuration details for running GLM-4.7-Flash on an M4 Mac Mini with 24GB RAM, including Q3_K_XL quantization, 32k context size with MLA, and memory allocation realities for Metal.

Fix for sub-agents not showing up in OpenClaw v2026.3.13
A workaround for OpenClaw v2026.3.13 where custom sub-agents don't appear in the agent list: simplify the openclaw.json agent list to only include IDs and manually register agents in runs.json with status set to 'idle'.

Optimizing Qwen 3.6 27B/35B on RTX 3090: Flags, Quantization, and Auto-Routing
A user shares his llama-server flags for Qwen 3.6 27B and 35B GGUF models on an RTX 3090 (24GB), reporting slow speeds for the 35B and unreliable code output from the 27B. The post asks for better quant, flag tuning, and auto model switching.

OpenClaw v2026.3.22 Update Issues and 30-Second Fixes
The OpenClaw v2026.3.22 update introduced 12 breaking changes, including ClawHub becoming the default plugin store and deprecated environment variables. Five common disasters with quick fixes include API billing spikes, unintended agent actions, and configuration errors.