Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(orchestrator): surface provider turn interrupt failures in the thread #4621

Closedm-de-graaff(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/4621/headopened View on GitHub

Fixes #4524

Problem

When the provider rejects turn/interrupt, the failure goes nowhere the user can see. processTurnInterruptRequested issues the call bare:

yield* providerService.interruptTurn({ threadId: event.payload.threadId });

so the cause propagates up to processDomainEventSafely, which terminates it in a logWarning. The orchestration command is still receipted accepted, thread.turn-interrupt-requested is persisted normally, and no activity is appended. Stop generation looks like it worked while the turn keeps running, and the only trace is a line in server-child.log. The reporter clicked it 16 times in 17 seconds — 16 accepted receipts, 0 receipt errors, 0 activities.

Change

The mechanism already exists and is already used one branch up in the same function: the "no active provider session" case appends a provider.turn.interrupt.failed activity. The sibling processApprovalResponseRequested likewise wraps its provider call in Effect.catchCause → appendProviderFailureActivity. The interrupt call was simply not wired to it.

This catches the cause and appends the same activity kind, so a rejected interrupt now shows up in the thread exactly like the missing-session case:

  • formatFailureDetail is reused, so a ProviderAdapterRequestError surfaces its detail (expected active turn id X but found Y) instead of a pretty-printed cause. That is the same helper the turn-start failure path uses.
  • Interrupt-only causes stay silent, matching handleTurnStartFailure.

No client change is needed: the thread already renders tone: "error" activities, which is the behavior the issue asks for.

Tests

ProviderCommandReactor.test.ts — new case makes interruptTurn fail with a ProviderAdapterRequestError and asserts a provider.turn.interrupt.failed activity lands on the thread carrying the provider's own detail and the requested turn id.

I confirmed it is not vacuous: with the source change stashed the new test fails, and it passes with the change. vp test run src/orchestration/Layers/ProviderCommandReactor.test.ts — 35 passed.

The interruptTurn mock is now declared as vi.fn<ProviderServiceShape["interruptTurn"]> so a failing effect is assignable, matching how respondToRequest is already declared in that harness. The test is written with effectIt.effect rather than Effect.runPromise, so it adds no new entries against the no-manual-effect-runtime-in-tests baseline.

Typecheck, lint, and format clean for apps/server.

Out of scope

The issue also notes that its own trigger came from a downstream turn/steer implementation adopting the steer response'"'"'s turn id as the active one, and flags that #231 could land in the same state. That is a separate concern; this PR only makes any such rejection visible.

🤖 Generated with Claude Code


Note

Low Risk Localized orchestration error-handling around interrupt; no auth or data-model changes, and behavior aligns with existing approval-response failure surfacing.

Overview When Stop generation triggers turn/interrupt, a provider rejection used to disappear into server logs while the command still looked accepted. This change wires processTurnInterruptRequested so interruptTurn failures are caught and surfaced as a provider.turn.interrupt.failed thread activity (same path as the no-session case and approval responses), using formatFailureDetail so adapter errors show their detail text.

Interrupt-only causes are still swallowed, matching turn-start failure handling. A reactor test mocks a failing interruptTurn and asserts the error activity appears with the expected tone, turn id, and payload.

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

Note

Surface provider turn interrupt failures as activities in the thread

  • In ProviderCommandReactor.processTurnInterrupt, wraps providerService.interruptTurn with Effect.catchCause to handle failures gracefully.
  • On failure, appends a provider.turn.interrupt.failed activity with formatted detail via appendProviderFailureActivity; interrupt-only causes are silently ignored.
  • Adds a test verifying that a ProviderAdapterRequestError from interruptTurn produces the expected failure activity with correct tone, turnId, and payload detail.
Macroscope summarized 4be0c97.
    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: 83f4ae1e-2486-406c-8a0e-3d0322e0e64e

      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
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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. Approvability

      Verdict: Approved

      Straightforward bug fix that adds error handling to surface interrupt failures to users. The change wraps an existing call with catch logic using patterns already established in the file, and includes a comprehensive test.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    5. juliusmarminge closed this

Sign in to join this conversation.