Skip to content

[FEATURE] Ability to rewind/undo the last message exchange without clearing the full session #47593

Description

@huangzhen1997

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

When exploring a complex topic, I often ask a broad question and get a large, multi-faceted response. I then want to dive deeper into one specific detail — but after that sub-conversation, I want to return to the original context
cleanly, as if the detour never happened.

Currently there's no way to do this without either:

  • /clear — loses everything, including the valuable original response
  • /compact — summarizes history but doesn't surgically remove the detour
  • Double-escape checkpoint — only reverts file changes, conversation history stays

Proposed Solution

A command (e.g., /undo or /rewind 1) that removes the last N message exchanges (user message + assistant response) from the active context window, freeing those tokens and restoring the conversation to its prior state.

Why this matters

Token context is a finite resource. When drilling into a sub-question produces a large but ultimately tangential exchange, there's no way to reclaim that context budget. This forces users to either abandon the session or carry
dead weight through the rest of the conversation, degrading response quality on the original topic.

Expected behavior

  • /undo removes the last user+assistant message pair from context
  • /undo 3 removes the last 3 pairs
  • Does not affect file changes already made on disk
  • Session JSONL could soft-delete entries (mark as removed) to keep an audit trail without loading them into context

Alternative Solutions

No response

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions