@@ -4135,6 +4135,7 @@ function isClaudeTranscriptConversationLine(
41354135interface PendingClaudeSubagentLaunch {
41364136 readonly model ?: string ;
41374137 readonly effort ?: string ;
4138+ readonly inheritModel ?: boolean ;
41384139 readonly ownerToolUseId ?: string ;
41394140}
41404141
@@ -4147,8 +4148,15 @@ function claudeSubagentModelSelection(
41474148 instanceId : ModelSelection [ "instanceId" ] ,
41484149 model : string ,
41494150 effort : string | undefined ,
4151+ inheritedSelection ?: ModelSelection ,
41504152) : ModelSelection {
41514153 const selection = resolveClaudeCatalogModelSelection ( catalog , instanceId , model ) ;
4154+ const options = new Map (
4155+ [
4156+ ...( inheritedSelection ?. model === selection . model ? ( inheritedSelection . options ?? [ ] ) : [ ] ) ,
4157+ ...( selection . options ?? [ ] ) ,
4158+ ] . map ( ( option ) => [ option . id , option ] as const ) ,
4159+ ) ;
41524160 const descriptor = getClaudeCatalogModelCapabilities (
41534161 catalog ,
41544162 selection . model ,
@@ -4157,15 +4165,11 @@ function claudeSubagentModelSelection(
41574165 effort !== undefined &&
41584166 descriptor ?. type === "select" &&
41594167 descriptor . options . some ( ( option ) => option . id === effort ) ;
4160- return offered
4161- ? {
4162- ...selection ,
4163- options : [
4164- ...( selection . options ?. filter ( ( option ) => option . id !== "effort" ) ?? [ ] ) ,
4165- { id : "effort" , value : effort } ,
4166- ] ,
4167- }
4168- : selection ;
4168+ if ( offered ) {
4169+ options . delete ( "effort" ) ;
4170+ options . set ( "effort" , { id : "effort" , value : effort } ) ;
4171+ }
4172+ return { ...selection , ...( options . size > 0 ? { options : [ ...options . values ( ) ] } : { } ) } ;
41694173}
41704174
41714175const PENDING_CLAUDE_SUBAGENT_CAP = 64 ;
@@ -4193,9 +4197,10 @@ function rememberClaudeSubagentLaunch(
41934197 toolUseId : string ,
41944198 input : ClaudeNativeToolInput ,
41954199 ownerToolUseId : string | null ,
4200+ defaultModel : string | undefined ,
41964201) : void {
41974202 if ( context . subagentsByToolUseId . has ( toolUseId ) ) return ;
4198- const requested = firstStringInputField ( input , [ "model" ] ) ;
4203+ const requested = firstStringInputField ( input , [ "model" ] ) ?? ( defaultModel ?. trim ( ) || undefined ) ;
41994204 const model =
42004205 requested !== "inherit"
42014206 ? requested && canonicalClaudeSubagentModel ( catalog , requested )
@@ -4206,11 +4211,13 @@ function rememberClaudeSubagentLaunch(
42064211 const launch : PendingClaudeSubagentLaunch = {
42074212 ...( model === undefined || pending . get ( toolUseId ) ?. model !== undefined ? { } : { model } ) ,
42084213 ...( effort === undefined ? { } : { effort } ) ,
4214+ inheritModel : requested === undefined || requested === "inherit" ,
42094215 ...( ownerToolUseId === null ? { } : { ownerToolUseId } ) ,
42104216 } ;
42114217 if (
42124218 launch . model !== undefined ||
42134219 launch . effort !== undefined ||
4220+ launch . inheritModel === true ||
42144221 launch . ownerToolUseId !== undefined
42154222 ) {
42164223 rememberPendingClaudeSubagentLaunch ( pending , toolUseId , launch ) ;
@@ -6305,6 +6312,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
63056312 readonly title ?: string ;
63066313 readonly model ?: string ;
63076314 readonly effort ?: string ;
6315+ readonly inheritModel ?: boolean ;
63086316 readonly owner ?: ActiveClaudeSubagent ;
63096317 readonly nativeTaskType ?: string ;
63106318 readonly progress ?: string ;
@@ -6406,6 +6414,11 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
64066414 . effort )
64076415 : existingSubagent . effort ;
64086416 const model = input . model ?? priorTask ?. model ?? null ;
6417+ const inheritedSelection =
6418+ existingSubagent ?. task . modelSelection ??
6419+ ( input . inheritModel
6420+ ? ( input . owner ?. task . modelSelection ?? input . context . input . modelSelection )
6421+ : undefined ) ;
64096422 const task = {
64106423 ...( priorTask ?? {
64116424 id : nodeId ,
@@ -6443,8 +6456,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
64436456 modelSelection : claudeSubagentModelSelection (
64446457 modelCatalog ,
64456458 input . context . input . modelSelection . instanceId ,
6446- model || input . context . input . modelSelection . model ,
6459+ model || inheritedSelection ?. model || input . context . input . modelSelection . model ,
64476460 effort ,
6461+ inheritedSelection ,
64486462 ) ,
64496463 }
64506464 : { } ) ,
@@ -8925,6 +8939,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
89258939 ...( message . prompt === undefined ? { } : { prompt : message . prompt } ) ,
89268940 ...( model === undefined ? { } : { model } ) ,
89278941 ...( launch ?. effort === undefined ? { } : { effort : launch . effort } ) ,
8942+ ...( launch ?. inheritModel === true ? { inheritModel : true } : { } ) ,
89288943 ...( owner === undefined ? { } : { owner } ) ,
89298944 ...( isWorkflow
89308945 ? {
@@ -9069,6 +9084,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
90699084 toolUse . id ,
90709085 nativeToolInput ,
90719086 parentToolUseIdFromSdkMessage ( message ) ,
9087+ adapterOptions . environment . CLAUDE_CODE_SUBAGENT_MODEL ,
90729088 ) ;
90739089 continue ;
90749090 }
@@ -9643,6 +9659,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
96439659 nativeRequestId ,
96449660 nativeToolInput ,
96459661 null ,
9662+ adapterOptions . environment . CLAUDE_CODE_SUBAGENT_MODEL ,
96469663 ) ;
96479664 } else if ( startToolCall && ! heldForEcho ) {
96489665 yield * ensureToolCallStarted ( {
0 commit comments