Skip to content

Commit 27ecbe1

Browse files
shivamhwpclaude
andcommitted
fix(orchestration-v2): model task stop failures directly
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent d935c9c commit 27ecbe1

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -595,22 +595,24 @@ export const claudeAgentSdkQueryRunnerLiveLayer: Layer.Layer<
595595
),
596596
),
597597
stopTask: (taskId) =>
598-
Effect.tryPromise({
599-
try: () => {
600-
// stopTask is deliberate wire surface (the CLI's own
601-
// /workflows view stops through it) but absent from the
602-
// published SDK types — this cast is the single place the
603-
// undocumented method is read.
604-
const stop = (queryRuntime as { stopTask?: (taskId: string) => Promise<void> })
605-
.stopTask;
606-
if (stop === undefined) {
607-
throw new Error(
608-
"The Claude SDK runtime for this session does not expose stopTask.",
609-
);
610-
}
611-
return stop.call(queryRuntime, taskId);
612-
},
613-
catch: (cause) => queryRunnerError(cause, "stopTask"),
598+
Effect.suspend(() => {
599+
// stopTask is deliberate wire surface (the CLI's own
600+
// /workflows view stops through it) but absent from the
601+
// published SDK types — this cast is the single place the
602+
// undocumented method is read.
603+
const stop = (queryRuntime as { stopTask?: (taskId: string) => Promise<void> })
604+
.stopTask;
605+
return stop === undefined
606+
? Effect.fail(
607+
new ClaudeAgentSdkQueryRunnerError({
608+
method: "stopTask",
609+
cause: "The Claude SDK runtime for this session does not expose stopTask.",
610+
}),
611+
)
612+
: Effect.tryPromise({
613+
try: () => stop.call(queryRuntime, taskId),
614+
catch: (cause) => queryRunnerError(cause, "stopTask"),
615+
});
614616
}).pipe(
615617
Effect.tap(() =>
616618
logProtocolEvent({

‎apps/server/src/orchestration-v2/ProviderTurnControlService.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class ProviderTaskStopError extends Schema.TaggedErrorClass<ProviderTaskS
4747
) {}
4848

4949
const isProviderTurnControlError = Schema.is(ProviderTurnControlError);
50+
export const isProviderTaskStopError = Schema.is(ProviderTaskStopError);
5051

5152
export interface ProviderTurnControlServiceV2Shape {
5253
readonly interrupt: (input: {
@@ -291,7 +292,7 @@ export const layer: Layer.Layer<
291292
yield* stop({ nativeTaskId: input.nativeTaskId });
292293
}).pipe(
293294
Effect.mapError((cause) =>
294-
Schema.is(ProviderTaskStopError)(cause)
295+
isProviderTaskStopError(cause)
295296
? cause
296297
: new ProviderTaskStopError({
297298
threadId: input.threadId,

0 commit comments

Comments
 (0)