Limit Subagent Tree Depth #1912

Open
opened 2026-02-16 17:33:12 -05:00 by yindo · 2 comments
Owner

Originally created by @garrett-hopper on GitHub (Oct 1, 2025).

Originally assigned to: @thdxr on GitHub.

I'd like to be able to limit subagents from creating further subagents too deeply. Often I'll find them creating a deeply nested tree which usually means they're duplicating work that was done higher in the tree, or at the very least should be orchestrated by the parent agent explicitly instead of the subagent deciding to "analyze this github repo" on its own which in turn creates its own set of recursive trees.
Perhaps a default limit of 2-3 would make sense. In my experience, once it goes any further than that, it's usually an indication of a problem.

It'd be easier to catch these kinds of issues if sub-sub-agents were visualized. Currently only the initial call to the subagent is shown; ideally nested tool calls under that agent would be visually shown and indented to make it clear what's actively being done without having to switch to that agent's session.

Originally created by @garrett-hopper on GitHub (Oct 1, 2025). Originally assigned to: @thdxr on GitHub. I'd like to be able to limit subagents from creating further subagents too deeply. Often I'll find them creating a deeply nested tree which usually means they're duplicating work that was done higher in the tree, or at the very least should be orchestrated by the parent agent explicitly instead of the subagent deciding to "analyze this github repo" on its own which in turn creates its own set of recursive trees. Perhaps a default limit of 2-3 would make sense. In my experience, once it goes any further than that, it's usually an indication of a problem. It'd be easier to catch these kinds of issues if sub-sub-agents were visualized. Currently only the initial call to the subagent is shown; ideally nested tool calls under that agent would be visually shown and indented to make it clear what's actively being done without having to switch to that agent's session.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 1, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2894: Reports similar behavior where opencode spawns excessive numbers of subagents (50-100 in a session), causing suspicious behavior and potential performance issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 1, 2025): This issue might be a duplicate of existing issues. Please check: - #2894: Reports similar behavior where opencode spawns excessive numbers of subagents (50-100 in a session), causing suspicious behavior and potential performance issues Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 1, 2025):

yeah that makes sense

@rekram1-node commented on GitHub (Oct 1, 2025): yeah that makes sense
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1912