fix(server): settle turns when provider interrupts fail #7376
main fromrefs/pull/7376/head·opened View on GitHubThe 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.interruptTurnfails, the handler now attemptsproviderService.stopSession, marks the thread session as error with the failure detail, and appends aprovider.turn.interrupt.failedactivity. - If
stopSessionalso fails, a warning is logged with both the stop cause and the original interrupt cause; the thread is still settled. - Renames the internal
setThreadSessionErrorOnTurnStartFailureutility tosetThreadSessionErrorand 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.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
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).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.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
3771a625-4da0-401d-88b3-d2cd2b384864You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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