@@ -3725,12 +3725,76 @@ it.effect(
37253725 const resumeSecondThread = secondRuntime . resumeThread ( {
37263726 providerThread : secondProviderThread ,
37273727 threadId : secondThreadId ,
3728- modelSelection,
3728+ modelSelection : {
3729+ ...modelSelection ,
3730+ options : [ { id : "reasoningEffort" , value : "medium" } ] ,
3731+ } ,
37293732 runtimePolicy,
37303733 } ) ;
37313734 yield * resumeSecondThread ;
37323735 yield * resumeSecondThread ;
37333736 assert . equal ( ( yield * Ref . get ( state ) ) . resumeCount , 1 ) ;
3737+ const projectionStore = yield * ProjectionStore . ProjectionStoreV2 ;
3738+ const appThread = ( yield * projectionStore . getThreadProjection ( secondThreadId ) ) . thread ;
3739+ const turnEvents = ( yield * Ref . get ( state ) ) . eventQueues . get ( String ( providerSessionId ) ) ;
3740+ assert . isDefined ( turnEvents ) ;
3741+ for ( const [ index , effort ] of [ "medium" , "high" , "medium" ] . entries ( ) ) {
3742+ const selection = {
3743+ ...modelSelection ,
3744+ options : [ { id : "reasoningEffort" , value : effort } ] ,
3745+ } satisfies ModelSelection ;
3746+ yield * secondRuntime . resumeThread ( {
3747+ providerThread : secondProviderThread ,
3748+ threadId : secondThreadId ,
3749+ modelSelection : selection ,
3750+ runtimePolicy,
3751+ } ) ;
3752+ const ordinal = index + 1 ;
3753+ const runId = idAllocator . derive . run ( { threadId : secondThreadId , ordinal } ) ;
3754+ yield * secondRuntime . startTurn ( {
3755+ appThread,
3756+ threadId : secondThreadId ,
3757+ runId,
3758+ runOrdinal : ordinal ,
3759+ providerTurnOrdinal : ordinal ,
3760+ attemptId : idAllocator . derive . runAttempt ( { runId, attemptOrdinal : 1 } ) ,
3761+ rootNodeId : idAllocator . derive . rootNode ( { runId } ) ,
3762+ providerThread : secondProviderThread ,
3763+ message : {
3764+ createdBy : "user" ,
3765+ creationSource : "web" ,
3766+ messageId : yield * idAllocator . allocate . message ( {
3767+ threadId : secondThreadId ,
3768+ ordinal,
3769+ } ) ,
3770+ text : "turn" ,
3771+ attachments : [ ] ,
3772+ } ,
3773+ modelSelection : selection ,
3774+ runtimePolicy,
3775+ } ) ;
3776+ const subscription = yield * secondRuntime . subscribeEvents ! ;
3777+ const terminal = yield * subscription . events . pipe (
3778+ Stream . filter ( ( event ) => event . type === "turn.terminal" ) ,
3779+ Stream . runHead ,
3780+ Effect . forkScoped ,
3781+ ) ;
3782+ yield * Queue . offer ( turnEvents ! , {
3783+ type : "turn.terminal" ,
3784+ driver : CODEX_DRIVER ,
3785+ providerThreadId : secondProviderThread . id ,
3786+ providerTurnId : idAllocator . derive . providerTurn ( {
3787+ driver : CODEX_DRIVER ,
3788+ nativeTurnId : `native-effort-turn-${ ordinal } ` ,
3789+ } ) ,
3790+ runOrdinal : ordinal ,
3791+ status : "completed" ,
3792+ failure : null ,
3793+ threadDisposition : "reusable" ,
3794+ } ) ;
3795+ yield * Fiber . join ( terminal ) ;
3796+ assert . equal ( ( yield * Ref . get ( state ) ) . resumeCount , 1 , `${ effort } effort reloaded Codex` ) ;
3797+ }
37343798 yield * secondRuntime . resumeThread ( {
37353799 providerThread : secondProviderThread ,
37363800 threadId : secondThreadId ,
@@ -3780,6 +3844,54 @@ it.effect(
37803844
37813845 assert . deepEqual ( ( yield * Ref . get ( state ) ) . unloadedNativeThreadIds , [ "native-thread" ] ) ;
37823846
3847+ const otherDriver = ProviderDriverKind . make ( "claudeAgent" ) ;
3848+ const otherProviderThread = {
3849+ ...secondProviderThread ,
3850+ driver : otherDriver ,
3851+ nativeThreadRef : { driver : otherDriver , nativeId : "native-other" , strength : "strong" } ,
3852+ } satisfies OrchestrationV2ProviderThread ;
3853+ const reloadCases = [
3854+ {
3855+ name : "other model options" ,
3856+ providerThread : secondProviderThread ,
3857+ selection : {
3858+ ...modelSelection ,
3859+ options : [ { id : "serviceTier" , value : "priority" } ] ,
3860+ } ,
3861+ policy : runtimePolicy ,
3862+ } ,
3863+ {
3864+ name : "runtime policy" ,
3865+ providerThread : secondProviderThread ,
3866+ selection : modelSelection ,
3867+ policy : { ...runtimePolicy , interactionMode : "plan" } ,
3868+ } ,
3869+ ...[ "medium" , "high" ] . map ( ( effort ) => ( {
3870+ name : `non-Codex ${ effort } effort` ,
3871+ providerThread : otherProviderThread ,
3872+ selection : {
3873+ ...modelSelection ,
3874+ options : [ { id : "reasoningEffort" , value : effort } ] ,
3875+ } ,
3876+ policy : runtimePolicy ,
3877+ } ) ) ,
3878+ ] satisfies ReadonlyArray < {
3879+ name : string ;
3880+ providerThread : OrchestrationV2ProviderThread ;
3881+ selection : ModelSelection ;
3882+ policy : ProviderAdapter . ProviderAdapterV2RuntimePolicy ;
3883+ } > ;
3884+ for ( const { name, providerThread, selection, policy } of reloadCases ) {
3885+ const before = ( yield * Ref . get ( state ) ) . resumeCount ;
3886+ yield * secondRuntime . resumeThread ( {
3887+ providerThread,
3888+ threadId : secondThreadId ,
3889+ modelSelection : selection ,
3890+ runtimePolicy : policy ,
3891+ } ) ;
3892+ assert . equal ( ( yield * Ref . get ( state ) ) . resumeCount , before + 1 , `${ name } did not reload` ) ;
3893+ }
3894+
37833895 yield * manager . detach ( { providerSessionId, threadId : firstThreadId } ) ;
37843896 assert . isTrue ( Option . isSome ( yield * manager . get ( providerSessionId ) ) ) ;
37853897 assert . equal ( ( yield * Ref . get ( state ) ) . closeCount , 0 ) ;
0 commit comments