New to context management? Read the free primer first: Context Death Spiral Prevention It explains the problem this skill solves and why default OpenClaw setups don't protect you.
This skill installs the exact compaction architecture Anthropic runs in production Claude Code. It configures your OpenClaw agent with:
Place this SKILL.md in your OpenClaw skills directory and reload:
bash
mkdir -p ~/.openclaw/workspace/skills/agent-compaction
cp SKILL.md ~/.openclaw/workspace/skills/agent-compaction/
Then reload OpenClaw or restart the gateway.
Add these values to your openclaw.json compaction config:
json
{
"compaction": {
"mode": "safeguard",
"keepRecentTokens": 200000,
"reserveTokensFloor": 20000,
"model": "anthropic/claude-haiku-4-5"
}
}
These are the production-validated constants. Do not guess alternatives — the values interact, and changing one without adjusting the others breaks the gate logic.
After 1–2 sessions, check your agent logs for:
[compaction] autocompact gate evaluated — gate is running[compaction] circuit breaker — breaker initialized[compaction] error entries without recoveryIf you see [compaction] threshold breach without gate — your OpenClaw
version doesn't support the full gate. Check the version requirements below.
ThresholdTokensPurposeWarning160,000Signal approaching limitAutocompact trigger167,000Gate evaluation beginsBlock177,000Context too full to compact safelyContext window200,000Hard limitReserve floor20,000Always reserved for output
These are derived from production Claude Code deployment baselines. The 167k trigger gives enough room for compaction output without hitting the block threshold. The 20k reserve prevents output truncation during compaction.
The full behavioral specification is in COMPACTION_ARCHITECTURE.md
(included in this package). It covers:
This skill is included in the Production Agent Ops — Battle-Tested Architecture Pack along with 6 other production architecture files covering loop termination, session memory, bash security, agent memory scoping, coordinator mode, and forked agent architecture.
If you need all 7 systems, the bundle ($69) costs less than buying them individually.