When to compact
- The session has been running long enough that responses are getting slower or hitting context limits.
- You want to preserve the thread’s history in place instead of starting a new session.
- You’re finished with an early phase of work (exploration, scaffolding) and want the summary to anchor the next phase.
Compact a session
- Open the session.
- In the session header, select Compact.
- Select Compact to confirm.
Automatic compaction
Sessions can also be compacted automatically by the runtime when the context window fills up. Automatic compactions show up in the conversation the same way, labeled asCompacted automatically instead of attributed to a user.
API
You can trigger compaction programmatically. The request takes no body.- Returns
204 No Contenton success. - Returns
403 Forbiddenif you aren’t the session owner or an admin. - Returns
409while the session’s OpenCode runtime is still provisioning, and410if the session is archived or deleted.