From 516f26edaef15bddcd22b8d2d0a1118c4bc7a9a2 Mon Sep 17 00:00:00 2001 From: Kacper Date: Thu, 18 Dec 2025 16:22:20 +0100 Subject: [PATCH] fix: prevent infinite loop when resuming feature with existing context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When executeFeatureWithContext calls executeFeature with a continuation prompt, skip the context existence check to avoid the loop: executeFeature -> resumeFeature -> executeFeatureWithContext -> executeFeature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/server/src/services/auto-mode-service.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/server/src/services/auto-mode-service.ts b/apps/server/src/services/auto-mode-service.ts index 61130314..b676c0c9 100644 --- a/apps/server/src/services/auto-mode-service.ts +++ b/apps/server/src/services/auto-mode-service.ts @@ -487,17 +487,20 @@ export class AutoModeService { try { // Check if feature has existing context - if so, resume instead of starting fresh - const hasExistingContext = await this.contextExists( - projectPath, - featureId - ); - if (hasExistingContext) { - console.log( - `[AutoMode] Feature ${featureId} has existing context, resuming instead of starting fresh` + // Skip this check if we're already being called with a continuation prompt (from resumeFeature) + if (!options?.continuationPrompt) { + const hasExistingContext = await this.contextExists( + projectPath, + featureId ); - // Remove from running features temporarily, resumeFeature will add it back - this.runningFeatures.delete(featureId); - return this.resumeFeature(projectPath, featureId, useWorktrees); + if (hasExistingContext) { + console.log( + `[AutoMode] Feature ${featureId} has existing context, resuming instead of starting fresh` + ); + // Remove from running features temporarily, resumeFeature will add it back + this.runningFeatures.delete(featureId); + return this.resumeFeature(projectPath, featureId, useWorktrees); + } } // Emit feature start event early