Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): settle turns when provider interrupts fail #7376

ClosedStiensWout(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7376/headopened View on GitHub

The stop button could leave a thread showing Working forever when the provider abort failed. The asynchronous reactor left the active turn set, while the provider failure never became visible to the user.

Interrupt failure is now fail-safe: T3 records a provider failure activity, attempts to stop the provider session, and clears the projected active turn even if session cleanup also fails.

Verification

  • pnpm exec vp test run apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
  • pnpm exec vp fmt --check apps/server/src/orchestration/Layers/ProviderCommandReactor.ts apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
  • pnpm exec vp lint --report-unused-disable-directives apps/server/src/orchestration/Layers/ProviderCommandReactor.ts apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
  • pnpm exec vp run --filter t3 typecheck
  • git diff --check

Fixes #7368

Implemented with GPT-5.6 Sol through Codex in T3 Code.


Note

Medium Risk Changes orchestration session state on interrupt failure paths; behavior is localized to ProviderCommandReactor with test coverage, but affects stop-button UX and projected thread state.

Overview Fixes threads that could stay in Working forever when Stop failed because the provider abort errored and the reactor never cleared activeTurnId or surfaced the failure.

Turn interrupt handling in ProviderCommandReactor is now fail-safe: if interruptTurn fails, the reactor tries stopSession, then uses the shared setThreadSessionError helper (renamed from the turn-start-only variant) to set session error, clear activeTurnId, and set lastError, and it records a provider.turn.interrupt.failed activity. Recovery still runs when session stop also fails.

A regression test covers the case where both interrupt and stop fail against an unavailable OpenCode server.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4eb952e4e73bcc2180a8a218cb3238a3012a4648. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Handle provider turn interrupt failures by settling thread session with error state

  • When providerService.interruptTurn fails, the handler now attempts providerService.stopSession, marks the thread session as error with the failure detail, and appends a provider.turn.interrupt.failed activity.
  • If stopSession also fails, a warning is logged with both the stop cause and the original interrupt cause; the thread is still settled.
  • Renames the internal setThreadSessionErrorOnTurnStartFailure utility to setThreadSessionError and reuses it across both turn start and interrupt failure paths in ProviderCommandReactor.ts.
  • Interrupt-only causes (e.g. fiber cancellation) still short-circuit as interrupts without triggering recovery.
  • Behavioral Change: provider turn interrupts that previously propagated errors now produce a settled error session state instead.
Macroscope summarized 4eb952e.
    1. 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: 3771a625-4da0-401d-88b3-d2cd2b384864

      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:trusted

    3. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This bug fix adds error handling when provider interrupts fail, ensuring threads settle to an error state rather than remaining inconsistent. While the change is focused and includes tests, the orchestration error-handling logic and the author's limited history with this file warrant human review.

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

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Closing in favor of #7412. It already fixes the same provider interrupt failure and clears the stuck thread state.

Sign in to join this conversation.