Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preserve provider history across repeated rollbacks #12676

MergedDerpedyea(GitHub profile, opens in a new tab)merged 1 commit intot3code/codex-turn-mapping fromrefs/pull/12676/headmerged by juliusmarminge View on GitHub

What Changed

Exclude turns from already rolled-back runs when preparing a provider rollback. The audit history stays intact, and the existing rollback test now covers a previous rewind and both rollback targets.

Targets the orchestration V2 branch from #2829.

Fixes #12679.

Why

In a Codex legacy-history thread with turns A, B, C, rewinding to B and then A makes Codex discard A too: T3 still shows one completed turn, but the provider has none. The second rollback incorrectly counts C again even though it was already removed.

Pi hits the same stale-history problem after rewinding to A, adding D, and rewinding to A again: it tries to fork at an already-removed entry. Filtering those turns makes both providers use the current conversation.

Validation

  • Regression fails without the fix; all 13 tests in CheckpointRollbackService.test.ts pass with it.
  • Server typecheck and changed-file lint/format checks pass.
  • Retested in real workspaces with Codex CLI 0.155.1 and GPT-6 Astra (gpt-6-astra). Legacy-history baseline: 3 → 2 → 0 native turns. Fixed: 3 → 2 → 1 → 2 → 1, with matching files and retained turn IDs. All three fixed rollback receipts succeed on the first attempt.
  • Pi 0.86.0 independently reproduced the stale-entry failure and passed with the fix.

The isolated test launcher explicitly requests the supported thread/start.historyMode: "legacy"; all other requests pass unchanged to Codex 0.155.1. Default new sessions use paginated history and hit a separate V2 adapter rejection on the first rewind, before this repeated-rollback bug can be exercised.

Reproduction

New recording: Codex CLI 0.155.1, GPT-6 Astra, legacy history, original rollback implementation. After the second rewind, T3 retains A while the native provider history is empty.

Repeated rollback removes Codex history that T3 still displays

MP4 recording

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included a video for the rollback interaction

Built and verified with GPT-6 Astra in Codex CLI 0.155.1.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at 82396a6

      Macroscope's review found this PR approvable — This focused rollback bug fix filters stale turns from already-rolled-back runs while retaining the durable audit history, preventing repeated rollbacks from acting on provider entries that no longer exist. It includes a targeted regression test and does not alter schemas, defaults, configuration, or deployment behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. juliusmarminge merged this3853888

    4. juliusmarminge closed this

Sign in to join this conversation.