How It Works
Quick Start
CLI Flags
Strategy
| Strategy | Description | Best For |
|---|---|---|
smart | Intelligent combination | General use |
truncate | Remove oldest messages | Fast, simple |
sliding_window | Keep recent N messages | Conversation flow |
summarize | Compress old messages | Context preservation |
prune_tools | Truncate tool outputs | Tool-heavy workflows |
Auto-Compaction
Threshold
Interactive Commands
Manual Compaction
View Optimization History
View Current Config
Environment Variables
config.yaml
Strategy Details
Smart (Recommended)
Combines multiple strategies intelligently:- First tries non-destructive pruning
- Falls back to sliding window
- Uses truncation as last resort
Truncate
Simply removes oldest messages until under budget.Sliding Window
Keeps the most recent N messages that fit in budget.Summarize
Compresses old messages into a summary (requires LLM call).Prune Tools
Truncates old tool outputs while preserving recent ones.Troubleshooting
Context still overflowing
Losing important context
Auto-compact not triggering
Best Practices
Start with smart strategy
Start with smart strategy
smart combines pruning, sliding window, and summarisation — use it unless you have a specific reason not to.Set threshold below 1.0
Set threshold below 1.0
Trigger compaction at 0.7–0.8 so optimisation runs before the model hard-fails on context overflow.
Use /context stats during long sessions
Use /context stats during long sessions
Check token usage before manually compacting —
/context history shows what each compaction saved.Related
Context Optimizer
Python API and strategy reference
Context Monitor
Watch optimisation in action
Context Budgeter
Set token budgets per session
Intelligent Conversation Compaction
Long-session compaction deep-dive

