@@ -282,13 +282,24 @@ async function runCheckpointLoop(
282282 )
283283 }
284284
285+ if ( isAborted ( options , context ) ) {
286+ cancelPendingTools ( context )
287+ context . awaitingAsyncContinuation = undefined
288+ break
289+ }
290+
285291 const results : Array < {
286292 callId : string
287293 name : string
288294 data : unknown
289295 success : boolean
290296 } > = [ ]
291297 for ( const toolCallId of continuation . pendingToolCallIds ) {
298+ if ( isAborted ( options , context ) ) {
299+ cancelPendingTools ( context )
300+ context . awaitingAsyncContinuation = undefined
301+ break
302+ }
292303 const tool = context . toolCalls . get ( toolCallId )
293304 if ( ! tool || ( ! tool . result && ! tool . error ) ) {
294305 logger . error ( 'Missing tool result for pending tool call' , {
@@ -309,6 +320,12 @@ async function runCheckpointLoop(
309320 } )
310321 }
311322
323+ if ( isAborted ( options , context ) ) {
324+ cancelPendingTools ( context )
325+ context . awaitingAsyncContinuation = undefined
326+ break
327+ }
328+
312329 logger . info ( 'Resuming with tool results' , {
313330 checkpointId : continuation . checkpointId ,
314331 runId : continuation . runId ,
@@ -324,6 +341,13 @@ async function runCheckpointLoop(
324341 checkpointId : continuation . checkpointId ,
325342 results,
326343 }
344+
345+ if ( isAborted ( options , context ) ) {
346+ cancelPendingTools ( context )
347+ context . awaitingAsyncContinuation = undefined
348+ break
349+ }
350+
327351 logger . info ( 'Prepared resume request payload' , {
328352 route,
329353 streamId : context . messageId ,
0 commit comments