Skip to content

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

Closed
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:t3code/fix-pr-7368
Closed

fix(server): settle turns when provider interrupts fail#7376
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:t3code/fix-pr-7368

Conversation

@StiensWout

@StiensWout StiensWout commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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 for commit 4eb952e. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 18, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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.

@t3dotgg

t3dotgg commented Aug 24, 2026

Copy link
Copy Markdown
Member

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 t3dotgg closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop button leaves a thread stuck "Working" forever when the provider's abort fails

2 participants