Skip to content

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

Open
mrmg wants to merge 4 commits into
pingdotgg:mainfrom
mrmg:agent/fix-interrupt-recovery
Open

fix(server): recover from provider interrupt failures#7412
mrmg wants to merge 4 commits into
pingdotgg:mainfrom
mrmg:agent/fix-interrupt-recovery

Conversation

@mrmg

@mrmg mrmg commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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

@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: 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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 18, 2026
@mrmg
mrmg marked this pull request as ready for review August 18, 2026 15:29
Comment thread apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7469c37

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

You can add or adjust custom eligibility rules. Learn more.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Reviewed by Cursor Bugbot for commit 94c2cb0. Configure here.

Comment thread apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
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:unvouched PR author is not yet trusted in 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

1 participant