@@ -29,6 +29,8 @@ interface LoopSetupOptions {
2929 agent ?: string
3030 model ?: { providerID : string ; modelID : string }
3131 worktree ?: boolean
32+ executionModel ?: string
33+ auditorModel ?: string
3234 onLoopStarted ?: ( loopName : string ) => void
3335}
3436
@@ -196,6 +198,8 @@ export async function setupLoop(
196198 worktree : options . worktree ,
197199 sandbox : sandboxEnabled ,
198200 sandboxContainerName,
201+ executionModel : options . executionModel ,
202+ auditorModel : options . auditorModel ,
199203 }
200204
201205 kvService . set ( projectId , `plan:${ uniqueLoopName } ` , options . prompt )
@@ -359,6 +363,8 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
359363 const sessionTitle = args . title . length > 60 ? `${ args . title . substring ( 0 , 57 ) } ...` : args . title
360364 const loopModel = parseModelString ( config . loop ?. model ) ?? parseModelString ( config . executionModel )
361365 const audit = config . loop ?. defaultAudit ?? true
366+ const executionModel = config . loop ?. model ?? config . executionModel
367+ const auditorModel = config . auditorModel ?? config . loop ?. model ?? config . executionModel
362368
363369 const loopName = args . loopName ? slugify ( args . loopName ) : slugify ( sessionTitle )
364370
@@ -373,6 +379,8 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
373379 agent : 'code' ,
374380 model : loopModel ,
375381 worktree : args . worktree ,
382+ executionModel : executionModel ,
383+ auditorModel : auditorModel ,
376384 onLoopStarted : ( id ) => loopHandler . startWatchdog ( id ) ,
377385 } )
378386 } ,
@@ -545,6 +553,8 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
545553 sandboxContainerName : restartSandbox
546554 ? ctx . sandboxManager ?. docker . containerName ( stoppedState . loopName ! )
547555 : undefined ,
556+ executionModel : stoppedState . executionModel ,
557+ auditorModel : stoppedState . auditorModel ,
548558 }
549559
550560 loopService . setState ( stoppedState . loopName ! , newState )
@@ -555,7 +565,9 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
555565 promptText += buildCompletionSignalInstructions ( stoppedState . completionSignal )
556566 }
557567
558- const loopModel = parseModelString ( config . loop ?. model ) ?? parseModelString ( config . executionModel )
568+ const loopModel = parseModelString ( stoppedState . executionModel )
569+ ?? parseModelString ( config . loop ?. model )
570+ ?? parseModelString ( config . executionModel )
559571
560572 const { result : promptResult } = await retryWithModelFallback (
561573 ( ) => v2 . session . promptAsync ( {
@@ -704,6 +716,10 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
704716 `Started: ${ state . startedAt } ` ,
705717 ...( state . completedAt ? [ `Completed: ${ state . completedAt } ` ] : [ ] ) ,
706718 )
719+ statusLines . push (
720+ `Model: ${ state . executionModel ?? config . loop ?. model ?? config . executionModel ?? 'default' } ` ,
721+ `Auditor model: ${ state . auditorModel ?? config . auditorModel ?? state . executionModel ?? config . loop ?. model ?? config . executionModel ?? 'default' } ` ,
722+ )
707723
708724 if ( state . lastAuditResult ) {
709725 statusLines . push ( ...formatAuditResult ( state . lastAuditResult ) )
@@ -790,8 +806,8 @@ export function createLoopTools(ctx: ToolContext): Record<string, ReturnType<typ
790806 `Started: ${ state . startedAt } ` ,
791807 ...( state . errorCount && state . errorCount > 0 ? [ `Error count: ${ state . errorCount } (retries before termination: ${ MAX_RETRIES } )` ] : [ ] ) ,
792808 `Audit count: ${ state . auditCount ?? 0 } ` ,
793- `Model: ${ config . loop ?. model || config . executionModel || 'default' } ` ,
794- `Auditor model: ${ config . auditorModel || 'default' } ` ,
809+ `Model: ${ state . executionModel ?? config . loop ?. model ?? config . executionModel ?? 'default' } ` ,
810+ `Auditor model: ${ state . auditorModel ?? config . auditorModel ?? state . executionModel ?? config . loop ?. model ?? config . executionModel ?? 'default' } ` ,
795811 ...( stallCount > 0 ? [ `Stalls: ${ stallCount } ` ] : [ ] ) ,
796812 ...( secondsSinceActivity !== null ? [ `Last activity: ${ secondsSinceActivity } s ago` ] : [ ] ) ,
797813 '' ,
0 commit comments