@@ -291,6 +291,7 @@ export namespace SessionPrompt {
291291 // TODO: centralize "invoke tool" logic
292292 if ( task ?. type === "subtask" ) {
293293 const taskTool = await TaskTool . init ( )
294+ const taskModel = task . model ? Provider . parseModel ( task . model ) : model
294295 const assistantMessage = ( await Session . updateMessage ( {
295296 id : Identifier . ascending ( "message" ) ,
296297 role : "assistant" ,
@@ -308,8 +309,8 @@ export namespace SessionPrompt {
308309 reasoning : 0 ,
309310 cache : { read : 0 , write : 0 } ,
310311 } ,
311- modelID : model . modelID ,
312- providerID : model . providerID ,
312+ modelID : taskModel . modelID ,
313+ providerID : taskModel . providerID ,
313314 time : {
314315 created : Date . now ( ) ,
315316 } ,
@@ -1354,20 +1355,16 @@ export namespace SessionPrompt {
13541355 template = template . trim ( )
13551356
13561357 const agent = await Agent . get ( agentName )
1357- const parentModel = input . model
1358- ? Provider . parseModel ( input . model )
1359- : ( agent . model ?? ( await lastModel ( input . sessionID ) ) )
1358+ const model = input . model ? Provider . parseModel ( input . model ) : ( agent . model ?? ( await lastModel ( input . sessionID ) ) )
13601359
1361- const subtaskAgentName = command . agent ?? agentName
1362- const subtaskAgent = await Agent . get ( subtaskAgentName )
1363- const subtaskModel = command . model ? Provider . parseModel ( command . model ) : ( subtaskAgent . model ?? parentModel )
1360+ const cmdAgent = command . agent ? await Agent . get ( command . agent ) : agent
13641361
13651362 const parts =
1366- ( subtaskAgent . mode === "subagent" && command . subtask !== false ) || command . subtask === true
1363+ ( cmdAgent . mode === "subagent" && command . subtask !== false ) || command . subtask === true
13671364 ? [
13681365 {
13691366 type : "subtask" as const ,
1370- agent : subtaskAgent . name ,
1367+ agent : cmdAgent . name ,
13711368 description : command . description ?? "" ,
13721369 returnPrompt : command . returnPrompt ,
13731370 model : command . model ,
@@ -1380,7 +1377,7 @@ export namespace SessionPrompt {
13801377 const result = ( await prompt ( {
13811378 sessionID : input . sessionID ,
13821379 messageID : input . messageID ,
1383- model : parentModel ,
1380+ model,
13841381 agent : agentName ,
13851382 parts,
13861383 } ) ) as MessageV2 . WithParts
0 commit comments