8000 Subtasks are sometimes not reporting back to Parent tasks · Issue #1547 · RooVetGit/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Subtasks are sometimes not reporting back to Parent tasks #1547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cannuri opened this issue Mar 10, 2025 · 1 comment · Fixed by #1564
Closed

Subtasks are sometimes not reporting back to Parent tasks #1547

cannuri opened this issue Mar 10, 2025 · 1 comment · Fixed by #1564
Labels
actionable Confirmed and ready to work on bug Something isn't working needs scoping Needs up-front scoping to be actionable

Comments

@cannuri
Copy link
cannuri commented Mar 10, 2025

Which version of the app are you using?

3.8.4

Which API Provider are you using?

Anthropic

Which Model are you using?

Claude 3.7 Sonnet

What happened?

Sometimes subtasks are not reporting back to parent tasks which breaks the workflow. It seems as if it is sometimes losing its subtask-state.

Steps to reproduce

  1. Create a task and tell it to create a subtask for something
  2. In the subtask, press cancel, then resume the subtask
  3. The subtask will not report back to the parent task

I noticed this sometimes even happened without me cancelling and resuming the subtask.

Relevant API REQUEST output

Additional context

No response

@cannuri cannuri added the bug Something isn't working label Mar 10, 2025
@hannesrudolph hannesrudolph moved this from New to Issue [Needs Scoping] in Roo Code Roadmap Mar 10, 2025
@hannesrudolph hannesrudolph added actionable Confirmed and ready to work on needs scoping Needs up-front scoping to be actionable labels Mar 10, 2025
@cannuri
Copy link
Author
cannuri commented Mar 11, 2025

From some Roo Code investigation:

Subtask Cancellation and Resumption Issue Analysis

After investigating the code, I've identified the issue with subtasks not reporting back to parent tasks when cancelled and resumed.

Root Cause

The problem occurs in the cancelTask() method in ClineProvider.ts (lines 1934-1965). When a subtask is cancelled using the "Cancel" button:

  1. The cancelTask() method is called, which:

    • Aborts the current task
    • Sets abandoned = true
    • Reinitializes the task from history
    • But doesn't check if it's a subtask or notify the parent task
  2. In contrast, when using the "Clear Task" button:

    • The clearTask case in the WebviewMessage handler (line 999) is triggered
    • It calls finishSubTask() which properly:
      • Removes the subtask from the stack
      • Calls resumePausedTask() on the parent task
      • Sets isPaused = false on the parent task
  3. As a result, when a subtask is cancelled:

    • The parent task remains in the isPaused = true state
    • It continues to wait indefinitely in waitForResume()
    • Even when the subtask is resumed, the parent task never gets notified

Solution

The solution is to modify the cancelTask() method in ClineProvider.ts to check if the current task is a subtask, and if so, properly notify the parent task before reinitializing:

async cancelTask() {
  if (this.getCurrentCline()) {
    const currentCline = this.getCurrentCline()!;
    const { historyItem } = await this.getTaskWithId(currentCline.taskId);
    
    // Check if this is a subtask before aborting
    const isSubTask = currentCline.isSubTask;
    
    currentCline.abortTask();
    
    await pWaitFor(
      () =>
        currentCline === undefined ||
        currentCline.isStreaming === false ||
        currentCline.didFinishAbortingStream ||
        currentCline.isWaitingForFirstChunk,
      {
        timeout: 3_000,
      },
    ).catch(() => {
      console.error("Failed to abort task");
    });
    
    if (currentCline) {
      currentCline.abandoned = true;
    }
    
    // If this was a subtask, notify the parent task
    if (isSubTask) {
      await this.finishSubTask(`Task cancelled: The subtask was cancelled by the user.`);
    }
    
    // Reinitialize from history
    await this.initClineWithHistoryItem(historyItem);
  }
}

This change would ensure that when a subtask is cancelled, the parent task is properly notified and can continue execution, resolving the issue where subtasks don't report back to parent tasks when cancelled and resumed.

Implementation Challenge

The main challenge is that the isSubTask flag in the Cline class is private, so it can't be directly accessed from the ClineProvider class. There are two possible approaches:

  1. Add a public getter method for isSubTask in the Cline class
  2. Use the existing getParentTask() method to check if the task has a parent (which would indicate it's a subtask)

The second approach is simpler and can be implemented without modifying the Cline class:

// If this was a subtask (has a parent task), notify the parent task
if (currentCline.getParentTask()) {
  await this.finishSubTask(`Task cancelled: The subtask was cancelled by the user.`);
}

This change would fix the issue with cancelled subtasks not reporting back to their parent tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Confirmed and ready to work on bug Something isn't working needs scoping Needs up-front scoping to be actionable
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants
0