Skip to content

Comments

feat: Add task retry logic and improve max turns limit#778

Merged
gsxdsm merged 4 commits intoAutoMaker-Org:v0.15.0rcfrom
gsxdsm:fix/features-completed-too-soon
Feb 17, 2026
Merged

feat: Add task retry logic and improve max turns limit#778
gsxdsm merged 4 commits intoAutoMaker-Org:v0.15.0rcfrom
gsxdsm:fix/features-completed-too-soon

Conversation

@gsxdsm
Copy link
Collaborator

@gsxdsm gsxdsm commented Feb 17, 2026

Features are moving to completed before all tasks complete

Summary by CodeRabbit

  • New Features

    • Automatic retry mechanism for incomplete tasks (up to 3 retries) with continuation prompts and progress events
    • Enhanced completion messages showing elapsed time, verification status, and remaining task progress
    • Increased per-task execution allowance and longer default conversation turns to support extended runs
  • Bug Fixes

    • Final task status handling corrected to mark in-progress work as completed and preserve pending/completed states
    • Improved task completion tracking and warnings for never-started tasks
  • Tests

    • Added comprehensive tests for retry scenarios, aborts, planning-mode interactions, and edge cases

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gsxdsm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the robustness of agent-driven feature development by introducing an intelligent task retry system. It addresses the issue where features might prematurely transition to a completed state despite having unfinished tasks. By allowing agents to re-engage and complete outstanding tasks, and by increasing the maximum execution turns, the system ensures more thorough and reliable feature implementation. Additionally, the changes refine how task statuses are managed and displayed across the backend and frontend, providing a more accurate representation of work in progress.

Highlights

  • Task Retry Logic: Implemented a retry mechanism for agent execution to ensure all tasks are completed. If an agent finishes but leaves tasks in 'pending' or 'in_progress' status, it will be re-run up to 3 times with a continuation prompt to complete the remaining work.
  • Increased Max Turns Limit: The hard limit for the number of turns an agent can take in a single execution has been increased from 50 to 150, allowing for more complex and longer-running agent operations.
  • Improved Task Status Handling: Updated the server-side logic to correctly finalize task statuses when a feature transitions to 'waiting_approval' or 'verified'. 'In progress' tasks are marked 'completed', while 'pending' tasks remain 'pending' to accurately reflect their state.
  • UI Task Status Alignment: The UI now aligns with the server-side task status finalization, ensuring that 'in_progress' tasks are displayed as 'completed' when a feature is finished, while 'pending' tasks correctly show as 'pending'.
  • Comprehensive Unit Tests: Added a new suite of unit tests to cover various scenarios of the task retry logic, including cases where tasks are completed, remain pending, abort signals are triggered, and specific planning modes are used during retries.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • apps/server/src/services/agent-executor.ts
    • Increased the maximum turns limit for agent execution from 50 to 150.
  • apps/server/src/services/execution-service.ts
    • Added a retry loop to re-run the agent if incomplete tasks ('pending' or 'in_progress') are detected after initial execution, up to 3 attempts.
    • Generated a continuation prompt for retry runs, detailing remaining tasks.
    • Emitted progress events during task retry attempts.
    • Logged warnings if tasks remain incomplete after all retry attempts.
    • Updated the feature completion message to include the count of completed tasks if incomplete tasks were present.
  • apps/server/src/services/feature-state-manager.ts
    • Modified task finalization logic: 'in_progress' tasks are now marked 'completed' when a feature moves to 'waiting_approval' or 'verified', while 'pending' tasks retain their 'pending' status.
    • Added logging for pending tasks when a feature transitions to a final status.
  • apps/server/tests/unit/services/execution-service.test.ts
    • Added a new test suite for 'executeFeature - incomplete task retry'.
    • Included tests for scenarios where no re-run is needed (no tasks or all tasks completed).
    • Tested successful re-runs for pending and in-progress tasks, verifying continuation prompts and event emissions.
    • Validated that the maximum retry attempts are respected.
    • Confirmed that retries stop when an abort signal is triggered.
    • Verified that retry runs use 'planningMode: skip' and 'requirePlanApproval: false'.
  • apps/ui/src/components/views/board-view/components/kanban-card/agent-info-panel.tsx
    • Adjusted UI logic to display 'in_progress' tasks as 'completed' when a feature is finished, aligning with server-side status management.
Activity
  • The pull request was created by gsxdsm.
  • The pull request introduces new features related to task retry logic and improved agent execution limits.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds a retry loop in ExecutionService to re-run the agent up to three times for incomplete tasks using continuation prompts; increases per-task/default maxTurns from 50/20 to 100; logs pending-task counts in feature state finalization; enhances completion messaging and updates UI task finalization mapping.

Changes

Cohort / File(s) Summary
Agent execution / provider
apps/server/src/services/agent-executor.ts, apps/server/src/providers/claude-provider.ts
Increased per-task/default maxTurns from 50 (agent executor) and 20 (Claude provider) to 100; adjust execution options passed to agent/provider.
Execution logic & tests
apps/server/src/services/execution-service.ts, apps/server/tests/unit/services/execution-service.test.ts
Adds retry loop that re-runs agent up to 3 times when tasks remain pending/in_progress, builds continuation prompts listing remaining task IDs, emits auto-mode progress events, constructs richer completion messages (elapsed time, auto-verify, completed/total), and includes new unit tests covering retries, aborts, planning-mode, and progress events.
Feature state logging
apps/server/src/services/feature-state-manager.ts
Adds counting and warning logs for pending (never-started) tasks in waiting_approval and verified branches; retains existing finalization logic and completed-task accounting.
UI task status display
apps/ui/src/components/views/board-view/components/kanban-card/agent-info-panel.tsx
When a feature is finished, map in_progress (and failed agent-work state) to completed for display; pending stays pending, completed stays completed, aligning UI with server finalization logic.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Feature Executor
    participant ExecSvc as ExecutionService
    participant Agent as AgentExecutor
    participant StateMgr as FeatureStateManager

    Client->>ExecSvc: executeFeature(feature, tasks)
    ExecSvc->>Agent: run agent for tasks (maxTurns=100)
    Agent-->>ExecSvc: execution result

    rect rgba(100,150,200,0.5)
        ExecSvc->>ExecSvc: evaluate task completion
        alt incomplete tasks exist
            ExecSvc->>ExecSvc: retry_count < 3?
            ExecSvc->>ExecSvc: build continuation prompt with remaining task IDs
            ExecSvc->>Agent: re-run agent with continuation prompt (maxTurns=100)
            Agent-->>ExecSvc: execution result
            ExecSvc->>Client: emit auto-mode progress events
        else all tasks complete
            ExecSvc->>ExecSvc: finalize results (elapsed time, completionMessage)
        end
    end

    ExecSvc->>StateMgr: updateFeatureStatus(...)
    StateMgr-->>ExecSvc: status updated (logs pending counts)
    ExecSvc->>Client: emit feature_complete (completionMessage)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested labels

Enhancement, Tests

Poem

A rabbit nudges the agent to try thrice more,
Hops through tasks till the checklist is lore,
Retries counted under moonlit beams,
Logs and prompts stitching up the seams,
🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (7 files):

⚔️ apps/server/src/providers/claude-provider.ts (content)
⚔️ apps/server/src/services/agent-executor.ts (content)
⚔️ apps/server/src/services/execution-service.ts (content)
⚔️ apps/server/src/services/feature-state-manager.ts (content)
⚔️ apps/server/tests/unit/providers/claude-provider.test.ts (content)
⚔️ apps/server/tests/unit/services/execution-service.test.ts (content)
⚔️ apps/ui/src/components/views/board-view/components/kanban-card/agent-info-panel.tsx (content)

These conflicts must be resolved before merging into v0.15.0rc.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: task retry logic is introduced in execution-service.ts, and maxTurns limits are increased across multiple files (claude-provider, agent-executor).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/features-completed-too-soon
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a robust retry mechanism for agent tasks that haven't completed, addressing an issue where features were marked as complete prematurely. The maximum number of agent turns has also been increased. The changes include new backend logic in ExecutionService with comprehensive unit tests, adjustments in FeatureStateManager to handle task finalization, and UI updates in AgentInfoPanel to correctly reflect the status of incomplete tasks.

My review focuses on improving maintainability and robustness. I've pointed out an opportunity to refactor duplicated code in FeatureStateManager and suggested defining a magic number as a constant in ExecutionService. I also found a potential issue in the UI where a 'failed' task status isn't handled, and I've provided a suggestion to make the logic safer.

Overall, this is a well-implemented feature that improves the reliability of task execution.

// Check for incomplete tasks after agent execution.
// The agent may have finished early (hit max turns, decided it was done, etc.)
// while tasks are still pending. If so, re-run the agent to complete remaining tasks.
const MAX_TASK_RETRY_ATTEMPTS = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The value 3 is used here as a magic number for the maximum number of retry attempts. It would be better to define this as a constant at the top of the file (e.g., const DEFAULT_MAX_TASK_RETRY_ATTEMPTS = 3;). This improves readability and makes the value easier to find and change if needed.

Comment on lines +147 to +166
let tasksFinalized = 0;
let tasksPending = 0;
for (const task of feature.planSpec.tasks) {
if (task.status === 'in_progress') {
task.status = 'completed';
tasksFinalized++;
} else if (task.status === 'pending') {
tasksPending++;
}
}
if (tasksFinalized > 0) {
logger.info(
`[updateFeatureStatus] Finalized ${tasksFinalized} in_progress tasks for feature ${featureId} moving to verified`
);
}
if (tasksPending > 0) {
logger.warn(
`[updateFeatureStatus] Feature ${featureId} moving to verified with ${tasksPending} pending (never started) tasks out of ${feature.planSpec.tasks.length} total`
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code is nearly identical to the one for the waiting_approval status (lines 117-136). To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, consider refactoring this logic into a private helper function. This function could take the feature and the status string as parameters to handle task finalization and logging.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/server/src/services/feature-state-manager.ts (1)

108-171: Consider extracting the duplicated task-finalization logic into a helper.

The waiting_approval (Lines 116–141) and verified (Lines 146–171) branches contain nearly identical code: iterating tasks, finalizing in_progresscompleted, counting pending tasks, logging, and updating tasksCompleted. Extracting this into a private method would reduce duplication and make future changes less error-prone.

♻️ Example helper extraction
+  private finalizeTasks(
+    tasks: ParsedTask[],
+    featureId: string,
+    targetStatus: string
+  ): { tasksFinalized: number; tasksPending: number } {
+    let tasksFinalized = 0;
+    let tasksPending = 0;
+    for (const task of tasks) {
+      if (task.status === 'in_progress') {
+        task.status = 'completed';
+        tasksFinalized++;
+      } else if (task.status === 'pending') {
+        tasksPending++;
+      }
+    }
+    if (tasksFinalized > 0) {
+      logger.info(
+        `[updateFeatureStatus] Finalized ${tasksFinalized} in_progress tasks for feature ${featureId} moving to ${targetStatus}`
+      );
+    }
+    if (tasksPending > 0) {
+      logger.warn(
+        `[updateFeatureStatus] Feature ${featureId} moving to ${targetStatus} with ${tasksPending} pending (never started) tasks out of ${tasks.length} total`
+      );
+    }
+    return { tasksFinalized, tasksPending };
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/services/feature-state-manager.ts` around lines 108 - 171,
Extract the duplicated task-finalization logic into a helper (e.g., a private
function finalizeTasksOnCompletion(planSpec, featureId, statusLabel) or
finalizePlanSpecTasks(feature, featureId, statusLabel) called from
updateFeatureStatus) that: iterates planSpec.tasks, converts 'in_progress' →
'completed' and counts finalized and pending tasks, updates
planSpec.tasksCompleted and planSpec.currentTaskId, and emits the same
logger.info/logger.warn messages using statusLabel; then replace the duplicated
blocks in the 'waiting_approval' and 'verified' branches with a single call to
that helper (pass feature.planSpec, featureId, and a label like
'waiting_approval' or 'verified').
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/server/src/services/feature-state-manager.ts`:
- Around line 108-171: Extract the duplicated task-finalization logic into a
helper (e.g., a private function finalizeTasksOnCompletion(planSpec, featureId,
statusLabel) or finalizePlanSpecTasks(feature, featureId, statusLabel) called
from updateFeatureStatus) that: iterates planSpec.tasks, converts 'in_progress'
→ 'completed' and counts finalized and pending tasks, updates
planSpec.tasksCompleted and planSpec.currentTaskId, and emits the same
logger.info/logger.warn messages using statusLabel; then replace the duplicated
blocks in the 'waiting_approval' and 'verified' branches with a single call to
that helper (pass feature.planSpec, featureId, and a label like
'waiting_approval' or 'verified').

gsxdsm and others added 2 commits February 16, 2026 22:19
…/agent-info-panel.tsx

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/server/src/services/agent-executor.ts (1)

334-334: Inconsistent maxTurns handling across execution paths.

Line 334 caps per-task turns with Math.min(sdkOptions?.maxTurns ?? 100, 100), but other buildExecOpts call sites don't apply the same cap:

  • Line 553 (plan revision): sdkOptions?.maxTurns ?? 100 — no cap, so a user-configured value > 100 is passed through.
  • Line 664 (single-agent continuation): options.sdkOptions?.maxTurns — no default at all, so undefined is passed when unset (falling through to the provider's default of 100).

If the intent is to enforce a 100-turn ceiling, apply it consistently. If not, the cap on line 334 is misleading. Consider extracting a helper like getEffectiveMaxTurns(sdkOptions) to centralize this logic.

Suggested helper
+  private getEffectiveMaxTurns(sdkOptions?: { maxTurns?: number }, cap = 100): number {
+    return Math.min(sdkOptions?.maxTurns ?? cap, cap);
+  }

Then use it at lines 334, 553, and 664.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/services/agent-executor.ts` at line 334, Introduce a single
helper getEffectiveMaxTurns(sdkOptions) that returns
Math.min(sdkOptions?.maxTurns ?? 100, 100) and use it everywhere buildExecOpts
is invoked so maxTurns handling is consistent: replace the current inline cap at
the buildExecOpts call that uses Math.min, the plan-revision call that uses
sdkOptions?.maxTurns ?? 100, and the single-agent continuation call that passes
options.sdkOptions?.maxTurns so all three call sites pass
getEffectiveMaxTurns(sdkOptions) into buildExecOpts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/server/src/services/agent-executor.ts`:
- Line 334: Introduce a single helper getEffectiveMaxTurns(sdkOptions) that
returns Math.min(sdkOptions?.maxTurns ?? 100, 100) and use it everywhere
buildExecOpts is invoked so maxTurns handling is consistent: replace the current
inline cap at the buildExecOpts call that uses Math.min, the plan-revision call
that uses sdkOptions?.maxTurns ?? 100, and the single-agent continuation call
that passes options.sdkOptions?.maxTurns so all three call sites pass
getEffectiveMaxTurns(sdkOptions) into buildExecOpts.

@gsxdsm gsxdsm merged commit 57446b4 into AutoMaker-Org:v0.15.0rc Feb 17, 2026
6 checks passed
@gsxdsm gsxdsm deleted the fix/features-completed-too-soon branch February 17, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant