Context
Keep the context window focused on what matters right now.
When to Use
- Session feels slow or responses degrade
- Switching between unrelated tasks
- After completing a major task and pivoting
- Context approaching 60–70% capacity
Compression Strategies
Choose based on how much to recover:
| Strategy | Savings | Risk |
|---|---|---|
| Prune — drop tool outputs, resolved threads | 10–30% | Low |
| Summarize — replace resolved subtasks with 3-bullet summary | 30–60% | Low |
| Checkpoint — save state to file, fresh session | 100% | Medium |
Summarize pattern
Replace a completed subtask block with:
## [SUMMARIZED] Auth refactor — 2026-04-10
- Replaced JWT middleware with JWKS-based validation
- 3 new tests; all green
- Gotcha: validateToken() is now async
Checkpoint pattern
When severely bloated, save state before starting fresh:
.agents/plans/checkpoint-<date>.md:
- Active task: <what you're doing>
- Branch: <name>
- Completed: <bullet list>
- Next step: <exact next action>
- Key decisions: <anything not in git>
Context Prioritization
Keep in context (highest priority first):
- Current task and next step
- Active file contents being modified
- In-progress plan and pending items
- Key decisions not yet committed
- Recent error messages (if debugging)
Drop first:
- Old search results and grep outputs
- File reads that are no longer being modified
- Completed todo items and resolved threads
- Verbose tool execution logs
Steps
- Estimate current context usage (% of limit)
- Identify stale context using the drop-first list above
- Apply the appropriate compression strategy
- Verify active state preserved: branch, files, plan, decisions
- Report what changed
Output
Before: ~N% used
Compacted: <what was removed>
After: ~N% used
Preserved: <key items kept>
Checkpoint: <file path if saved>
Rules
- Never compact active task state
- Preserve: current branch, active files, in-progress plan, key decisions
- Remove: old search outputs, completed todos, resolved threads
- At 80%+ capacity: checkpoint immediately, don't wait for degradation
- Save critical state to a plan file before compacting if work is in progress