@@ -1553,7 +1553,34 @@ export class ClineProvider
15531553 this . log ( `[continueParentTask] Found parent task ${ parentTask . taskId } , isPaused: ${ parentTask . isPaused } ` )
15541554 this . log ( `[continueParentTask] Parent task isInitialized: ${ parentTask . isInitialized } ` )
15551555
1556+ // Log mode information for debugging
1557+ const currentProviderMode = ( await this . getState ( ) ) . mode
1558+ const parentTaskMode =
1559+ typeof parentTask . getTaskMode === "function"
1560+ ? await parentTask . getTaskMode ( )
1561+ : ( parentTask as any ) . _taskMode || parentTask . pausedModeSlug || "unknown"
1562+ this . log ( `[continueParentTask] Current provider mode: ${ currentProviderMode } ` )
1563+ this . log ( `[continueParentTask] Parent task mode: ${ parentTaskMode } ` )
1564+ this . log ( `[continueParentTask] Parent task pausedModeSlug: ${ parentTask . pausedModeSlug } ` )
1565+
15561566 try {
1567+ // Switch provider mode to match parent task's mode if they differ
1568+ if ( currentProviderMode !== parentTaskMode && parentTaskMode !== "unknown" ) {
1569+ this . log (
1570+ `[continueParentTask] Provider mode (${ currentProviderMode } ) differs from parent task mode (${ parentTaskMode } )` ,
1571+ )
1572+ this . log ( `[continueParentTask] Switching provider mode to match parent task: ${ parentTaskMode } ` )
1573+
1574+ try {
1575+ await this . handleModeSwitch ( parentTaskMode as any )
1576+ this . log ( `[continueParentTask] Successfully switched provider mode to: ${ parentTaskMode } ` )
1577+ } catch ( error ) {
1578+ this . log (
1579+ `[continueParentTask] Failed to switch provider mode: ${ error instanceof Error ? error . message : String ( error ) } ` ,
1580+ )
1581+ }
1582+ }
1583+
15571584 // If the parent task is not initialized, we need to initialize it properly
15581585 if ( ! parentTask . isInitialized ) {
15591586 this . log ( `[continueParentTask] Initializing parent task from history` )
@@ -1679,6 +1706,35 @@ export class ClineProvider
16791706 }
16801707
16811708 this . log ( `[reconstructTaskStack] Successfully reconstructed stack with ${ createdTasks . length } tasks` )
1709+
1710+ // Log final mode state after reconstruction
1711+ const finalProviderMode = ( await this . getState ( ) ) . mode
1712+ const targetTask = createdTasks [ createdTasks . length - 1 ]
1713+ // Safety check for getTaskMode method (may not exist in tests)
1714+ const targetTaskMode =
1715+ typeof targetTask . getTaskMode === "function"
1716+ ? await targetTask . getTaskMode ( )
1717+ : ( targetTask as any ) . _taskMode || "unknown"
1718+ this . log ( `[reconstructTaskStack] Final provider mode after reconstruction: ${ finalProviderMode } ` )
1719+ this . log ( `[reconstructTaskStack] Target task final mode: ${ targetTaskMode } ` )
1720+
1721+ // Check if provider mode matches target task mode
1722+ if ( finalProviderMode !== targetTaskMode ) {
1723+ this . log (
1724+ `[reconstructTaskStack] WARNING: Provider mode (${ finalProviderMode } ) does not match target task mode (${ targetTaskMode } )` ,
1725+ )
1726+ this . log ( `[reconstructTaskStack] Switching provider mode to match target task mode: ${ targetTaskMode } ` )
1727+
1728+ // Switch provider mode to match the target task's mode
1729+ try {
1730+ await this . handleModeSwitch ( targetTaskMode as any )
1731+ this . log ( `[reconstructTaskStack] Successfully switched provider mode to: ${ targetTaskMode } ` )
1732+ } catch ( error ) {
1733+ this . log (
1734+ `[reconstructTaskStack] Failed to switch provider mode: ${ error instanceof Error ? error . message : String ( error ) } ` ,
1735+ )
1736+ }
1737+ }
16821738 } catch ( error ) {
16831739 this . log (
16841740 `[reconstructTaskStack] ERROR during reconstruction: ${ error instanceof Error ? error . message : String ( error ) } ` ,
0 commit comments