4-Tier Pruning System
The guard daemon now uses 4 tiers instead of 2, with reload where it matters:
| Tier | Threshold | Prescription | Reload? | Purpose |
|---|---|---|---|---|
| Soft | 25% | gentle (5) | No | Background file maintenance |
| Hard1 | 55% | standard (11) | Yes | First real prune — context drops to ~10-15% |
| Hard2 | 80% | aggressive (18) | Yes | Emergency — last chance before CC compaction |
| User | 90% | aggressive | Yes | Manual last resort |
Key insight: Claude Code reads the JSONL once at session start and keeps the conversation in memory. Pruning without reload doesn't affect what Claude sends to the API. The old system pruned at 75% without reload — effective savings were zero until restart. Now the first real prune happens at 55% WITH reload, so it immediately takes effect.
On 1M context (Opus/Sonnet 4.5/4.6):
- 25% = 250K → gentle cleanup (no API effect, but file is lean for restarts)
- 55% = 550K → standard + reload → drops to ~10-15%, gives 400K tokens of runway
- 80% = 800K → aggressive + reload → catches what standard missed
- CC auto-compaction fires at ~967K (96.7%) — we prune well before that
Same-Terminal Resume (macOS)
On reload, the guard now sends keystrokes to the frontmost terminal instead of opening a new window. Falls back to new window if keystroke delivery fails.
Install / Upgrade
pip install --upgrade cozempic