GeezerVison is showing github.com — fix(core): PR #88 regresses subagent_depth: 0 — a top-level session can launch subagents again · Issue #89 · developing-today-forks/opencode
fix(core): PR #88 regresses subagent_depth: 0 — a top-level session can launch subagents again #89
Description
Finding
PR #88 (merged 2026-10-19T00:45:11Z, merge commit b3e93cd066910ada3bcdf1f95b7015897e4abd15, fixes #87) regresses experimental.subagent_depth: 0: a top-level (root) session can launch subagents again, even though 0 is documented to disable subagents entirely.
Evidence
- Schema,
packages/schema/src/config/experimental.ts (on current main b3e93cd): subagent_depth is a NonNegativeInt described as "Maximum subagent nesting depth below a top-level session. 0 disables subagents and 1 stops subagents from launching their own. Defaults to 5."
- Before PR fix(core): guard subagent depth walk against parent cycles #88,
packages/core/src/tool/plugin/subagent.ts checked the limit after the parent walk, unconditionally: a root session has depth 0, and 0 >= 0 failed the call.
- PR fix(core): guard subagent depth walk against parent cycles #88 moved the check inside the walk loop (
packages/core/src/tool/plugin/subagent.ts, current main: the if (depth >= limit) now sits inside while (current.parentID) { ... }). A root session has no parentID, so the loop body never executes, the depth check is never reached, and execution proceeds to agent resolution and child-session creation.
- A non-root session with limit 0 still fails (the loop runs once, depth becomes 1,
1 >= 0), so only the top-level case regressed — which is exactly the case "0 disables subagents" is about.
- Verified by tracing/simulating both versions of the walk: limit 0 / root session — old code: FAIL (depth limit); new code: ALLOW. Limit 1 and limit 5 agree between old and new for root and child sessions.
- Test gap: PR fix(core): guard subagent depth walk against parent cycles #88's new tests cover only the parent-cycle and self-parented cases. The pre-existing configured-limit test uses
subagent_depth: 1 from a child session (the loop runs), so no test pins limit 0 from a top-level session.
Why it matters
A user who set subagent_depth: 0 specifically to disable subagent spawning gets subagents spawned from top-level sessions anyway — a silent loss of a documented configuration control, introduced by a fix for a different bug (#87).
Acceptance criteria
- With
experimental.subagent_depth: 0, a subagent call from a top-level session fails with Subagent depth limit reached (0) and creates no child session.
- A regression test pins that case (top-level session, limit 0), alongside the existing limit-1 and cycle tests.
- Existing behaviour is unchanged for limits >= 1 and for the PR fix(core): guard subagent depth walk against parent cycles #88 cycle/self-parent cases (full
tool-subagent.test.ts passes).
Found by the pr-diff-review job reviewing PR #88's diff against current main. Single-repo: the subagent_depth walk exists only in this repo's core (per #87's cross-repo check; code searches in developing-today/code and developing-today/openchamber return no subagent_depth).
Metadata
Metadata
Development
No branches or pull requestsIssue actions