Skip to content

[Bug]: Revert restores files and timeline but leaves the reverted turns in the agent's context #6127

Description

@cristip73

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Open a thread in a git workspace with the Claude provider and complete several turns.
  2. Hover a user prompt a few turns back and use Revert to this message. Let the revert finish.
  3. Confirm the visible rollback: the later turns are gone from the timeline and the workspace files are restored to the checkpoint.
  4. Send a new prompt that probes memory rather than files, for example: quote verbatim the first five words of my previous prompt.

Expected behavior

After reverting to turn N, the provider session should continue from the conversation state at turn N. The reverted turns should be out of the model's context, so step 4 quotes the last retained prompt.

Actual behavior

The model answers with the prompt from a turn that was reverted away. The timeline and the workspace rolled back, but the agent's context did not: the underlying Claude session is resumed at the transcript leaf, so every reverted turn is still in the window.

This is quiet in the worst way. Nothing fails, nothing is logged, and the UI looks exactly right, so the natural assumption is that the model has forgotten what the timeline no longer shows. In my case the model then reasoned about work it had supposedly never done, and I only noticed because I happened to ask it to quote me.

Where it seems to come from, reading main:

  • CheckpointReactor.ts:779 dispatches providerService.rollbackConversation after a successful file restore, which is the right intent.
  • ClaudeAdapter.rollbackThread (ClaudeAdapter.ts:4482) truncates context.turns and refreshes the cursor, but context.lastAssistantUuid is left on the newest assistant message. updateResumeCursor (ClaudeAdapter.ts:1742) builds resumeSessionAt from that field, so the cursor keeps pointing past the revert. In my database it read turnCount: 9 next to a resumeSessionAt from a turn well after the revert point.
  • Even with a correct value, resumeSessionAt never reaches the SDK: the query options built around ClaudeAdapter.ts:4101 pass resume only, and ClaudeAdapter.test.ts:3393 asserts options.resumeSessionAt === undefined under the name "passes Claude resume ids without pinning a stale assistant checkpoint".

I read that last test as deliberate, which is why I am filing this as one question rather than a patch: if the provider session cannot be resumed mid-transcript by design, then revert cannot mean what the timeline implies, and the gap probably belongs in the UI rather than in the adapter. Either direction is fine from where I sit. What is costly is the current silence.

Impact

Major degradation or frequent failure

Version or commit

Desktop 0.0.34-nightly.20260810.1061, source read at main @ 9c7622d

Environment

macOS 26.5.2, Claude provider (claudeAgent), Opus

Workaround

Fork the transcript by hand: copy the session .jsonl truncated at the last assistant message of the retained turn, give the copy a new session id, and point a thread at that session. The resumed context then ends where the timeline ends.

Activity

  1. maslinedwin commented on Aug 16, 2026

    @maslinedwin
    Contributor

    Opened a fix for the Claude revert/resume mismatch: #7198

    After revert, the adapter now points the resume cursor at the last retained assistant message and pins resumeSessionAt only for that post-rollback resume. The next start or sendTurn recreates the Claude query at that uuid, so the model no longer keeps the discarded turns in context. Ordinary resume still omits the pin, so a stale assistant checkpoint is not applied on a normal session restart.

  2. qwertie commented on Aug 22, 2026

    @qwertie

    I could hardly care less about reverting changes, I only want to be able to rewind in order to edit a mistaken message or otherwise repair the agent's context. It's mystifying that I can revert but the conversation is left intact!

    I very much would like to disable all checkpoints completely. But above all, let me rewind the context window.

  3. danielquintas8 commented on Sep 9, 2026

    @danielquintas8

    Confirming this on 0.0.40. I reverted to an earlier message, sent a new prompt, and the model's reply showed it still had the reverted turns. The timeline and the files had rolled back as expected.

    One thing that might help whoever picks this up. The Claude adapter already has the mechanism to rewind the provider's own context, but the revert path does not use it.

    apps/server/src/provider/Layers/ClaudeAdapter.ts carries resumeSessionAt on the resume context, set from context.lastAssistantUuid:

    ...(context.resumeSessionId ? { resume: context.resumeSessionId } : {}),
    ...(context.lastAssistantUuid ? { resumeSessionAt: context.lastAssistantUuid } : {}),

    Grepping for resumeSessionAt or lastAssistantUuid under apps/server/src/orchestration returns nothing, while the same term appears in three files under apps/server/src/provider. So checkpoint revert rolls back the timeline and the workspace, then continues against a provider session that still holds the full history, because nothing tells it which message to resume from.

    If that reading is right, the fix may be to carry the target turn's assistant UUID through the revert and reuse the existing resumeSessionAt path, rather than to add a new mechanism.

    Checked against main at 6c58362.

  4. juliusmarminge commented on Sep 12, 2026

    @juliusmarminge
    Member

    Fixed by #11338 (merged to main) — Edit from here / rewind now restores provider history (Claude fork + Codex paginated thread/revert) so reverted turns leave the agent's context.

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

Metadata

Metadata

Assignees

No one assigned

    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