Fix OpenClaw Slowdown in Long Sessions: contextInjection continuation-skip for llama.cpp Cache

If your self-hosted OpenClaw with llama.cpp gets progressively slower as sessions grow past 90k tokens, the culprit might be a single OpenClaw setting that silently invalidates the prompt cache every turn. A user on r/openclaw traced the issue and found a simple fix.
The Setup
- Qwen3.6-27B-Q8_0 on dual RTX 3090s (tensor parallel)
- llama-server with
--cache-prompt,--ctx-size 400000,--parallel 2 - OpenClaw connecting over LAN
The Symptoms
llama-server logs showed on every turn:
forcing full prompt re-processing due to lack of cache data
erased invalidated context checkpoint (pos_min = 57172)
erased invalidated context checkpoint (pos_min = 60139)
erased invalidated context checkpoint (pos_min = 91076)
prompt eval time = 130511 ms / 91403 tokens91k tokens re-processed from scratch each turn — 130 seconds. The cache was enabled, checkpoints existed, but llama.cpp found zero matches and fell back to full re-processing.
The Root Cause
OpenClaw's setting contextInjection, default always, re-injects all workspace bootstrap files (AGENTS.md, SOUL.md, USER.md, TOOLS.md, MEMORY.md, HEARTBEAT.md, ~15kb) into the system prompt on every turn — including continuation turns. This changes the token sequence, so llama.cpp's prompt cache (which relies on exact prefix matching) cannot be reused.
The Fix
openclaw config set agents.defaults.contextInjection continuation-skip --mergeThen restart the gateway. continuation-skip only injects bootstrap files on new user messages, not on continuation turns, keeping the prompt stable and the cache valid.
The Results
Before: 91,403 tokens re-processed per turn, 130s prompt eval, 0% cache reuse, 2+ min per reply.
After: 513 new tokens per turn, 1.3s prompt eval, 99.7% cache reuse, ~5 seconds per reply. 100x faster.
How to Diagnose
ssh your-server "journalctl -u llama.service --no-pager -n 50 | grep -iE 'cache|re-process|checkpoint'"Broken cache signs: forcing full prompt re-processing due to lack of cache data, erased invalidated context checkpoint repeated, prompt processing over 30 seconds. Healthy cache signs: restored context checkpoint, f_keep = 0.99+, graphs reused = large number, prompt processing under 5 seconds.
Also tune --ctx-size to 400k (200k per session), OpenClaw contextTokens to 200k, and memoryFlush.softThresholdTokens from 30k to 10k for additional improvements.
📖 Read the full source: r/openclaw
👀 See Also

OpenClaw CLI Performance Triage Checklist
A Reddit user shares a six-step checklist to diagnose slow OpenClaw CLI commands, including commands to measure latency, monitor system resources, check gateway logs, and isolate configuration issues.

Building a Fully Local Multi-Agent Assistant with OpenClaw and Ollama
A developer shares their stack for a fully local personal AI assistant using OpenClaw and Ollama, including models qwen3.5:35b-a3b, gemma3:4b, mistral:7b, MCP servers for Home Assistant and Gmail, and a Telegram Bot interface.

A 4-file memory system for OpenClaw agents without plugins
A Reddit user shares a practical memory system using four markdown files: USER.md for identity, CONTEXT.md for active work, MEMORY.md for structured topics, and ARCHIVE.md for completed items. The approach addresses the 'agent doesn't know what it knows' problem through better file architecture rather than more memory.

Route Claude Code through Ollama and Cut Your Bill ~90%
Pair Claude Desktop with Ollama-backed Claude Code: strategic work stays on Anthropic, heavy tasks run on free open-source models like Gemma, Qwen, DeepSeek. Includes a copy-paste prompt that automates ~98% of the setup.