# Compaction

Session compaction reduces long conversation history while preserving essential context, decisions, and artifacts.

## Why It Matters

- **Token efficiency** — keeps context within model limits for extended sessions
- **Latency** — shorter context means faster model responses
- **Continuity** — prevents the model from losing track of goals in very long conversations

## When to Compact

- Prompts start feeling slower or less responsive
- The model repeats information that was already established
- You've completed a major subtask and want a clean continuation
- Context window warnings appear from the provider

## How Compaction Works

Compaction takes the current session state (file changes, decisions, user goals, tool results) and produces a condensed summary. The summary replaces the older turns in the session while keeping recent turns intact. No external data leaves your environment.

## Compaction Commands

### In the TUI

Trigger compaction via the session menu or by using the compaction keybinding (default: `C` in session view).

### Via CLI

```bash
vox --compact
```

Compaction runs against the current (or most recent) session.

## Best Practices

- Compact when context grows noisy or repetitive, not before every turn
- Explicitly restate critical constraints after compaction if they were in older context
- Keep important decisions and constraints in the session history before compacting
- Re-run critical verification after major compaction points
- Combine with session branching to preserve pre-compaction state as a branch

## Related

- [Sessions](sessions.md) — session lifecycle and branching
- [session-format.md](session-format.md) — on-disk session structure
