feat: add support for calling multiple subagents at once #1172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR
Subagents now execute in parallel instead of sequentially. Add
maxConcurrentSubagentsparameter (default: 1) to control concurrency. For 5 independent tasks, execution time reduces from 5×T to ~2×T withmaxConcurrentSubagents=3. Users can enable and configure parallel execution through the CLI settings menu. The TaskTool now dynamically informs the AI about the actual execution mode to ensure correct behavior. Settings require CLI restart to take effect. Includes robust error handling and input validation to prevent edge cases.Dive Deeper
Core Changes:
coreToolScheduler.tsto separate TaskTool execution from other toolsmaxConcurrentSubagentslimit using Set-based promise trackingexecuteTaskToolCallsInParallel()with race-condition-free concurrency controlexecuteSingleToolCall()for reuse.finally()to ensure promises are always removed from executing Set, even when tasks failmaxConcurrentSubagentsto minimum of 1 usingMath.max()to prevent infinite loopsConfiguration:
maxConcurrentSubagentsparameter toConfigandQueryOptions(SDK)CLI Settings Menu:
/settingscommand in the CLIrequiresRestart: true- CLI restart required for changes to take effectDynamic AI Guidance:
Testing:
Usage:
Via CLI Settings Menu (requires restart):
qwenCLI/settingscommandVia SDK:
Important Notes:
Known Limitation:
Reviewer Test Plan
CLI Settings Menu:
qwenand type/settingsRestart requirement verification:
qwenagain)Parallel execution with AI awareness:
Sequential fallback:
maxConcurrentSubagents: 1)Concurrency limit:
maxConcurrentSubagents: 2Tool separation: Mix TaskTools and other tools, verify only TaskTools parallelize
AI guidance verification:
Error handling verification:
Input validation verification:
maxConcurrentSubagentsto 0 or negative values via SDKRun existing integration tests to validate no regressions:
Testing Matrix
Linked issues / bugs
Related #856 to improving qwen-code workflow performance for multi-task scenarios.