Feature hasn't been suggested before.
Describe the enhancement you want to request
Description:
When a long conversation triggers context compaction, the full conversation history is permanently lost -- only a summary survives. There's currently no way to automatically save or export the session before this happens.
Related issues: #9387 (session export CLI), #7579 (plan persistence across compaction). This request differs in that it proposes an automatic local save triggered before compaction runs, rather than a manual export command.
Use case:
During extended coding sessions, compaction can trigger unexpectedly. The /share command exists but requires manual intervention (and cloud authentication). Users working in air-gapped or corporate environments may not have access to /share at all.
Proposed solution:
Add a pre-compaction lifecycle hook that fires before the context is compacted. This could support:
- Auto-export to a local file -- save the full conversation (messages + tool outputs) to a local file (e.g.,
.opencode/sessions/) before compaction runs
- Plugin hook -- expose a
beforeCompaction event in the plugin system so users can implement custom save logic
- Config option -- a simple config flag like
compaction.save_before: true that writes a local snapshot automatically
Example config:
{
"compaction": {
"auto": true,
"save_before": true,
"save_path": ".opencode/sessions/"
}
}
Why this matters:
- Long sessions accumulate valuable context about decisions, debugging steps, and rationale that's useful to revisit later
- Compaction summaries lose nuance and exact details
- A local-first approach works in all environments without requiring cloud auth
Feature hasn't been suggested before.
Describe the enhancement you want to request
Description:
When a long conversation triggers context compaction, the full conversation history is permanently lost -- only a summary survives. There's currently no way to automatically save or export the session before this happens.
Related issues: #9387 (session export CLI), #7579 (plan persistence across compaction). This request differs in that it proposes an automatic local save triggered before compaction runs, rather than a manual export command.
Use case:
During extended coding sessions, compaction can trigger unexpectedly. The
/sharecommand exists but requires manual intervention (and cloud authentication). Users working in air-gapped or corporate environments may not have access to/shareat all.Proposed solution:
Add a pre-compaction lifecycle hook that fires before the context is compacted. This could support:
.opencode/sessions/) before compaction runsbeforeCompactionevent in the plugin system so users can implement custom save logiccompaction.save_before: truethat writes a local snapshot automaticallyExample config:
{ "compaction": { "auto": true, "save_before": true, "save_path": ".opencode/sessions/" } }Why this matters: