Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): recover from provider interrupt failures #7412

Mergedmrmg(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/7412/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Fixes #7368

Problem

If a provider rejects an interrupt request, the projected session remains running and leaves the thread stuck in a working state.

Fix

Stop the provider session best-effort, then project the session as stopped, clear its active turn, and record the provider failure. Cancellation-only stop failures remain cancellations.

Verification

  • vp test run apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
  • vp run --filter t3 typecheck
  • vp fmt --check apps/server/src/orchestration/Layers/ProviderCommandReactor.ts apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts

Created with GPT-5.6-terra in T3 Code.

Note

Fix ProviderCommandReactor to recover from provider interrupt failures

When providerService.interruptTurn fails during a thread.turn-interrupt-requested event, the reactor now stops the session, clears activeTurnId, records the failure detail in lastError, and emits a provider.turn.interrupt.failed activity.

  • Recovery is skipped if the session is already stopped, ready, or has progressed to a different active turn, preventing stale state overwrites.
  • If stopSession itself fails during recovery, a warning is logged but the failure is otherwise swallowed (except for pure interrupts).
  • Three new tests cover: interrupt failure with an active turn, interrupt failure for a starting session, and the case where the session becomes ready before the interrupt fails.
Macroscope summarized 7469c37.

Note

Medium Risk Changes orchestration session lifecycle on interrupt failures in a critical reactor path, though recovery is guarded against overwriting ready/stopped state and is covered by new tests.

Overview When a user interrupts a turn but providerService.interruptTurn fails, threads no longer stay stuck in a running/working session state.

processTurnInterruptRequested now catches interrupt failures and runs recovery: it re-reads the latest projected session, skips work if the session already became ready, stopped, or the active turn changed, otherwise best-effort stopSession, then projects the session as stopped with activeTurnId cleared, lastError set from the provider error, and a provider.turn.interrupt.failed activity. Cancellation-only failures on stop are logged and do not block that projection.

Tests add injectable interruptTurnEffect / stopSessionEffect hooks and cover running and starting sessions, plus a race where natural completion to ready must not be overwritten.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7469c378fd89fb7dd890e207c4315600e974e527. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 1602f7d4-1c71-4339-a3ef-47a82e360d5f

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 7469c37

      Macroscope's review found this PR approvable — ...

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 94c2cb0028f79addcd91482f9ef9716522365016. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.