Description
Zeph's zeph-subagent crate has two existing runaway-spawn guardrails: max_spawn_depth (recursion-depth guard, SubAgentError::MaxDepthExceeded, crates/zeph-subagent/src/manager/spawn.rs:617-620) and max_concurrent (in-flight concurrency guard, SubAgentError::ConcurrencyLimit, crates/zeph-subagent/src/manager/spawn.rs:641-644/:1157-1160). Neither bounds the cumulative total number of subagents spawned over a session's lifetime — a session could sequentially spawn an unbounded number of subagents (shallow depth, low concurrency, high total count) with no default protection, e.g. a misbehaving orchestration loop spawning-and-completing subagents in a tight sequential cycle.
This is the subagent-spawning analog of #6469 ("core: no default-on runaway tool-call / cost protection"), which found Zeph's tool-call rate limiter and daily cost budget both shipped disabled/unlimited by default, corroborated by Claude Code's session-wide CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION cap. #6469 was fixed by PR #6528 (rate limiting + cost cap now enabled by default).
This cycle found a second, structurally distinct guardrail from the same Claude Code release wave (v2.1.207-212, week of 2026-07-13): CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION (default 200, session-wide absolute cap on total subagent spawns, "to stop runaway delegation loops"). Zeph has no equivalent cumulative counter or config field.
Reproduction Steps
rg -n "max_spawn_depth|max_concurrent|ConcurrencyLimit|MaxDepthExceeded" crates/zeph-subagent/src — only depth and concurrency guards exist.
- Inspect
SubAgentConfig (crates/zeph-config/src/agent.rs) — no max_spawns_per_session-style field.
- Observe: a session that spawns, awaits completion, then spawns again in a loop is unbounded by either existing guard.
Expected Behavior
A session should have a configurable, default-on cap on the cumulative number of subagents spawned over its lifetime, independent of depth and concurrency, to stop runaway sequential delegation loops.
Actual Behavior
No cumulative session-wide spawn cap exists; only depth and concurrency are bounded.
Environment
- Version: HEAD c63e321
- Config: default
SubAgentConfig
- Features: n/a (config-level)
Evidence / Competitive Corroboration
Spec
.local/specs/077-subagent-session-spawn-cap/spec.md
Description
Zeph's
zeph-subagentcrate has two existing runaway-spawn guardrails:max_spawn_depth(recursion-depth guard,SubAgentError::MaxDepthExceeded,crates/zeph-subagent/src/manager/spawn.rs:617-620) andmax_concurrent(in-flight concurrency guard,SubAgentError::ConcurrencyLimit,crates/zeph-subagent/src/manager/spawn.rs:641-644/:1157-1160). Neither bounds the cumulative total number of subagents spawned over a session's lifetime — a session could sequentially spawn an unbounded number of subagents (shallow depth, low concurrency, high total count) with no default protection, e.g. a misbehaving orchestration loop spawning-and-completing subagents in a tight sequential cycle.This is the subagent-spawning analog of #6469 ("core: no default-on runaway tool-call / cost protection"), which found Zeph's tool-call rate limiter and daily cost budget both shipped disabled/unlimited by default, corroborated by Claude Code's session-wide
CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSIONcap. #6469 was fixed by PR #6528 (rate limiting + cost cap now enabled by default).This cycle found a second, structurally distinct guardrail from the same Claude Code release wave (v2.1.207-212, week of 2026-07-13):
CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION(default 200, session-wide absolute cap on total subagent spawns, "to stop runaway delegation loops"). Zeph has no equivalent cumulative counter or config field.Reproduction Steps
rg -n "max_spawn_depth|max_concurrent|ConcurrencyLimit|MaxDepthExceeded" crates/zeph-subagent/src— only depth and concurrency guards exist.SubAgentConfig(crates/zeph-config/src/agent.rs) — nomax_spawns_per_session-style field.Expected Behavior
A session should have a configurable, default-on cap on the cumulative number of subagents spawned over its lifetime, independent of depth and concurrency, to stop runaway sequential delegation loops.
Actual Behavior
No cumulative session-wide spawn cap exists; only depth and concurrency are bounded.
Environment
SubAgentConfigEvidence / Competitive Corroboration
CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION, default 200, on by default, "to stop runaway delegation loops." Single reference project so far (P3 per parity severity rules; corroborating 2nd project not yet found).Spec
.local/specs/077-subagent-session-spawn-cap/spec.md