fix(agents): bound how many subagents one session runs at once
Port of upstream grok-build 1.0.1 (landed upstream 2026-08-06). The coordinator fire-and-forgot every spawn, so a wide fan-out (graph waves, swarm bursts, model-driven Task storms) could exhaust file descriptors. - kigi-tools task/admission: SubagentLimits — 32 concurrent per session by default (KIGI_MAX_CONCURRENT_SUBAGENTS), queue|fail behavior (KIGI_SUBAGENT_LIMIT_BEHAVIOR), zero clamped to 1, read once at the composition root; parse_positive_env helper. - Each parent session gets one spawn semaphore (map entries live for the process so a resumed session shares its predecessor's limit); handle_subagent_request holds an owned permit for the whole child run — queue awaits FIFO with a unified-log notice at saturation, fail routes through send_pre_spawn_failure. After a queued wait, a closed parent command channel (teardown) fails the spawn instead of running against a dead parent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KSy9S31pZNWXtRZNVJ1sDf
This commit is contained in:
1 parent
26d26e15c9
commit
bf93091416
9 files changed
+240
No files matched your search
@@ -33,6 +33,12 @@ pub(crate) fn ctx_with_toggle(toggle: HashMap<String, bool>) -> SubagentSpawnCon
|
||||
let (tx, _rx) = mpsc::unbounded_channel();
|
||||
SubagentSpawnContext {
|
||||
lsp: None,
|
||||
spawn_limits:
|
||||
kigi_tools::implementations::kigi::task::admission::SubagentLimits::default(),
|
||||
spawn_permits: std::sync::Arc::new(tokio::sync::Semaphore::new(
|
||||
kigi_tools::implementations::kigi::task::admission::SubagentLimits::default()
|
||||
.effective_max_concurrent(),
|
||||
)),
|
||||
parent_max_turns: None,
|
||||
gateway: test_gateway(),
|
||||
client_hooks: Default::default(),
|
||||
|
||||
Reference in new issue
Block a user