Repository navigation
Description
- I have verified this feature I'm about to request hasn't been suggested before.
Implemented in #63227 (feat(core): bound subagent concurrency), ready for review.
The gap today
subagent fan-out is unbounded. A model that emits five subagent calls in one step gets five child sessions running at the same time, each with its own prompt cache key and its own context, and nothing in config bounds that. On a metered key that is a visible cost jump for work one agent could have done, and on a small machine it is five competing processes plus the parent. The only related knob, experimental.subagent_depth, bounds nesting depth, not how many run at once.
What the enhancement adds
A cap on how many of one session's subagents run at once, settable from every config layer plus a startup switch, with a chosen over-limit behavior:
| Setting | Values | Default |
|---|---|---|
experimental.subagent_concurrency |
-1 or unset for unlimited, 0 for none, N for a cap |
unlimited |
experimental.subagent_over_limit |
"fail" returns a tool error immediately, "wait" queues until a slot frees |
"fail" |
OPENCODE_SUBAGENT_CONCURRENCY |
the same integer, ahead of every config document | unset |
{
"experimental": {
"subagent_concurrency": 2,
"subagent_over_limit": "wait",
},
}Why it is worth merging now
- It ships in feat(core): bound subagent concurrency #63227 with tests and docs, not as a sketch: 82 passing test cases across four files, including a new
packages/core/test/session-subagent-job.test.tsfor slot and queue semantics, plus the "Subagent concurrency" section in the config docs. - Non-breaking by construction. The elected default reproduces today's behavior exactly, so nothing changes until a config sets a key, and the unlimited path carries no bookkeeping at all. No new feature flag is needed.
- Small surface. Two optional keys on the existing
experimentalblock, one env var read ahead of config the wayOPENCODE_FLAGSalready works, and a per-parent slot registry inside the existingSubagentJobservice rather than a new service. - Correct at the edges. A slot is taken before the child session is created, so a rejected call leaves no orphan session; release is idempotent and owned either by the call fiber or by the backgrounded child's completion observer; a follow-up on a running child keeps its existing slot instead of budgeting a second one; at a cap of
0the tool leaves the advertised list so the model is never offered a call that can only fail. - The Windows
check-testtimeout from the first CI run is already fixed on the same branch (fix(core): use the in-memory watcher in the plugin test layer): the plugin fixture used the native watcher, whose only bound is anEffect.timeoutthatTestClockleaves inert. The full core suite shows an identical failure-name set before and after the change.
Same ask as the earlier reports, now with a working implementation attached: #27110 (max parallel subagents), #54935 (uncapped parallel subagents cost more than one agent) and #50563 (the sibling case, parallel tool calls inside one step).
Requested labels: enhancement, core. Will close with #63227.
Activity
opencodejr commentedon Nov 11, 2026
Thanks for the detailed write-up and for the implementation in #63227!
I think this is a duplicate of #27110. That issue already asks for a setting to limit how many subagents run in parallel, with extra ones waiting their turn, and your PR #63227 already closes it. Discussion of the feature can continue there, and discussion of the implementation on the PR.
Possible duplicates and related items, ordered from most to least likely:
experimental.subagent_concurrencyand also targets [FEATURE]: Setting to limit max number of parallel subagents #27110, which may be worth comparing with feat(core): bound subagent concurrency #63227The bot will close this issue as a duplicate in 1 day unless you reply explaining how it differs from #27110.
opencodejr commentedon Nov 12, 2026
We haven't heard back since the duplicate notice, so I'm closing this as a duplicate of #27110. That issue already asks for a setting to limit how many subagents run in parallel, with extra calls queued. Thanks again for the work in #63227, which already closes #27110. The implementation can be discussed on that PR, and the feature on #27110.
If this request is different from #27110, reply here and the issue will be reopened.