Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): threads mid-turn continue after a restart on every provider #14182

Mergedjuliusmarmingemerged 1 commit intot3code/codex-turn-mapping fromrefs/pull/14182/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Addresses #13331 (item 1).

With "Continue threads after restarts" on, a Codex, Claude, Cursor or ACP thread that was mid-turn when the server restarted is cancelled and left for a manual continue. restartContinuationRun only keeps a live turn when its provider session is "running", but only the OpenCode and Pi adapters ever write that status. Codex, Claude, Cursor and ACP create the session as "ready" and never promote it; ProviderSessionManager persists only "stopped" / "error" on release.

What changed

restartContinuationRun now rules out a live turn only when the session is "stopped" or "error". That is the same "live session" test recovery itself (ProviderRuntimeRecoveryService), ProjectionStore and ProviderSwitchService already use. The other gates are unchanged: the run must be running, the provider thread active with a strong native ref, and a provider turn for the run's active attempt must be running.

OpenCode's "waiting" (pending permission/question) now qualifies too. That thread was mid-turn, so resuming it is the intended behavior.

Verification

  • New test continues a live turn whose session the adapter never marked running in RestartContinuation.test.ts: fails on the base branch (starting: expected undefined to equal 'run:restart'), passes with the fix. It covers starting/ready/running/waiting (continue) and stopped/error (don't).
  • vp test run src/orchestration-v2/RestartContinuation.test.ts src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts src/orchestration-v2/ProjectionRecovery.test.ts: 30 passed.
  • vp exec tsc --noEmit -p . in apps/server: no errors. vp lint on both touched files: clean.
  • Not run: a live restart against a real provider. Adapter session statuses were checked from source (CodexAdapterV2.ts providerSession(), ClaudeAdapterV2.ts, CursorAdapterV2.ts, AcpAdapterV2.ts all set "ready"; only OpenCodeAdapterV2.ts / PiAdapterV2.ts emit "running").

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


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

    2. Approvability

      Verdict: Approved at 3680767

      Macroscope's review found this PR approvable — This is a tightly scoped restart-recovery bug fix: it broadens an existing session-status check so mid-turn continuations work for all supported providers while retaining the stopped/error safeguards. A focused regression test covers the accepted and rejected states.

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

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.7 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.4 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—4.9 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.7 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—20.7 KiB—29.3 KiB✅
      ClaudeLive turn messages—1—8✅

      Baseline: unavailable · PR result: 3680767 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. juliusmarminge merged this2b9a4ad

    5. juliusmarminge closed this

Sign in to join this conversation.