From a30440f55d4bb3269667a1505475ccc2b00045a8 Mon Sep 17 00:00:00 2001 From: Julian lechner Date: Thu, 1 Oct 2026 11:01:45 +0200 Subject: [PATCH] feat(claude): limit concurrent subagents and spawn depth Set CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS=5 and CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 so Claude matches the Codex agent limits and subagents cannot start further subagents. Co-Authored-By: Claude Opus 5.5 --- adapters/claude/config/settings.json | 4 +++- scripts/tests/test-shell-packages.ps1 | 2 ++ scripts/tests/test-shell-packages.sh | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/adapters/claude/config/settings.json b/adapters/claude/config/settings.json index a177fcb..c209483 100644 --- a/adapters/claude/config/settings.json +++ b/adapters/claude/config/settings.json @@ -6,7 +6,9 @@ }, "sandbox": __CLAUDE_SANDBOX__, "env": { - "CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY": "__CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY__" + "CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY": "__CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY__", + "CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS": "5", + "CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "1" }, "statusLine": { "type": "command", diff --git a/scripts/tests/test-shell-packages.ps1 b/scripts/tests/test-shell-packages.ps1 index ce39969..a28f0eb 100644 --- a/scripts/tests/test-shell-packages.ps1 +++ b/scripts/tests/test-shell-packages.ps1 @@ -62,6 +62,8 @@ foreach ($shell in @('powershell','bash')) { throw "Claude finish hook is incorrect in $package" } elseif ($content -notmatch '"defaultMode"\s*:\s*"auto"') { throw "Claude auto permission mode is missing in $package" + } elseif ($settings.env.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS -ne '5' -or $settings.env.CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH -ne '1') { + throw "Claude subagent limits are missing in $package" } elseif ($sandboxSupported -and ($settings.sandbox.enabled -ne $true -or $settings.sandbox.allowUnsandboxedCommands -ne $false -or $settings.sandbox.failIfUnavailable -ne $true -or (@($settings.sandbox.network.allowedDomains) -join ',') -ne 'mcp.context7.com' -or @($settings.sandbox.PSObject.Properties).Count -ne 4)) { throw "Claude strict sandbox is missing in $package" } elseif (-not $sandboxSupported -and ($settings.sandbox.enabled -ne $false -or @($settings.sandbox.PSObject.Properties).Count -ne 1)) { diff --git a/scripts/tests/test-shell-packages.sh b/scripts/tests/test-shell-packages.sh index 42f4ccb..a926a53 100644 --- a/scripts/tests/test-shell-packages.sh +++ b/scripts/tests/test-shell-packages.sh @@ -80,6 +80,8 @@ for shell in powershell bash; do ! grep -q 'flashbang-if-input' "$package/$file" ! grep -q '"async"[[:space:]]*:[[:space:]]*true' "$package/$file" grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file" + grep -q '"CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS"[[:space:]]*:[[:space:]]*"5"' "$package/$file" + grep -q '"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH"[[:space:]]*:[[:space:]]*"1"' "$package/$file" python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); expected={"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True, "network": {"allowedDomains": ["mcp.context7.com"]}} if sys.argv[2] == "true" else {"enabled": False}; assert settings["sandbox"] == expected' "$package/$file" "$sandbox_supported" statusline_extension='sh' [ "$shell" != powershell ] || statusline_extension=ps1