[BUG] `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` override silently fails via both cloud config paths (Environment Variables panel and repo `settings.json`)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
In a Claude Code on the web cloud environment, CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH stays fixed at 1 no matter which of the two config surfaces a user actually has access to is used to raise it: the environment's own "Environment Variables" panel, or a repo's .claude/settings.json. This silently breaks any subagent designed to delegate to its own subagents (a "manager" agent whose tools: frontmatter includes Agent) — the Agent tool is simply absent from its toolset at runtime, with no error or warning anywhere.
This is related to but distinct from #46424 (closed as not planned) — that issue reports the base capability gap from a desktop CLI session and never mentions CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH. This report is narrower: the documented override variable for exactly this situation does not work through either config path available to a cloud session, even though the mechanism is otherwise sound (see below). Also related: #63541 (closed), which found a different silent-failure gap in the same Environment Variables panel (values not reaching the Setup script) — this may be a second instance of that panel's values not propagating reliably.
Environment
Claude Code version: 2.1.221
Surface: Claude Code on the web, cloud environment (CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE=cloud_default)
Environment configured with TWELVE_DATA_API_KEY and CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=2 as custom keys in its Environment Variables panel
What Should Happen?
Expected behavior
Either the environment-panel value or the settings.json value takes effect, and the dispatched subagent has Agent available (able to nest one layer deep, per depth=2).
Error Messages/Logs
settings.json`'s `env` block is documented to lose to a real shell/process environment variable — that precedence is expected and was separately confirmed here, and is not what's being reported.
Steps to Reproduce
In a Claude Code on the web environment's config, add CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=2 under Environment Variables (alongside at least one other custom key, e.g. an API key, to use as a control).
Also add "env": {"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "2"} to a repo's .claude/settings.json as a second attempt.
Start a fresh session in that environment against that repo.
Run env | grep CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH.
Dispatch a subagent whose tools: frontmatter includes Agent, and have it check whether Agent is actually present in its own available toolset (not just attempt a call — introspect the toolset directly).
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code version: 2.1.221
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
N/A — not a terminal session. Reproduced via Claude Code on the web (browser/cloud remote environment), no local shell or terminal emulator involved.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗