@@ -115,6 +115,7 @@ function makeTestAdapter(input: {
115115 readonly interruptedRunOrdinals ?: ReadonlySet < number > ;
116116 readonly holdRunOrdinal ?: number ;
117117 readonly pendingBackgroundWork ?: Ref . Ref < boolean > ;
118+ readonly subagentOnlyBackgroundWork ?: boolean ;
118119 readonly holdFirstTurn ?: Deferred . Deferred < void > ;
119120 readonly releaseFirstTurn ?: Deferred . Deferred < void > ;
120121} ) : ProviderAdapter . ProviderAdapterV2 [ "Service" ] {
@@ -149,7 +150,10 @@ function makeTestAdapter(input: {
149150 ...( input . pendingBackgroundWork === undefined
150151 ? { }
151152 : {
152- hasPendingBackgroundWorkForThread : ( ) => Ref . get ( input . pendingBackgroundWork ! ) ,
153+ hasPendingBackgroundWorkForThread : ( _thread , options ) =>
154+ input . subagentOnlyBackgroundWork && options ?. includeSubagents !== true
155+ ? Effect . succeed ( false )
156+ : Ref . get ( input . pendingBackgroundWork ! ) ,
153157 } ) ,
154158 ...( input . getModelContextWindow === undefined
155159 ? { }
@@ -424,6 +428,7 @@ describe("orchestration v2 provider switching", () => {
424428 "screenshot-exhausted-target-oversized-native" ,
425429 "screenshot-exhausted-target-tight-native" ,
426430 "screenshot-exhausted-target-background-native" ,
431+ "screenshot-exhausted-target-subagent-native" ,
427432 "prior-images-reasoning-change-replacement-small-native" ,
428433 "imported-prior-images-fallback" ,
429434 "prior-images-telemetry-native" ,
@@ -484,7 +489,12 @@ describe("orchestration v2 provider switching", () => {
484489 ...( scenario . includes ( "retry" ) || scenario . includes ( "unsent" ) ? { failStartOnce } : { } ) ,
485490 ...( replaceNative ? { failResumeOnce, nativeThreadGeneration : generation } : { } ) ,
486491 ...( exhaustedTarget ? { nativeThreadGeneration : generation } : { } ) ,
487- ...( scenario . includes ( "target-background" ) ? { pendingBackgroundWork } : { } ) ,
492+ ...( scenario . includes ( "target-background" ) || scenario . includes ( "target-subagent" )
493+ ? {
494+ pendingBackgroundWork,
495+ subagentOnlyBackgroundWork : scenario . includes ( "target-subagent" ) ,
496+ }
497+ : { } ) ,
488498 ...( scenario . includes ( "reported-capacity" )
489499 ? { initialContextUsage : { usedTokens : 999_999 , maxTokens : 1_000_000 } }
490500 : { } ) ,
@@ -744,7 +754,8 @@ describe("orchestration v2 provider switching", () => {
744754 yield * Ref . set ( failResumeOnce , true ) ;
745755 }
746756 if ( scenario . includes ( "retry" ) ) yield * Ref . set ( failStartOnce , true ) ;
747- if ( scenario . includes ( "target-background" ) ) yield * Ref . set ( pendingBackgroundWork , true ) ;
757+ if ( scenario . includes ( "target-background" ) || scenario . includes ( "target-subagent" ) )
758+ yield * Ref . set ( pendingBackgroundWork , true ) ;
748759 yield * dispatch ( targetOrdinal , current , targetSelection ) ;
749760 yield * wait ( targetOrdinal ) ;
750761 if ( scenario . includes ( "retry" ) ) {
@@ -833,13 +844,14 @@ describe("orchestration v2 provider switching", () => {
833844 if (
834845 scenario . includes ( "target-oversized" ) ||
835846 scenario . includes ( "target-tight" ) ||
836- scenario . includes ( "target-background" )
847+ scenario . includes ( "target-background" ) ||
848+ scenario . includes ( "target-subagent" )
837849 ) {
838850 assert . equal ( projection . runs . at ( - 1 ) ?. status , "failed" ) ;
839851 assert . equal ( yield * Ref . get ( generation ) , 1 ) ;
840852 assert . equal ( projection . messages . at ( - 1 ) ! . text , current ) ;
841853 assert . deepEqual ( projection . messages . at ( - 1 ) ! . attachments , screenshots ) ;
842- if ( scenario . includes ( "target-background" ) ) {
854+ if ( scenario . includes ( "target-background" ) || scenario . includes ( "target-subagent" ) ) {
843855 assert . isTrue ( yield * Ref . get ( pendingBackgroundWork ) ) ;
844856 const failure = projection . turnItems . findLast ( ( item ) => item . type === "error" ) ;
845857 assert . equal (
0 commit comments