Context Window & Compaction
Every model has a context window (max tokens it can see). Long-running chats accumulate messages and tool results; once the window is tight, Kurahi compacts older history to stay within limits.
What compaction is
Section titled “What compaction is”Compaction summarizes older conversation into a compact summary entry and keeps recent messages intact. The summary is stored in the session history, so future requests use:
- The compaction summary
- Recent messages after the compaction point
Compaction persists in the session’s JSONL history.
Configuration
Section titled “Configuration”See Compaction config & modes for the agents.defaults.compaction settings.
Auto-compaction (default on)
Section titled “Auto-compaction (default on)”When a session nears or exceeds the model’s context window, Kurahi triggers auto-compaction and may retry the original request using the compacted context.
You’ll see:
🧹 Auto-compaction completein verbose mode/statusshowing🧹 Compactions: <count>
Before compaction, Kurahi can run a silent memory flush turn to store durable notes to disk. See Memory for details and config.
Manual compaction
Section titled “Manual compaction”Use /compact (optionally with instructions) to force a compaction pass:
/compact Focus on decisions and open questionsContext window source
Section titled “Context window source”Context window is model-specific. Kurahi uses the model definition from the configured provider catalog to determine limits.
Compaction vs pruning
Section titled “Compaction vs pruning”- Compaction: summarises and persists in JSONL.
- Session pruning: trims old tool results only, in-memory, per request.
See /concepts/session-pruning for pruning details.
- Use
/compactwhen sessions feel stale or context is bloated. - Large tool outputs are already truncated; pruning can further reduce tool-result buildup.
- If you need a fresh slate,
/newor/resetstarts a new session id.