From 87cb5bc0ad02583d3ce6e62b545b05dc63511df7 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 1 Aug 2026 15:10:18 +0530 Subject: [PATCH] fix(orchestration-v2): model task stop failures directly Co-Authored-By: Claude Fable 5 --- .../Adapters/ClaudeAdapterV2.ts | 34 ++++++++++--------- .../ProviderTurnControlService.ts | 3 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index bdea5401cf..53daae3d96 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -602,22 +602,24 @@ export const claudeAgentSdkQueryRunnerLiveLayer: Layer.Layer< ), ), stopTask: (taskId) => - Effect.tryPromise({ - try: () => { - // stopTask is deliberate wire surface (the CLI's own - // /workflows view stops through it) but absent from the - // published SDK types — this cast is the single place the - // undocumented method is read. - const stop = (queryRuntime as { stopTask?: (taskId: string) => Promise }) - .stopTask; - if (stop === undefined) { - throw new Error( - "The Claude SDK runtime for this session does not expose stopTask.", - ); - } - return stop.call(queryRuntime, taskId); - }, - catch: (cause) => queryRunnerError(cause, "stopTask"), + Effect.suspend(() => { + // stopTask is deliberate wire surface (the CLI's own + // /workflows view stops through it) but absent from the + // published SDK types — this cast is the single place the + // undocumented method is read. + const stop = (queryRuntime as { stopTask?: (taskId: string) => Promise }) + .stopTask; + return stop === undefined + ? Effect.fail( + new ClaudeAgentSdkQueryRunnerError({ + method: "stopTask", + cause: "The Claude SDK runtime for this session does not expose stopTask.", + }), + ) + : Effect.tryPromise({ + try: () => stop.call(queryRuntime, taskId), + catch: (cause) => queryRunnerError(cause, "stopTask"), + }); }).pipe( Effect.tap(() => logProtocolEvent({ diff --git a/apps/server/src/orchestration-v2/ProviderTurnControlService.ts b/apps/server/src/orchestration-v2/ProviderTurnControlService.ts index 732635ab47..507c748303 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnControlService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnControlService.ts @@ -47,6 +47,7 @@ export class ProviderTaskStopError extends Schema.TaggedErrorClass - Schema.is(ProviderTaskStopError)(cause) + isProviderTaskStopError(cause) ? cause : new ProviderTaskStopError({ threadId: input.threadId,