Skip to content

docs/config: subagent_depth defaults to 1 and is undocumented, so subagents can't delegate #59826

Open

Description

@srobroek

Summary

experimental.subagent_depth defaults to 1 in 2.1.4, so a subagent cannot spawn another subagent ("Subagent depth limit reached (1)"). The default and the setting are not mentioned in the V2 docs (agents / config pages), so agent designs that delegate one level down (for example a coder subagent spawning explore) fail with no documented fix.

Environment

  • opencode version: 2.1.4
  • OS: Darwin 25.6.0 (darwin arm64); also Linux
  • Install/channel: latest (official installer)
  • Active plugins: not required to reproduce

Reproduction

  1. Define a subagent coder whose permissions allow subagent on explore.
  2. From the main session, spawn coder and ask it to delegate a search to explore.

Expected Behavior

Either a documented default and setting, or a default that allows at least one nested level (common pattern: main → specialist → explore).

Actual Behavior

The nested spawn fails with Subagent depth limit reached (1). Setting experimental.subagent_depth: 3 in opencode.json fixes it; the only place we found the setting was the config schema.

Additional Context

Related closed issues on depth-2 behaviour: #49342, #39112.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the clear write-up, @srobroek!

    You're asking for the default experimental.subagent_depth to allow at least one nested level (main → specialist → explore), or for the setting to be easier to find. Maintainers will consider it.

    Some context:

    • The default of 1 is intentional. The depth check in packages/core/src/tool/plugin/subagent.ts uses subagent_depth ?? 1, and the tests expect nesting to be blocked unless you raise the setting.
    • The setting is in the V2 docs, but only in the Experimental section of the config page ("Subagent depth"). It says the default is 1, so a subagent cannot start another subagent. It isn't mentioned on the agents page, which is probably where most people look when designing delegating agents.
    • Your workaround is the supported way to allow nesting:
      {
        "experimental": { "subagent_depth": 2 }
      }
      2 allows main → subagent → subagent; use higher values for deeper chains.

    Related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions