feat: Add subagent tool for focused subtasks#11742
feat: Add subagent tool for focused subtasks#11742kels-ng wants to merge 2 commits intoRooCodeInc:mainfrom
Conversation
|
Does this also support sending off multiple Subagents in parallel and waiting for the result? I might play around with this today to check how reliably this works with my GSD-Roo port I created yesterday: It works well with Subtasks already, so I guess this will already be a nice abstraction layer for agents which don't need supervision. |
- Added new tool parameters for subagent including "description" and "subagent_type". - Implemented filtering logic to include/exclude the subagent tool based on experiment settings. - Enhanced localization for subagent tool in multiple languages. - Updated UI components to display subagent status and progress. - Introduced subagent-specific tool restrictions in the backend logic. This commit lays the groundwork for running subagents in the background for research or sub-tasks, enhancing the overall functionality of the toolset.
- Introduced support for running multiple subagents in parallel by managing child tasks with unique toolCallIds. - Updated the Task class to hold active subagent children in a Map for better tracking and management. - Enhanced the reportSubagentProgress method to update specific subagent messages based on runId, allowing for real-time progress updates. - Modified the ClineProvider to handle cancellation of multiple running subagents. - Improved error handling and messaging for subagent execution. These changes significantly improve the subagent's capabilities, enabling more efficient task management and user feedback during concurrent operations.
Hello, Good point. I checked and add parallel subagent execution: Also, rebase on top of HEAD. |
|
@cte @daniel-lxs Any thoughts about the PR? |

Add a subagent tool so the model can run a focused sub-task in the background. The subagent’s result or summary is returned as the tool result and the main task continues in the same chat, without creating a new user-visible task.
Benefits:
Related GitHub Issue
Closes: #11741
Roo Code Task Context (Optional)
Description
This PR adds the subagent tool so the model can run a focused sub-task in the background and receive its result back in the main task.
Implementation overview:
subagentis added toexperimentIds,experimentsSchema, andtoolNames; message types supportsubagentRunning/subagentCompletedandprogressStatus.spin;ClineSayToolincludes optional fields for subagent payloads.src/shared/subagent.tswith constants and types;tools.tsextended withsubagent_typeanddescriptionparams andTOOL_DISPLAY_NAMES.subagent; SUBAGENT experiment (off by default) inexperiments.ts.NativeToolCallParserhandlessubagent(description, prompt, subagent_type);presentAssistantMessagewires subagent progress and delegates toSubagentTool;SubagentToolvalidates args, emits running/completed tool messages, callsprovider.runSubagentInBackground, and pushes the tool result (string or structured e.g. cancelled).TaskgainssubagentType,needUpdateHistory,reportSubagentProgress,runBackgroundSubagentLoop, andbackgroundCompletionResolve;build-toolsappliesapplySubagentToolRestrictions(explore = read-only + attempt_completion; all subagents exclude subagent + ask_followup_question, new_task, switch_mode, update_todo_list).runSubagentInBackgroundcreates a child Task, runsrunBackgroundSubagentLoop, and returns a Promise that resolves viabackgroundCompletionResolve(or rejects on error).task.backgroundCompletionResolveis set, completion resolves that, clears callbacks, and aborts the task (subagent exit path).subagentRunning(description, progress, optional spin) andsubagentCompleted(result/error/resultCode/messageKey); CodeAccordion supportsprogressStatus.spin.subagentsin chat.json and SUBAGENT experiment name/description in settings.json.Design choices:
SUBAGENT_EXCLUDE_TOOLS(no kilocode-specific tools).filter-tools-for-mode).Test Procedure
Unit tests (run from repo root):
cd src && pnpm exec vitest run core/tools/__tests__/SubagentTool.spec.ts core/assistant-message/__tests__/NativeToolCallParser.spec.ts— SubagentTool parseLegacy/execute and NativeToolCallParser subagent cases.cd src && pnpm exec vitest run core/prompts/tools/__tests__/filter-tools-for-mode.spec.ts core/task/__tests__/flushPendingToolResultsToHistory.spec.ts— subagent experiment filtering and reportSubagentProgress.src/sharedtests (e.g. experiments.spec.ts) to confirm SUBAGENT in experiment config and test records.Manual testing:
Pre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Discord: kels9009
Telegram: kelsnewman
Interactively review PR in Roo Code Cloud