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 Qwen3.5-9B on RTX 3070 Mobile with ik_llama.cpp: Config Tweaks and Benchmarks
A developer shares optimization findings for running Qwen3.5-9B Q4_K_M on an RTX 3070 Mobile 8GB GPU using ik_llama.cpp, achieving ~50 tokens/second generation speed and significant prompt evaluation improvements through configuration adjustments.

OpenClaw Cost Optimization: Five Settings for Continuous Agent Usage
A developer running OpenClaw continuously on a Raspberry Pi identified five configuration settings that significantly reduced agent costs by optimizing for cost rather than default capability.

Giving Claude M365 Access via Power Automate and a FastMCP Server
A developer built a lightweight MCP server that lets Claude interact with Microsoft 365 (inbox, calendar, OneDrive, Planner, Excel, Word) using Power Automate webhooks — no admin Graph permissions needed.

Skill-writing principles for Claude Code from 159 open-source skills
A developer shares 10 principles for writing effective skills for Claude Code, based on building and maintaining an open-source registry with 159 skills. The principles include practical approaches like using folders instead of single files, adding gotchas sections, and implementing on-demand hooks.