fix(orchestrator): surface provider turn interrupt failures in the thread #4621
main fromrefs/pull/4621/head·opened View on GitHubFixes #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:
formatFailureDetailis reused, so aProviderAdapterRequestErrorsurfaces itsdetail(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.
Note
Surface provider turn interrupt failures as activities in the thread#
- In
ProviderCommandReactor.processTurnInterrupt, wrapsproviderService.interruptTurnwithEffect.catchCauseto handle failures gracefully. - On failure, appends a
provider.turn.interrupt.failedactivity with formatted detail viaappendProviderFailureActivity; interrupt-only causes are silently ignored. - Adds a test verifying that a
ProviderAdapterRequestErrorfrominterruptTurnproduces the expected failure activity with correct tone, turnId, and payload detail.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
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).Closing in favor of #2829 (orchestration V2).
#2829 deletes the V1 orchestration layer this PR builds on —
apps/server/src/orchestration/**,provider/Layers/*Adapter.tsandprovider/Services/**are removed and replaced byapps/server/src/orchestration-v2/**, with the IPC surface renamed toORCHESTRATION_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.juliusmarminge 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:
83f4ae1e-2486-406c-8a0e-3d0322e0e64eYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
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