text
| 1 | # Context Compaction |
| 2 | |
| 3 | A long task does not fail at the context limit, it degrades well before it. The agent |
| 4 | starts forgetting decisions it made an hour ago, re-litigates settled questions, and |
| 5 | re-reads files it already understood. This harness compacts deliberately: it decides |
| 6 | in advance what must survive, writes a checkpoint that can be resumed cold, and drops |
| 7 | the rest. |
| 8 | |
| 9 | ## When to use |
| 10 | |
| 11 | - Multi-hour or multi-session tasks: migrations, large refactors, long investigations. |
| 12 | - Any agent loop that runs until a goal is met rather than for a fixed number of steps. |
| 13 | - Work that may be interrupted and picked up later, possibly by someone else. |
| 14 | |
| 15 | ## Install |
| 16 | |
| 17 | ```bash |
| 18 | npx openagents-cli add openagents/context-compaction |
| 19 | ``` |
| 20 | |
| 21 | | Runtime | Installed to | |
| 22 | |---|---| |
| 23 | | `claude-code` | `.claude/skills/context-compaction/` | |
| 24 | | `codex` | `.codex/skills/context-compaction/` | |
| 25 | | `openai-agents` | `agents/context-compaction/` | |
| 26 | | `langgraph` | `graphs/context-compaction/` | |
| 27 | | `generic` | `.openagents/context-compaction/` | |
| 28 | |
| 29 | ## What is in the package |
| 30 | |
| 31 | - `HARNESS.md` - what survives compaction, what does not, and when to trigger it. |
| 32 | - `templates/checkpoint.md` - the checkpoint format, resumable without the transcript. |
| 33 | |
| 34 | ## License |
| 35 | |
| 36 | MIT |
| 37 |