@@ -396,6 +396,10 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
396396 start : vi . fn ( ) ,
397397 run : childRun ,
398398 setRuntimeThinkingEffort,
399+ // The child's resolved model (post mode switch) supports the requested level.
400+ api : {
401+ getModel : ( ) => ( { id : "child-model" , info : { supportsReasoningEffort : [ "low" , "medium" , "high" ] } } ) ,
402+ } ,
399403 } )
400404 const taskHistoryStore = makeStoreStub ( )
401405
@@ -463,4 +467,95 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
463467
464468 expect ( setRuntimeThinkingEffort ) . not . toHaveBeenCalled ( )
465469 } )
470+
471+ it ( "falls back with an observable say when the child model (post mode switch) does not support the effort (DTE series 5/5)" , async ( ) => {
472+ const parentTask = makeParentTask ( )
473+ const setRuntimeThinkingEffort = vi . fn ( )
474+ const say = vi . fn ( ) . mockResolvedValue ( undefined )
475+ const childRun = vi . fn ( ) . mockResolvedValue ( undefined )
476+ // The mode switch resolved a DIFFERENT model than the parent's: it only
477+ // supports low/high, so the parent-validated "xhigh" must not be applied.
478+ const createTask = vi . fn ( ) . mockResolvedValue ( {
479+ taskId : "child-1" ,
480+ start : vi . fn ( ) ,
481+ run : childRun ,
482+ setRuntimeThinkingEffort,
483+ say,
484+ api : { getModel : ( ) => ( { id : "child-model" , info : { supportsReasoningEffort : [ "low" , "high" ] } } ) } ,
485+ } )
486+ const taskHistoryStore = makeStoreStub ( )
487+
488+ const provider = {
489+ taskScheduler : new TaskScheduler ( ) ,
490+ emit : vi . fn ( ) ,
491+ getCurrentTask : vi . fn ( ( ) => parentTask ) ,
492+ removeClineFromStack : vi . fn ( ) . mockResolvedValue ( undefined ) ,
493+ createTask,
494+ handleModeSwitch : vi . fn ( ) . mockResolvedValue ( undefined ) ,
495+ log : vi . fn ( ) ,
496+ isViewLaunched : false ,
497+ recentTasksCache : undefined ,
498+ taskHistoryStore,
499+ } as unknown as ClineProvider
500+
501+ await ClineProvider . prototype . delegateParentAndOpenChild . call ( provider , {
502+ parentTaskId : "parent-1" ,
503+ message : "Do something" ,
504+ initialTodos : [ ] ,
505+ mode : "code" ,
506+ thinkingEffort : "xhigh" ,
507+ } )
508+ await Promise . resolve ( )
509+
510+ // No task-local override: the child runs with the settings-derived effort.
511+ expect ( setRuntimeThinkingEffort ) . not . toHaveBeenCalled ( )
512+ // Observable on the child task: the fallback is announced, not silent.
513+ expect ( say ) . toHaveBeenCalledTimes ( 1 )
514+ const [ sayType , sayText ] = say . mock . calls [ 0 ]
515+ expect ( sayType ) . toBe ( "error" )
516+ expect ( sayText ) . toContain ( "xhigh" )
517+ expect ( sayText ) . toContain ( "child-model" )
518+ // Delegation itself still proceeds: the child runs.
519+ expect ( childRun ) . toHaveBeenCalledTimes ( 1 )
520+ } )
521+
522+ it ( "applies the effort when the child model (post mode switch) has a boolean-true capability (DTE series 5/5)" , async ( ) => {
523+ const parentTask = makeParentTask ( )
524+ const setRuntimeThinkingEffort = vi . fn ( )
525+ const childRun = vi . fn ( ) . mockResolvedValue ( undefined )
526+ // Boolean-true capability: the child model supports every level.
527+ const createTask = vi . fn ( ) . mockResolvedValue ( {
528+ taskId : "child-1" ,
529+ start : vi . fn ( ) ,
530+ run : childRun ,
531+ setRuntimeThinkingEffort,
532+ api : { getModel : ( ) => ( { id : "child-model" , info : { supportsReasoningEffort : true } } ) } ,
533+ } )
534+ const taskHistoryStore = makeStoreStub ( )
535+
536+ const provider = {
537+ taskScheduler : new TaskScheduler ( ) ,
538+ emit : vi . fn ( ) ,
539+ getCurrentTask : vi . fn ( ( ) => parentTask ) ,
540+ removeClineFromStack : vi . fn ( ) . mockResolvedValue ( undefined ) ,
541+ createTask,
542+ handleModeSwitch : vi . fn ( ) . mockResolvedValue ( undefined ) ,
543+ log : vi . fn ( ) ,
544+ isViewLaunched : false ,
545+ recentTasksCache : undefined ,
546+ taskHistoryStore,
547+ } as unknown as ClineProvider
548+
549+ await ClineProvider . prototype . delegateParentAndOpenChild . call ( provider , {
550+ parentTaskId : "parent-1" ,
551+ message : "Do something" ,
552+ initialTodos : [ ] ,
553+ mode : "code" ,
554+ thinkingEffort : "xhigh" ,
555+ } )
556+ await Promise . resolve ( )
557+
558+ expect ( setRuntimeThinkingEffort ) . toHaveBeenCalledTimes ( 1 )
559+ expect ( setRuntimeThinkingEffort ) . toHaveBeenCalledWith ( "xhigh" , "parent" )
560+ } )
466561} )
0 commit comments