Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 15, 2025

This PR fixes the orchestrator mode restoration issue described in #5747 where sub-tasks launched by the Orchestrator mode were not properly returning to the parent Orchestrator task after completion or interruption.

Problem

  • When sub-tasks get interrupted (e.g., Claude "overloaded" error), the main task doesn't return to orchestrator mode
  • Modes like "architect" and "ask" have lower success rates of returning to parent tasks after completion
  • Users expect to be able to close VSCode, reopen it, and restart with the Orchestrator top-level task

Solution

This PR implements a comprehensive fix with four major components:

1. Enhanced mode restoration in resumePausedTask method

  • Added comprehensive mode restoration logic in Task.ts lines 766-793
  • Checks if current mode differs from paused mode and restores it with proper error handling and logging

2. Mode restoration safety net in finishSubTask method

  • Enhanced ClineProvider.ts lines 229-264 to include mode restoration as a safety net
  • Ensures parent task's mode is properly restored regardless of how the sub-task ends

3. Mode validation and restoration in task resumption from history

  • Added mode restoration logic in Task.ts lines 814-838
  • Ensures correct mode is restored when tasks are resumed from history

4. Error handling for interrupted sub-tasks

  • Enhanced error handling in Task.ts lines 1462-1520 to include mode restoration
  • Ensures parent task mode is restored even during error scenarios

Key Changes

  • src/core/task/Task.ts: Enhanced resumePausedTask(), resumeTaskFromHistory(), and stream error handling methods with comprehensive mode restoration logic
  • src/core/webview/ClineProvider.ts: Added mode restoration safety net in finishSubTask() method

Testing

  • All existing tests pass
  • The fix provides comprehensive mode restoration coverage across all sub-task lifecycle scenarios
  • Handles normal completion, interruption, error handling, and task resumption from history

Impact

  • Fixes the core issue where orchestrator mode wasn't properly restored after sub-task completion/interruption
  • Improves reliability of the orchestrator workflow
  • Ensures consistent user experience when resuming tasks from history

Fixes #5747


Important

Fixes orchestrator mode restoration for sub-tasks, ensuring correct mode restoration on task resumption, completion, and interruption.

  • Behavior:
    • Fixes orchestrator mode restoration for sub-tasks in Task.ts and ClineProvider.ts.
    • Ensures mode restoration on task resumption, completion, and interruption.
  • Functions:
    • resumePausedTask() and resumeTaskFromHistory() in Task.ts now include mode restoration logic.
    • finishSubTask() in ClineProvider.ts adds a safety net for mode restoration.
    • Enhanced error handling in Task.ts to restore mode during sub-task interruptions.
  • Testing:
    • All existing tests pass, ensuring comprehensive mode restoration coverage across scenarios.
  • Impact:

This description was created by Ellipsis for 53e264b. You can customize this summary. It will automatically update as commits are pushed.

- Enhanced resumePausedTask method with comprehensive mode restoration logic
- Added mode restoration safety net in finishSubTask method
- Improved mode validation and restoration in task resumption from history
- Added error handling for interrupted sub-tasks with mode restoration
- Ensures parent task mode is properly restored regardless of how sub-task ends

Fixes #5747
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 15, 2025 15:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 15, 2025
this.isPaused = false
this.emit("taskUnpaused")

// Restore the mode that was active when this task was paused
Copy link
Contributor

Choose a reason for hiding this comment

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

The mode restoration logic in resumePausedTask (and similarly in resumeTaskFromHistory and in the streaming error handling block) is very similar. Consider extracting this logic into a dedicated helper function to reduce duplication and simplify maintenance.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 15, 2025
@daniel-lxs daniel-lxs moved this from Triage to Roomote/renovate BOT in Roo Code Roadmap Jul 15, 2025
@daniel-lxs daniel-lxs closed this Sep 16, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 16, 2025
@github-project-automation github-project-automation bot moved this from Renovate BOT to Done in Roo Code Roadmap Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Sub-tasks not returning to Orchestrator, re-starting tasks not working

3 participants