@@ -89,7 +89,7 @@ export interface DesktopExecutorOptions {
8989 onResultDelivered ?: ( toolCallId : string ) => void
9090 /**
9191 * Called once Sim is done with a call without taking its real result: it settled the call
92- * first, refused the result, or was sent one that stands in for it. The model never learns of
92+ * first, refused the result, or recorded one that stands in for it. The model never learns of
9393 * anything the action handed back as still going, so nothing will come back to it.
9494 */
9595 onResultNotDelivered ?: ( toolCallId : string ) => void
@@ -419,7 +419,7 @@ export class DesktopExecutor {
419419 sendingSince : number
420420 ) : Promise < void > {
421421 let pending = completion
422- let delivered = false
422+ let notDelivered = true
423423 for ( let attempt = 1 ; ! this . disposed ; attempt ++ ) {
424424 try {
425425 const outcome = await this . options . client . complete ( {
@@ -429,8 +429,11 @@ export class DesktopExecutor {
429429 } )
430430 logger . info ( 'Desktop call result acknowledged' , { toolCallId, outcome } )
431431 // Superseded: Sim settled the call first, so this result never reached the model.
432- delivered = outcome !== 'superseded' && isDeliveredResult ( pending )
432+ const delivered = outcome !== 'superseded' && isDeliveredResult ( pending )
433433 if ( delivered ) this . options . onResultDelivered ?.( toolCallId )
434+ // A stand-in Sim already holds leaves open which result it took first: a send from before
435+ // a restart may have carried the real one.
436+ notDelivered = ! delivered && outcome !== 'duplicate'
434437 break
435438 } catch ( error ) {
436439 // Encoding failed on this machine, so nothing was sent; the same data would fail again.
@@ -488,7 +491,7 @@ export class DesktopExecutor {
488491 }
489492 }
490493 if ( this . disposed ) return
491- if ( ! delivered ) this . options . onResultNotDelivered ?.( toolCallId )
494+ if ( notDelivered ) this . options . onResultNotDelivered ?.( toolCallId )
492495 await this . forget ( toolCallId )
493496 }
494497
0 commit comments