Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Manage AI agent context window consumption, prevent compaction death spirals, and enforce sub-agent spawn policies. Use when: (1) context is filling up and w...
Manage AI agent context window consumption, prevent compaction death spirals, and enforce sub-agent spawn policies. Use when: (1) context is filling up and w...
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
Prevent context exhaustion, enforce spawn discipline, and make compaction survivable.
Fixed baseline: Typically 5-15% of context consumed before any conversation β system prompt, workspace files, skill descriptions, tool definitions. Varies by setup (more skills/files = higher baseline). 60/40 rule: ~60% of consumed context is tool outputs, ~40% conversation. Tool outputs are the primary target for savings. Compaction is lossy: Summaries stack cumulatively. Each cycle raises the floor. After 3+ compactions, summaries alone can consume 30%+ of context. Sub-agents are disposable context: A sub-agent can burn most of its context investigating something; only the summary (~500 tokens) enters main context. All percentages are relative to the model's context window. Check session_status for actual window size and usage.
After every tool-heavy operation (>5 tool calls), assess: Run session_status to check usage If below 50%: continue normally If 50-70%: spawn sub-agents for remaining tool-heavy work (>3 tool calls) If 70-85%: spawn sub-agents for ANY tool work (>1 tool call). Warn user. If above 85%: write checkpoint (see below), suggest /compact or /new
Cannot get exact per-component breakdown. Estimate: Fixed baseline: ~5-15% (system prompt + workspace files + skills + tools) Per user message: ~100-500 tokens each Per assistant response: ~200-1000 tokens each Per tool call result: ~500-5000 tokens each (exec/read heavy, search light) Compaction summaries: ~2000-5000 tokens each (cumulative!) Count messages and tool calls in recent history, multiply by midpoint estimates. Report as ranges, not false precision. For per-operation cost detail, read references/operation-costs.md.
If .context-policy.yml exists in workspace root, use it as guidance for spawn thresholds and task categories. Otherwise use these defaults: Always spawn (regardless of context level): Test suites (>3 tests) Multi-file audits (>5 files) Build/deploy pipelines Research tasks (web search + analysis) Bulk file operations Never spawn (keep in main session): Single commands Conversations / discussions Quick edits (1-3 files) Status checks Tasks requiring user input mid-execution Context-dependent (spawn when context exceeds threshold): Above 50%: spawn if task involves >5 tool calls Above 70%: spawn if task involves >2 tool calls When spawning, write detailed task descriptions. Sub-agents have no conversation context β they only know what the task field tells them.
Before compaction or /new, write .context-checkpoint.md in the workspace root (the agent reads this post-compaction): # Context Checkpoint β {date} {time} ## Active Task {what you were doing} ## Key State {bullet list of current state β what's done, what's in progress} ## Decisions Made This Session {numbered list of decisions with rationale} ## Files Changed {list of files modified this session} ## Next Steps {what to do after resuming} This file survives compaction. On session start or post-compaction, check for it and use it to restore context. Delete after consuming. Coordination with OpenClaw memoryFlush: OpenClaw may fire its own pre-compaction flush (writing to daily log). The checkpoint is complementary β the flush saves to the daily log, the checkpoint saves structured resume state. Both should exist. If the memoryFlush fires first, compaction may already be in progress. For critical sessions, write checkpoints proactively at 75%, don't wait for 85%. The scripts/context-checkpoint.sh script handles basic write/read/clear. For the full 5-section checkpoint, write the file directly β multiline content works better that way.
After compaction or /new: Read .context-checkpoint.md if it exists Read today's daily log if the workspace has one (e.g. memory/{today}.md) Resume from the checkpoint's "Next Steps" Delete the checkpoint file after restoring context
When context exceeds 65%, warn: β οΈ Context: {pct}% ({used}k/{total}k). Estimated runway: ~{remaining_calls} tool calls. {recommendation} Recommendations by level: 65%: "Spawning sub-agents for remaining tool-heavy work." 75%: "Recommend compacting soon. Writing checkpoint." 85%: "Context critical. Writing checkpoint now. Suggest /compact or /new."
After significant work (or on request), profile the current session and recommend config changes.
Run session_status. Count approximate tool calls and message exchanges. Classify: PatternSignatureExampleTool-heavyMost context from tool results, many exec/read/web callsAudits, migrations, test suites, debuggingConversationalMost context from messages, few tool callsPlanning, discussion, decisionsMixedRoughly even splitFeature builds (discuss β code β test β discuss)BurstyLong quiet periods with intense tool burstsMonitoring + incident response
There are four settings that matter. When explaining them to the user, always describe what they do in practice, not just the setting name: 1. When to compress the conversation (reserveTokensFloor) How full the context gets before the agent summarises and compresses the history. A higher number means it compresses sooner β producing a shorter summary with more room left afterwards. 30000 β waits until nearly full. Risk: huge summary, little room after. 50000 β compresses at ~75% full. Good balance. 60000 β compresses early at ~70%. Maximum breathing room. 2. How quickly old tool output is cleared (pruning TTL) After you stop talking for this long, the agent clears old command outputs, file reads, and search results from memory. Shorter = more aggressive cleanup. 5m β only clears after 5 minutes of silence. Rarely fires during active work. 2m β clears after 2 minutes. Good for most workflows. 1m β aggressive. Clears fast, but you might need to re-read files. 3. How many recent exchanges are protected from cleanup (keepLastAssistants) When clearing old tool output, this many of your most recent back-and-forth exchanges are kept untouched. 3 β keeps more history visible. Good for conversations. 2 β moderate protection. 1 β only the last exchange is safe. Most aggressive cleanup. 4. Minimum size before tool output gets trimmed (minPrunableToolChars) Only tool results larger than this (in characters) are eligible for trimming. Lower = more things get cleaned up. 50000 (default) β only trims very large outputs (long file reads, huge command output). 10000 β also trims medium outputs. Catches more. 5000 β aggressive. Most tool results are eligible. Recommended combinations by work style: Work styleCompress atClear afterProtectTrim aboveTool-heavy (audits, tests, debugging)600001m110000Conversational (planning, discussion)300005m350000Mixed (code β test β discuss)500002m210000Bursty (monitoring + incidents)500002m110000 Additional tips: Sessions with browser/canvas work: Ensure those tools are protected from cleanup in the config Long-running sessions (>2h): Use a higher compression trigger to survive multiple rounds
Use a compact list format β tables render poorly on mobile and narrow chat windows. For each setting, show current vs recommended only if they differ. Skip settings that are already correct. π Current Session Profile: {pattern} Context: {pct}% ({used}k/{total}k) Β· Compressions: {c} β When to compress β {current_description}. Good for this work style. β Clear old output after β {current_description}. No change needed. β οΈ Protect last exchanges β currently {current}, recommend {recommended}. {why} β Trim output above β {current_description}. No change needed. Estimated runway: ~{time_or_calls} before next compression. Lead with what's already right (builds confidence), then highlight what needs changing and why. Keep it short β the user wants a verdict, not a lecture. If changes are recommended, tell the user everything up front before asking for approval: Exact file being modified (full path β get from gateway config.get) Exact changes β setting name, current value, new value What happens β gateway restart (~2-3 second pause, auto-reconnects) Safety net β backup taken first, rollback doc written to temp directory Example closing: One change recommended: File: {config_path} Change: {setting_name}: {old_value} β {new_value} Applying means: I'll back up the config file first, write a rollback doc to {temp_path}, then restart the OpenClaw gateway (~2-3 second pause while it reloads). Want me to go ahead? For multiple changes, list each one. Never summarise as "4 changes" β spell them out. Never ask "want me to apply?" without the user seeing the exact file, exact values, and exact consequences. The user decides with full information, not blind trust. If the user agrees, follow the full procedure below.
After giving advice, note the session pattern and outcome in the daily log (if the workspace keeps one). Over multiple sessions, patterns emerge β the user's typical work style becomes clear and default config can be permanently tuned.
When recommending config changes, follow this exact sequence. No shortcuts.
Run gateway config.get to get the config file path and current values. Do not assume the path β it varies by installation.
cp <config_path> <config_path>.backup-$(date +%Y%m%d-%H%M%S)
Tell them: Which file is being modified (full path β get it from gateway config.get) What values change (before β after table) What "restart" means β the OpenClaw gateway process restarts (not the machine, not any other service). Brief 2-3 second pause, then the session reconnects automatically. Where the backup is (full path) Where the rollback doc is (full path) How to check if something goes wrong
Use the gateway tool with action: config.patch. Include a clear note parameter β this message is delivered to the user after the gateway restarts.
For detailed config options and profiles: references/config-guide.md For per-operation cost estimates: references/operation-costs.md
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.