@@ -1543,9 +1543,10 @@ async function spawnClaudeTaskIsolated(agent, context) {
15431543 resolveWrapperClose = resolveClose ;
15441544 } ) ;
15451545 const markWrapperClosed = ( ) => {
1546- if ( wrapperClosed ) return ;
1547- wrapperClosed = true ;
1548- resolveWrapperClose ( ) ;
1546+ if ( ! wrapperClosed ) {
1547+ wrapperClosed = true ;
1548+ resolveWrapperClose ( ) ;
1549+ }
15491550 } ;
15501551 proc . once ( 'close' , markWrapperClosed ) ;
15511552 proc . once ( 'error' , markWrapperClosed ) ;
@@ -1629,7 +1630,7 @@ async function spawnClaudeTaskIsolated(agent, context) {
16291630 } ) ;
16301631
16311632 proc . on ( 'error' , ( error ) => {
1632- if ( ! isolatedTaskId && agent . currentTask === pendingLaunch ) {
1633+ if ( ! isolatedTaskId && agent . currentTask === isolatedPendingLaunch ) {
16331634 agent . currentTask = null ;
16341635 }
16351636 clearTimeout ( spawnTimeout ) ;
@@ -2332,15 +2333,15 @@ async function killTask(agent, termination = 'Task killed') {
23322333 const taskId = agent . currentTaskId ;
23332334
23342335 if ( currentTask ?. pendingLaunch && typeof currentTask . kill === 'function' ) {
2335- const termination = await currentTask . kill ( reason , { code } ) ;
2336- if ( termination ?. forced === false ) return termination ;
2336+ const pendingTermination = await currentTask . kill ( reason , { code } ) ;
2337+ if ( pendingTermination ?. forced === false ) return pendingTermination ;
23372338 agent . _stopLivenessCheck ?. ( ) ;
23382339 agent . currentTask = null ;
23392340 agent . currentTaskId = null ;
23402341 agent . processPid = null ;
23412342 agent . lastOutputTime = null ;
23422343 agent . taskStartedAt = null ;
2343- return termination ;
2344+ return pendingTermination ;
23442345 }
23452346
23462347 if ( agent . isolation ?. enabled && taskId ) {
0 commit comments