@@ -568,6 +568,73 @@ const followUpResultRecovery = Effect.gen(function* () {
568568 } ) ;
569569 assert . notInclude ( yield * store . getRecoveryThreadIds ( "subagent-results" ) , childId ) ;
570570 }
571+ let ordinal = 11 ;
572+ for ( const [ scenario , sourceRunId , recoverable ] of [
573+ [ "requested" , original . id , true ] ,
574+ [ "notification" , RunId . make ( "run:automatic-follow-up:0" ) , false ] ,
575+ [ "scheduled" , RunId . make ( "run:automatic-follow-up:3" ) , false ] ,
576+ [ "notification-intermediate" , original . id , false ] ,
577+ [ "scheduled-intermediate" , original . id , false ] ,
578+ [ "missing" , RunId . make ( "run:missing-source" ) , false ] ,
579+ ] as const ) {
580+ let previousRunId = sourceRunId ;
581+ for ( let depth = 1 ; depth <= 3 ; depth ++ ) {
582+ const continuation = {
583+ ...monitor ,
584+ id : RunId . make ( `run:continuation:${ scenario } :${ depth } ` ) ,
585+ userMessageId : MessageId . make ( `message:continuation:${ scenario } :${ depth } ` ) ,
586+ ordinal : ordinal ++ ,
587+ restartContinuationOfRunId : previousRunId ,
588+ } ;
589+ yield * store . apply ( {
590+ id : EventId . make ( `continuation:message:${ scenario } :${ depth } ` ) ,
591+ type : "message.updated" ,
592+ threadId : childId ,
593+ runId : continuation . id ,
594+ occurredAt : now ,
595+ payload : {
596+ ...( yield * store . getThreadProjection ( childId ) ) . messages [ 0 ] ! ,
597+ id : continuation . userMessageId ,
598+ runId : continuation . id ,
599+ creationSource : "server" ,
600+ createdBy : "agent" ,
601+ notification :
602+ scenario === "notification-intermediate" && depth === 1
603+ ? { source : { kind : "command" } , outcome : "completed" , summary : "Automatic update" }
604+ : undefined ,
605+ scheduledTaskId :
606+ scenario === "scheduled-intermediate" && depth === 1
607+ ? ScheduledTaskId . make ( "continuation-schedule" )
608+ : undefined ,
609+ } ,
610+ } ) ;
611+ yield * store . apply ( {
612+ id : EventId . make ( `continuation:run:${ scenario } :${ depth } ` ) ,
613+ type : "run.updated" ,
614+ threadId : childId ,
615+ runId : continuation . id ,
616+ occurredAt : now ,
617+ payload : continuation ,
618+ } ) ;
619+ const candidates = yield * store . getRecoveryThreadIds ( "subagent-results" ) ;
620+ assert . equal ( candidates . includes ( childId ) , recoverable , `${ scenario } depth ${ depth } ` ) ;
621+ if ( recoverable ) {
622+ yield * store . apply ( {
623+ id : EventId . make ( `continuation:transfer:${ scenario } :${ depth } ` ) ,
624+ type : "context-transfer.created" ,
625+ threadId : childId ,
626+ occurredAt : now ,
627+ payload : {
628+ ...transfer ,
629+ id : ContextTransferId . make ( `transfer:continuation:${ scenario } :${ depth } ` ) ,
630+ sourcePoint : { threadId : childId , runId : continuation . id } ,
631+ } ,
632+ } ) ;
633+ assert . notInclude ( yield * store . getRecoveryThreadIds ( "subagent-results" ) , childId ) ;
634+ }
635+ previousRunId = continuation . id ;
636+ }
637+ }
571638} ) ;
572639
573640it . effect ( "recovers only undelivered follow-up results in memory" , ( ) =>
0 commit comments