[FEATURE]: Allow subagents to spawn subagents
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I was trying to build a helper subagent that takes different paths and calls tools to fulfill a request based on what was asked of it, but seemed to have run into the limitation that a subagent cannot use the task tool at all? The docs don't call this out from looking over the agent page, and there are no docs on the task tool.
The idea being that one of the routes my subagent could take would be to browse the web using the chrome devtools MCP, but because I only want a subset of tools enabled for the main helper subagent, and my rules for browsing the web warranted their own system prompt, I made a browsing subagent to not clutter up the main subagent. After troubleshooting why it couldn't be called, I saw using mitmproxy that my tool permissions for the task tool were ignored. Looking at the code, I also saw a flag here on line 60 that looks like it would deliberately take this permission away. I understand that this is probably to prevent recursion issues, but was wondering if this could be a feature in the future and just have OpenCode put a max depth on the task tool call to stop possible recursion.
This issue might be a duplicate of existing issues. Please check:
- #7296: [FEATURE]: Allow configurable subagent-to-subagent task delegation with call limits - Directly addresses allowing subagents to call the task tool with configurable limits to prevent infinite recursion
- #2906: Limit Subagent Tree Depth - Discusses limiting the depth of subagent nesting to prevent recursive duplication of work
- #8114: Task tool permission override no longer works for nested sub-agents - Related issue about task tool permissions being ignored for nested subagents
Feel free to ignore if none of these address your specific case.
So I wasn't able to find the subagent-to-subagent issue before making this one. That is pretty much what I want. Looks like that issue has been closed without actual resolution but a PR was opened. Would be nice to get https://github.com/anomalyco/opencode/pull/7756 in to support this
@zackheil the issue that you linked has been reopened (until the PR is merged or another solution is implemented). I'd suggest leaving a comment there to generate more traction and closing this one to avoid splitting it