feat(cli): /rewind N undoes multiple turns with safer truncation#213
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
feat(cli): /rewind N undoes multiple turns with safer truncation#213emal-avala merged 1 commit intomainfrom
emal-avala merged 1 commit intomainfrom
Conversation
Extends /rewind (and its /undo alias) to accept an optional turn count, so /rewind 3 undoes three turns in one go. The existing version only ever unwound the last assistant reply and did so with an ad-hoc loop that would happily chew through the entire history if the tail wasn't a plain assistant message. The new implementation defines a turn as "the most recent real user prompt plus everything that came after it" and truncates in one pass per turn. Tool results (is_meta) and compact summaries are explicitly excluded from being treated as prompt boundaries, so: - a session whose tail is a tool result never gets mis-truncated - a compacted session can't be rewound past its summary - multi-turn rewinds stop early with a readable message when there's no earlier prompt left 8 new unit tests cover argument parsing (default, numeric, zero/garbage) and the per-turn truncation algorithm (happy path, multi-turn peel, tool-result tail, compact-summary boundary, empty history).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/rewind(alias/undo) now accepts an optional turn count./rewindstill undoes one turn;/rewind 3undoes up to three.is_meta) and compact summaries are no longer treated as prompt boundaries, so a session whose tail is a tool result can't be mis-truncated and a compacted session can't be rewound past its summary.Test plan
cargo clippy -p agent-code --tests --no-deps -- -D warnings— cleancargo test -p agent-code --bin agent commands::tests::— 80 pass (72 prior + 8 new)