Skip to content

[FEATURE]: Make compaction revertible (undo / explicit dialog) #32368

Closed

Description

@gzb1128
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Today compaction (auto on overflow, or manual /compact) collapses earlier turns into a summary and the original messages are filtered out of the active context with no way back.

My use case: after finishing a design discussion I often compact on purpose to hand the model a clean state. But then the model needs concrete implementation details and has to re-grep the codebase. When that happens I want to drop the compaction and continue from the full pre-compaction conversation instead of re-explaining everything.

Proposal: treat compaction as an explicit, reversible step. Keep the pre-compaction history recoverable (it already is in storage — filterCompacted only hides it) and surface an action to revert a compaction and its summary so the session resumes from the uncompacted view. A confirmation/preview dialog before compaction would also make the decision deliberate.

Why it belongs in opencode: compaction is already lossless on disk — the data isn't deleted, only filtered. Revert is mostly a history-selection / presentation concern, not a new storage model. This would make compaction safe to use as a deliberate workflow tool instead of a one-way door.

Activity

  1. github-actions commented on Jun 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. gzb1128 commented on Jun 15, 2026

    @gzb1128
    Author

    Thanks for the pointers — checked all three. My core ask is distinct from each:

    What I'm specifically after: after compaction runs (manual or auto), an action to undo that compaction and resume from the full pre-compaction conversation in the same session — useful when you compacted deliberately but then need the dropped details back without re-explaining or branching. Since the data is already lossless on disk, this is a history-selection concern rather than a storage change.

    Happy to close as a duplicate of #17802 if the maintainers consider in-place revert in scope there; otherwise I think it's complementary.

  3. rekram1-node commented on Jun 15, 2026

    @rekram1-node
    Collaborator

    u can use /revert for this

  4. gzb1128 commented on Jun 15, 2026

    @gzb1128
    Author

    Thanks for the pointer — confirmed /undo does restore the pre-compaction context. I missed earlier that it sets a revert marker at the user message before the compaction marker, and the next prompt's cleanup deletes the compaction message so the full context is sent to the model again.

    So the feature already exists. For anyone else landing here from the TUI: the actual slash command is /undo (paired with /redo), not /revert — "revert" is just the internal service/API name. It wasn't obvious to me that /undo also un-compacts.

  5. neobrain commented on Oct 24, 2026

    @neobrain

    Does this still work for you in 2.x? In my testing, /undo doesn't just revert the compaction operation itself but all history that came before it up until my last message. This is largely defeating the purpose for me, since that's often the part where the agent has independently been running for a while until auto-compaction kicked in.

    Was this the desired behavior for you, or is this a change from 1.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions