feat: sequential fan-out / fan-in for orchestrator (Phase 2 of #12330)#12335
feat: sequential fan-out / fan-in for orchestrator (Phase 2 of #12330)#12335roomote-v0[bot] wants to merge 3 commits into
Conversation
… of #12330) Adds subtask queue support to the new_task tool, allowing the orchestrator to define multiple subtasks that execute automatically in sequence without returning to the parent between each one. This saves LLM API calls and enables more efficient multi-agent workflows. Key changes: - SubtaskQueueItem, SubtaskResult types in packages/types/src/history.ts - task_queue parameter on new_task tool (optional JSON array) - NewTaskTool parses and validates queued subtasks, stores on parent - delegateParentAndOpenChild persists queue in parent HistoryItem - reopenParentFromDelegation auto-advances queue via advanceSubtaskQueue - formatAggregatedQueueResults aggregates all results when queue completes - 9 new tests covering queue advance, exhaustion, and result formatting - All 56 existing delegation tests continue to pass
|
Thanks for implementing Phase 2 (#12335)! This is a solid step forward. The A few questions / suggestions:
Overall, I'm happy with the direction. Let's continue with the phased approach. @roomote Looking forward to your thoughts on the above points. Thanks for driving this! |
Fixed two bugs in To answer the questions from the comment:
|
…advanceSubtaskQueue - Fix off-by-one: dispatch subtaskQueue[currentIndex] instead of subtaskQueue[nextIndex], preventing the first queued item from being skipped - Fix completedMode: fetch child history to get the child actual mode instead of incorrectly using the parent historyItem.mode - Update tests to reflect corrected queue semantics (subtaskQueueIndex represents the next item to dispatch, not the currently running item)
|
Thanks for the quick fixes and detailed answers! The bug fixes in A few thoughts:
Overall, Phase 2 is progressing well. Thanks for continuing to iterate on this. |
The Windows CI failure was caused by |
The Windows CI bundle step fails with EBUSY when antivirus or indexing services hold brief locks on files during copyFileSync. Add a copyFileWithRetry helper (matching the existing rmDir retry pattern) that retries up to 5 times with exponential backoff for EBUSY, EPERM, and EACCES errors.
|
Thanks for the quick fix on the Windows CI failure! It's good to know the EBUSY error was unrelated to the sequential fan-out changes, and the retry mechanism you added makes sense (consistent with the existing At this point, Phase 2 looks solid — the core functionality is implemented, tests are passing, and it's backward compatible. @roomote Happy to let this move forward. Thanks again for driving the phased improvements. |
No issues to fix -- the triggering comment is an approval message. The PR looks good as-is with all tests passing and backward compatibility maintained. |
Done -- posted a comment on issue #12330 mentioning Phase 2 and linking to this PR. |
|
Closing as part of PR restructuring per issue #12330. This work will be combined into a new Phase 2+3 PR with proper stacked branching. |
Related GitHub Issue
This PR attempts to address Issue #12330 (Phase 2). Feedback and guidance are welcome.
Description
Implements Phase 2: Sequential fan-out / fan-in for the orchestrator mode, as discussed in #12330. This builds on Phase 1 (structured context summaries, #12332) by adding the ability for the orchestrator to define multiple subtasks that execute automatically in sequence without returning to the parent between each one.
How it works:
new_taskwith an optionaltask_queueparameter -- a JSON array of{mode, message}objects defining additional subtasks.mode/messageparams) runs immediately, as usual.attempt_completion,reopenParentFromDelegationchecks if the parent has remaining queued subtasks.Key implementation details:
SubtaskQueueItem,SubtaskResulttypes (packages/types/src/history.ts): New schema types for queue items and their results, stored on the parent HistoryItem.task_queueparameter onnew_task: Optional JSON array parsed and validated by NewTaskTool. Each queued mode is validated before delegation starts.advanceSubtaskQueuemethod (ClineProvider): Core queue advancement logic. Called fromreopenParentFromDelegationwhen a subtask completes and the parent has a queue. Returns{handled: true}if advancing (caller returns early) or{handled: false, aggregatedSummary}when queue is exhausted.formatAggregatedQueueResults: Formats all subtask results into a structured markdown summary for the parent.task_queueparameter is optional. Without it,new_taskbehaves exactly as before. Existing sequential workflows are unaffected.Test Procedure
src/__tests__/sequential-fan-out.spec.tscovering:advanceSubtaskQueuewith more items remaining (returns handled=true, creates next child)advanceSubtaskQueuewith queue exhausted (returns handled=false, aggregated summary)advanceSubtaskQueuewith empty queue (no-op)formatAggregatedQueueResultswith multiple, zero, and single resultsPre-Submission Checklist
Documentation Updates
No user-facing documentation changes required. The
task_queueparameter is auto-documented via the tool definition in the system prompt.Additional Notes
This is Phase 2 of the incremental approach discussed in #12330. Phase 1 (structured context summaries) is in #12332. Phase 3 (true parallel execution) would be a future consideration if architecturally feasible.
Interactively review PR in Roo Code Cloud