Problem
Specialist / Task tool nesting has no hard upper bound.
// internal/specialist/exec.go
if options.CurrentDepth < 0 { ... }
// then always:
args = append(..., "--depth", strconv.Itoa(input.CurrentDepth+1), ...)
Only a negative check. Depth is just metadata passed down to child zero processes.
Impact
- A specialist (or the model) can recursively spawn more specialists indefinitely.
- Leads to process explosion, high CPU/memory, stack overflow, or runaway costs.
- No protection against accidental or adversarial deep recursion.
Suggested fix
- Add a hard
MaxDepth (e.g. 5-8) in TaskRunOptions / Executor.Run / swarm launcher.
- Return clear error when exceeded.
- Document and expose via CLI flag if needed.
- Consider a global per-run limit in the main agent loop.
Problem
Specialist / Task tool nesting has no hard upper bound.
Only a negative check. Depth is just metadata passed down to child
zeroprocesses.Impact
Suggested fix
MaxDepth(e.g. 5-8) inTaskRunOptions/Executor.Run/ swarm launcher.