Repository navigation
Open
Description
Summary
Compaction destroys the details a session is built on, and there is no way to undo it or to undo individual steps. A session carrying ~244,000 tokens of exact constraints, debugging state and 300–400 tool calls can be compacted into ~2,000 tokens of vague prose that drops every boundary, constraint and step the user issued — and once compacted, the work is gone: undoing the compaction itself is impossible, and forking before the compaction point re-imports all 300+ tool calls without the detail that made them usable.
Two requests:
- Undo granularity — currently a revert/undo point is tied to a user prompt. A single prompt can trigger 300+ tool calls and hundreds of file edits, and the user has no way to step back three tool calls or three file edits while keeping the rest.
- Undo compaction — there is no way to restore the pre-compaction history.
/compactis one-way, and the compaction summary is shown as if it were the new state with no restore path.
This combination makes compaction a one-way door: after a heavy session is compacted the session is effectively unusable and unrecoverable without starting over.
Environment
- opencode version: 2.0.26
- OS: Linux 6.18.55-1-lts x86_64 GNU/Linux
- Terminal: xterm-256color (COLORTERM=truecolor, TERM_PROGRAM unset)
- Shell: /bin/bash
- Install/channel: latest
- Active plugins: none found in config
- Related session:
ses_edd90d634ffe1MTsEt6p5Tlbel(projectgerman-app-thinking-method), ~2.66M input tokens and ~339 compaction-era messages before the destructive compaction; forksses_edad1b600ffeA2ugmIegQBxzAE,ses_edad25875ffeQ1jEj5bPSrCjdQ
Reproduction
- Run a long session where one prompt drives ~300–400 tool calls and hundreds of file edits, under explicit user constraints (boundaries, "don't do X" instructions, style rules).
- Request a manual
/compact. - Inspect the resulting summary: exact constraints, paths, error strings, versions, debugging state ("tested X, ruled out because Y") and most of the tool-call record are reduced to vague prose.
- Attempt to undo:
- Undo the compaction — no such operation exists.
- Revert to an earlier point — the only unit is a user prompt, so reverting drops the entire prompt's worth of work, and forking from a pre-compaction point re-imports all 300+ tool calls without the detail that made them usable.
Expected Behavior
- Compaction should carry forward every user-stated constraint, boundary, style instruction, exact identifier/path/value/version/error string, and the investigation state, verbatim where possible — not generalized prose.
/compactshould be reversible: restore the pre-compaction history, or at minimum keep it retrievable (e.g./compact --undo, or a compaction checkpoint that can be reverted like a message revert).- Undo should be finer-grained than a prompt: stepping back N tool calls / N file edits while keeping the surrounding work.
Actual Behavior
- The compaction summary loses: all user-imposed constraints and boundaries, most exact technical details (paths, flag names, config keys, error strings, versions), the debugging state (what was tried, what was ruled out, with what evidence), and the granular tool-call record. The post-compaction session "forgets" the constraints and repeats questions already answered.
- No undo of the compaction itself. No restore of pre-compaction history.
- Undo/revert granularity is one user prompt. A prompt that caused 300+ tool calls cannot be partially reverted.
Additional Context
- The compaction summary is presented as the new state ("what is it now"), with no compare view against the pre-compaction history and no restore path.
- Compaction-recovery precedent in this repo is already visible in related requests ([FEATURE]: Improve compaction prompt to preserve critical context details #16512 — compaction prompt too generic, loses user constraints/pasted content/technical specifics; Compaction updates made the models dumber #25746 — "compaction updates made the models dumber"; Failed compaction silently drops pre-tail history from the model context #42282 — "Failed compaction silently drops pre-tail history from the model context"). This report adds the missing half: there is no way back, so it is a data-loss/recoverability problem, not only a quality-of-summary problem.
- A plugin workaround exists for the prompt side (
experimental.session.compactingcan fully replace the compaction prompt — see the template in [FEATURE]: Improve compaction prompt to preserve critical context details #16512), but nothing addresses undo granularity or undo/restore of a completed compaction.
Suggested fix
- In the default compaction prompt: instruct the summarizer to never generalize names/paths/values/error strings/versions, reproduce key user-pasted content verbatim, preserve all user constraints and preferences, and preserve investigation state (tried / ruled out / evidence).
- Persist the pre-compaction message set as a restorable checkpoint (like the existing snapshot/revert machinery) and expose compact-restore in the TUI.
- Make undo step through tool calls / file edits (mutation epochs, per v2: redesign filesystem snapshots around mutation epochs #44511) instead of prompt boundaries.
Reacted by Szczurek
Metadata
Metadata
Assignees
Labels
No labels
Activity
opencode-agent commentedon Oct 10, 2026
Thanks for the detailed write-up! To restate: you'd like a way out of compaction. That means undoing or restoring a completed
/compactand its pre-compaction history, undo that can step back individual tool calls or file edits instead of a whole prompt, and a default compaction prompt that keeps constraints and exact details word for word. Maintainers will consider this.Related issues:
experimental.session.compactingplugin hook.The undo parts can't be built as a plugin right now, because plugins have no access to session history, revert points or snapshots.
[-][FEATURE]: undo compaction restore pre-compaction history + finer undo granularity[/-][+][FEATURE][URGENT]: undo/restore compaction + finer undo granularity — compaction is a one-way door[/+]samvallad33 commentedon Oct 23, 2026
Hi Shaurya,
Which constraint hurt most to lose when 244k tokens shrank to 2k?
Exact boundaries should resurface when the next edit touches them, not dissolve into prose. Open to a quick demo of a small memory setup that keeps rules and debugging history recallable?
Sam
ngPati commentedon Oct 27, 2026
Same pain here. Until an undo exists, these keep a compaction from costing me the constraints:
"compaction": { "auto": false }.git resetaway.Disclosure: I build VibeiDE (https://vibeide.dev), a desktop app that runs OpenCode, Codex and Claude Code tasks one session per task. A real undo for compaction would still be great.
Nomadu27 commentedon Oct 27, 2026
Agree that compaction shouldn't be one-way. Disclosure: I make Sigillion, memory for coding agents, built for exactly this kind of loss. Claude Code only today; more agent tools are planned for the end of 2026. https://github.com/Sigillion-AI/sigillion