Context Compaction (F2)
Rolling summarization of old conversation turns to stay within context limits.
How It Works
- After each run, check conversation length against the session cap
- If near cap,
compact_history()sends the oldest N messages to the LLM as a one-shot summarization chat - The summary replaces those messages, embedded as a
[CONTEXT SUMMARY]marker - Recent messages stay intact — only the tail is compressed
Session Format v2
Compaction summaries persist across restarts via the session file format v2:
{
"version": 2,
"summary": "User asked about X; we decided Y...",
"messages": [...]
}
Format v1 (bare message array) is still readable — backward compatible.
Config
[gateway]
context_compaction = true