You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]:Add pre-compaction hook for session save/export #14164
I have verified this feature I'm about to request 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
Activity
github-actions commentedon Apr 20, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.