fix(orchestration-v2): model task stop failures directly

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Shivam SharmaandClaude Fable 5 authored and T3 Code Test committed 2026-08-14 15:04:12 +05:30
1 parent 6894fe9f6f
commit 87cb5bc0ad
2 files changed
+20 -17

No files matched your search

@@ -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<void> })
.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<void> })
.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({
@@ -47,6 +47,7 @@ export class ProviderTaskStopError extends Schema.TaggedErrorClass<ProviderTaskS
) {}
const isProviderTurnControlError = Schema.is(ProviderTurnControlError);
export const isProviderTaskStopError = Schema.is(ProviderTaskStopError);
export interface ProviderTurnControlServiceV2Shape {
readonly interrupt: (input: {
@@ -291,7 +292,7 @@ export const layer: Layer.Layer<
yield* stop({ nativeTaskId: input.nativeTaskId });
}).pipe(
Effect.mapError((cause) =>
Schema.is(ProviderTaskStopError)(cause)
isProviderTaskStopError(cause)
? cause
: new ProviderTaskStopError({
threadId: input.threadId,