@@ -1352,18 +1352,20 @@ const decodeCodexResumeMetadata = Schema.decodeUnknownEffect(
13521352 Schema . Struct ( { thread : Schema . Struct ( { id : Schema . String , updatedAt : Schema . Number } ) } ) ,
13531353) ;
13541354
1355- const decodeCodexChildModel = Schema . decodeUnknownEffect (
1356- Schema . Struct ( {
1357- thread : Schema . Struct ( { id : Schema . String } ) ,
1358- model : Schema . NullOr ( Schema . String ) ,
1359- } ) ,
1360- ) ;
1355+ const CodexChildSelection = Schema . Struct ( {
1356+ thread : Schema . Struct ( { id : Schema . String } ) ,
1357+ model : Schema . NullOr ( Schema . String ) ,
1358+ reasoningEffort : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
1359+ serviceTier : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
1360+ } ) ;
1361+ const decodeCodexChildModel = Schema . decodeUnknownEffect ( CodexChildSelection ) ;
13611362
13621363const decodeCodexChildThread = Schema . decodeUnknownEffect (
13631364 Schema . Struct ( {
13641365 thread : Schema . Struct ( {
13651366 id : Schema . String ,
13661367 model : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
1368+ reasoningEffort : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
13671369 } ) ,
13681370 } ) ,
13691371) ;
@@ -1834,7 +1836,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
18341836 const pendingRootTurns = yield * Ref . make ( new Map < string , ProviderAdapterV2TurnInput > ( ) ) ;
18351837 const turnWaiters = yield * Ref . make ( new Map < string , Deferred . Deferred < void , never > > ( ) ) ;
18361838 const subagentThreads = yield * Ref . make ( new Map < string , CodexSubagentThreadContext > ( ) ) ;
1837- const subagentModels = new Map < string , string > ( ) ;
1839+ const subagentSelections = new Map < string , Omit < ModelSelection , "instanceId" > > ( ) ;
18381840 const pendingSubagentTurns = yield * Ref . make (
18391841 new Map < string , ReadonlyArray < PendingCodexSubagentTurnStarted > > ( ) ,
18401842 ) ;
@@ -2669,16 +2671,51 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
26692671 } ) ;
26702672 } ) ;
26712673
2672- const updateSubagentModel = Effect . fnUntraced ( function * (
2674+ const updateSubagentSelection = Effect . fnUntraced ( function * (
26732675 nativeThreadId : string ,
26742676 value : string | null ,
2677+ effort ?: string | null ,
2678+ tier ?: string | null ,
26752679 ) {
26762680 const model = value ?. trim ( ) ;
26772681 if ( ! model ) return ;
2678- subagentModels . set ( nativeThreadId , model ) ;
2682+ const previous = subagentSelections . get ( nativeThreadId ) ;
2683+ const previousOptions = previous ?. model === model ? previous . options : undefined ;
2684+ const options =
2685+ effort === undefined && tier === undefined
2686+ ? previousOptions
2687+ : [
2688+ ...( previousOptions ?? [ ] ) . filter ( ( { id } ) =>
2689+ id === "reasoningEffort"
2690+ ? effort === undefined
2691+ : id === "serviceTier" && tier === undefined ,
2692+ ) ,
2693+ ...[
2694+ { id : "reasoningEffort" , value : effort } ,
2695+ { id : "serviceTier" , value : tier } ,
2696+ ] . flatMap ( ( { id, value } ) =>
2697+ value ?. trim ( ) ? [ { id, value : value . trim ( ) } ] : [ ] ,
2698+ ) ,
2699+ ] ;
2700+ const selection = {
2701+ model,
2702+ ...( options === undefined ? { } : { options } ) ,
2703+ } ;
2704+ subagentSelections . set ( nativeThreadId , selection ) ;
26792705 const subagent = ( yield * Ref . get ( subagentThreads ) ) . get ( nativeThreadId ) ;
2680- if ( subagent === undefined || subagent . task . model === model ) return ;
2681- subagent . task = { ...subagent . task , model, updatedAt : yield * DateTime . now } ;
2706+ if ( subagent === undefined ) return ;
2707+ const modelSelection = { instanceId : subagent . task . providerInstanceId , ...selection } ;
2708+ if (
2709+ subagent . task . modelSelection &&
2710+ modelSelectionsEqual ( subagent . task . modelSelection , modelSelection )
2711+ )
2712+ return ;
2713+ subagent . task = {
2714+ ...subagent . task ,
2715+ model,
2716+ modelSelection,
2717+ updatedAt : yield * DateTime . now ,
2718+ } ;
26822719 yield * emitProviderEvent ( {
26832720 type : "subagent.updated" ,
26842721 driver : CODEX_PROVIDER ,
@@ -2694,6 +2731,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
26942731 readonly prompt : string ;
26952732 readonly title : string | null ;
26962733 readonly model : string | null ;
2734+ readonly reasoningEffort ?: string | null | undefined ;
26972735 readonly ordinal : number ;
26982736 readonly emitInitialPrompt : boolean ;
26992737 } ) =>
@@ -2702,6 +2740,13 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
27022740 if ( registeredSubagents . has ( input . nativeThreadId ) ) {
27032741 return ;
27042742 }
2743+ if ( input . model && ! subagentSelections . has ( input . nativeThreadId ) ) {
2744+ yield * updateSubagentSelection (
2745+ input . nativeThreadId ,
2746+ input . model ,
2747+ input . reasoningEffort ,
2748+ ) ;
2749+ }
27052750
27062751 const now = yield * DateTime . now ;
27072752 const subagentNodeId = idAllocator . derive . nodeFromProviderItem ( {
@@ -2744,6 +2789,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
27442789 createdAt : now ,
27452790 updatedAt : now ,
27462791 } satisfies OrchestrationV2ProviderThread ;
2792+ const reportedSelection = subagentSelections . get ( input . nativeThreadId ) ;
27472793 const task = {
27482794 id : subagentNodeId ,
27492795 threadId : input . context . projectionThreadId ,
@@ -2758,7 +2804,13 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
27582804 nativeTaskRef : codexNativeItemRef ( input . nativeItemId ) ,
27592805 prompt : input . prompt ,
27602806 title : input . title ,
2761- model : subagentModels . get ( input . nativeThreadId ) ?? input . model ,
2807+ model : reportedSelection ?. model ?? input . model ,
2808+ modelSelection : reportedSelection
2809+ ? {
2810+ instanceId : input . context . input . modelSelection . instanceId ,
2811+ ...reportedSelection ,
2812+ }
2813+ : undefined ,
27622814 status : "running" ,
27632815 result : null ,
27642816 startedAt : now ,
@@ -2913,9 +2965,13 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
29132965 . request ( "thread/read" , { threadId : input . nativeThreadId , includeTurns : false } )
29142966 . pipe (
29152967 Effect . flatMap ( decodeCodexChildThread ) ,
2916- Effect . map ( ( response ) =>
2968+ Effect . map ( ( response ) : typeof CodexChildSelection . Type | null =>
29172969 response . thread . id === input . nativeThreadId && response . thread . model ?. trim ( )
2918- ? { thread : response . thread , model : response . thread . model }
2970+ ? {
2971+ thread : response . thread ,
2972+ model : response . thread . model ,
2973+ reasoningEffort : response . thread . reasoningEffort ,
2974+ }
29192975 : null ,
29202976 ) ,
29212977 Effect . catch ( ( ) => Effect . succeed ( null ) ) ,
@@ -2932,8 +2988,13 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
29322988 Effect . timeout ( "5 seconds" ) ,
29332989 Effect . flatMap ( ( response ) =>
29342990 response . thread . id === input . nativeThreadId &&
2935- ! subagentModels . has ( input . nativeThreadId )
2936- ? updateSubagentModel ( input . nativeThreadId , response . model )
2991+ ! subagentSelections . has ( input . nativeThreadId )
2992+ ? updateSubagentSelection (
2993+ input . nativeThreadId ,
2994+ response . model ,
2995+ response . reasoningEffort ,
2996+ response . serviceTier ,
2997+ )
29372998 : Effect . void ,
29382999 ) ,
29393000 Effect . catch ( ( ) => Effect . void ) ,
@@ -2964,6 +3025,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
29643025 prompt : input . item . prompt ?? "" ,
29653026 title : null ,
29663027 model,
3028+ reasoningEffort : input . item . reasoningEffort ,
29673029 ordinal : index + 1 ,
29683030 emitInitialPrompt : true ,
29693031 } ) ;
@@ -4296,10 +4358,15 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
42964358 ) ;
42974359
42984360 yield * client . handleServerNotification ( "thread/settings/updated" , ( payload ) =>
4299- updateSubagentModel ( payload . threadId , payload . threadSettings . model ) ,
4361+ updateSubagentSelection (
4362+ payload . threadId ,
4363+ payload . threadSettings . model ,
4364+ payload . threadSettings . effort ,
4365+ payload . threadSettings . serviceTier ,
4366+ ) ,
43004367 ) ;
43014368 yield * client . handleServerNotification ( "model/rerouted" , ( payload ) =>
4302- updateSubagentModel ( payload . threadId , payload . toModel ) ,
4369+ updateSubagentSelection ( payload . threadId , payload . toModel ) ,
43034370 ) ;
43044371
43054372 yield * client . handleServerNotification ( "turn/started" , ( payload ) =>
0 commit comments