@@ -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 ( {
0 commit comments