Skill for context window management in long-running agent sessions. Prevents context exhaustion through proactive compression and delegation. Used by orchestrators and long-running worker agents.
Preventing context exhaustion in long-running investigations.
Use this skill when:
context_warning or context_critical directiveLong investigations accumulate 30+ OODA cycles of tool calls, reasoning, and outputs. Without management, agents lose strategic reasoning ability after exhausting their context window. Checkpoint files preserve state on disk, but the agent's conversation memory — the accumulated reasoning chain — fills up and cannot be recovered without intervention.
When context pressure is detected (by dispatcher directive or self-monitoring):
/compact
This compresses your conversation history in-place, recovering 60-70% of
context budget without restarting. Checkpoint files and .swarm/ state survive
because they're on disk, not in conversation context.
/context to get ground-truth token usage/context
This outputs something like:
● Context Usage
claude-opus-4.6 · 50k/200k tokens (25%)
○ System/Tools: 22.6k (11%)
◉ Messages: 27.3k (14%)
· Free Space: 109.6k (55%)
◎ Buffer: 40.4k (20%)
voronoi_write_checkpoint call:{
"context_snapshot": {
"model": "claude-opus-4.6",
"model_limit": 200000,
"total_used": 50000,
"system_tokens": 22600,
"message_tokens": 27300,
"free_tokens": 109600,
"buffer_tokens": 40400
}
}
The dispatcher reads this snapshot and:
events.jsonl for timeline analysiscontext_window_remaining_pct from free_tokens / model_limitIf you notice forgetting earlier findings or repeating work:
/context to check token usage/compact proactivelyAfter running /compact, re-read your checkpoint to restore strategic context
If still above 90% after compacting, delegate remaining work to fresh agents
When you read .swarm/dispatcher-directive.json:
| Directive | Required Action |
|---|---|
context_advisory | Prioritize convergence, avoid opening new threads |
context_warning | Run /compact NOW, then delegate remaining work to fresh agents |
context_critical | Run /compact NOW, write checkpoint, dispatch Scribe immediately |
| Mechanism | What It Compresses | When |
|---|---|---|
/compact (you run this) | Your conversation history (context window) | On directive or self-detected pressure |
| Checkpoint files | Strategic state snapshot on disk | Every OODA cycle |
Targeted bd query | Avoids loading full task list into context | Routine cycles (never bd list --json) |
| Belief map compression | Hypothesis space | When >10 hypotheses active |
Checkpoint + file state survives /compact because they're on disk, not in
conversation context. The agent reads checkpoint at each OODA cycle start, so
compacted conversation history doesn't lose critical state — only the raw
reasoning chain is summarized.