Enhancement: Configurable Maximum Agent Recursion Depth

Resolved 💬 1 comment Opened Jan 26, 2026 by iamthegone Closed Mar 2, 2026

Currently, agent recursion depth is hard-coded to a limit of 1 (primary agent can spawn sub-agents, but sub-agents cannot spawn further). This proposal suggests exposing this limit as a configurable setting in config.toml (e.g., agents.max_depth).

Motivation
Advanced orchestration workflows and hierarchical agent structures often require nesting deeper
than a single level. Hard-coding this limit restricts the tool's flexibility for power users
who are already building complex multi-agent systems.

By making this configurable:

  1. Flexibility: Advanced users can opt-in to deeper recursion (e.g., depth 4) to support

complex task decomposition.

  1. Safety: The default can remain at 1 to prevent runaway costs or loops for standard users.
  2. Consistency: It aligns with other "knobs" in Codex that allow users to tune the engine to

their specific environment.

Proposed Implementation

  • Add a max_depth field to the [agents] section of the configuration.
  • Update the recursion guard in the Rust core to check against this configured value instead

of a static constant.

  • Ensure the setting is propagated through the tool invocation context.

I have already implemented a working prototype of this change and am happy to submit a PR for
review.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗