@@ -669,6 +669,58 @@ describe("interrupt_agent unblocks wait_agents", () => {
669669 expect ( again . timed_out ) . toBe ( false ) ;
670670 expect ( again . results ) . toEqual ( [ ] ) ;
671671 } ) ;
672+
673+ test ( "late salvage attaches after wait collected an early interrupt" , async ( ) => {
674+ const settle = deferred < RunSubAgentResult > ( ) ;
675+ const deps = makeDeps ( async ( params ) => {
676+ params . onAgentReady ?.( {
677+ close : async ( ) => { } ,
678+ interrupt : ( ) => { } ,
679+ followup : async ( ) => "" ,
680+ } ) ;
681+ return settle . promise ;
682+ } ) ;
683+ const spawn = createSpawnAgentTool ( deps ) ;
684+ const wait = createWaitAgentsTool ( {
685+ sessions : deps . sessions ,
686+ fleetRecords : deps . fleetRecords ,
687+ } ) ;
688+ const interrupt = createInterruptAgentTool ( {
689+ sessions : deps . sessions ,
690+ fleetRecords : deps . fleetRecords ,
691+ } ) ;
692+
693+ const spawned = await callTool ( spawn , {
694+ description : "looping" ,
695+ prompt : "do it" ,
696+ intent : "explore" ,
697+ } ) ;
698+ const id = spawned . agent_id as string ;
699+
700+ // Let onAgentReady register interrupt before we call interrupt_agent.
701+ await new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) ) ;
702+
703+ if ( interrupt . kind !== "full" ) throw new Error ( "expected full tool" ) ;
704+ await interrupt . handler (
705+ { id : "int-1" , name : "interrupt_agent" , arguments : { target : id } } ,
706+ new AbortController ( ) . signal ,
707+ ) ;
708+
709+ const early = await callTool ( wait , { targets : [ id ] , timeout_ms : 5000 } ) ;
710+ expect ( ( early . results as { status : string } [ ] ) [ 0 ] ! . status ) . toBe ( "interrupted" ) ;
711+ expect ( ( early . results as { report ?: string } [ ] ) [ 0 ] ! . report ) . toBeUndefined ( ) ;
712+
713+ settle . resolve ( {
714+ report : "## Summary\nStopped.\n## Findings\nsalvage\n## Blockers\ninterrupted\n## Paths\n" ,
715+ interrupted : true ,
716+ } ) ;
717+ await new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) ) ;
718+
719+ const again = await callTool ( wait , { targets : [ id ] , timeout_ms : 5000 } ) ;
720+ const results = again . results as { status : string ; report ?: string } [ ] ;
721+ expect ( results [ 0 ] ! . status ) . toBe ( "interrupted" ) ;
722+ expect ( results [ 0 ] ! . report ) . toContain ( "salvage" ) ;
723+ } ) ;
672724} ) ;
673725
674726describe ( "close_agent unblocks wait_agents" , ( ) => {
0 commit comments