Compact a long conversation to free context

sessions & tui

// what it does

/compact replaces the conversation so far with an AI-written summary, reclaiming context space while preserving the gist so you can keep going in the same session. opencode also auto-compacts as you approach the model's context limit, so you rarely hit a hard wall mid-task.

// shortcut

Ctrl+X C

// shell

$ /compact

// gotcha

Compaction is lossy — fine detail from early messages can vanish. Before compacting, capture anything critical (a file path, a decision) in AGENTS.md or a commit so it survives the summary.

// resources