Governing Runaway Nested Spawning in Multi-Agent Systems
This article explains why multi-agent coding tools sometimes spiral into runaway nested spawning, where a main agent keeps creating deeper layers of sub-agents until the context is exhausted and the actual task stalls. It breaks the problem into two root causes: hidden spawning parameters that prevent the main agent from explicitly selecting agent types or model tiers, and recursive spawning that lacks an effective depth limit. For each issue, it presents practical configuration changes, fallback strategies, and the trade-offs involved, then offers three criteria for choosing between the newer and previous scheduling mechanisms and four metrics for verifying that the governance is actually working.
1. Symptom: Why Sub-Agents Spiral Out of Control
When using an AI coding tool with multi-agent collaboration, a common failure mode is that the task is flooded with sub-agents almost immediately. The main agent keeps spawning the next layer, nesting grows deeper and deeper, identical calls appear in long chains in the logs, and the context is consumed rapidly—while the change you actually wanted never moves forward.
This is rarely caused by a single misconfigured switch. It is usually the result of two things going wrong at once: how capabilities are exposed and how strongly recursion is constrained. The problem can be split into two categories, each with a practical fix.
2. Issue One: Hidden Spawn Parameters Prevent Targeted Selection
2.1 Root Cause
Newer multi-agent scheduling versions remove spawning metadata from the tool input structure by default. The removed fields typically include agent type, target model, reasoning effort, and service tier. The intent is to simplify the call surface and reduce misuse, but the side effect is direct: the main agent cannot “see” these dimensions when constructing a call, so it falls back to defaults.
This produces two concrete symptoms. First, named agents defined in the user-level agent directory cannot be explicitly selected, making the role separation defined in the configuration effectively useless. Second, even when the outer run uses a high-capability tier, spawned sub-agents do not inherit that tier and instead fall back to a general default model. The result is “weaker at every level down,” and quality on long chains of tasks drops sharply.
2.2 How to Fix It
The core principle is to make capabilities explicitly visible while limiting how much context is passed along. An illustrative configuration looks like this (key names are expressed in general terms and may vary slightly by version):
[features.multi_agent_v2]hide_spawn_agent_metadata = falsetool_namespace = "agents"
At the same time, document the context policy for spawning in the project-level instruction file (the conventionally used file that constrains agent behavior): do not set the fork scope to the entire history; choose only between “no context passed” and “only the most recent few turns.” The reason is that once a sub-agent inherits the full conversation, it not only inflates token cost but also tends to treat unrelated discussion from the main thread as a task premise.
If the current version still cannot reliably target agents, a fallback is to revert to the previous-generation scheduling mechanism and explicitly maintain a model catalog file so the set of selectable models stays controlled:
model_catalog_json = "~/.config/agent/models-v1.json"[features.multi_agent_v2]enabled = false
3. Issue Two: Recursive Spawning Has No Boundary
3.1 Root Cause
The first cause is on the model side: some models tend to keep spawning even when they are already in a sub-agent position, which is a behavioral preference introduced by training objectives. The second cause is on the framework side: the recursion depth limit does not actually take effect in the newer mechanism, and with no hard interception, that behavioral preference turns into unlimited expansion.
Notably, once Issue One is fixed, the recursion problem often eases significantly. When the model can see the agent type and reasoning tier, it is more inclined to “finish the work itself” rather than “spawn another one.” This shows the two issues are coupled: fix visibility first, then assess whether depth still needs to be limited.
3.2 Fix and Its Cost
If prompt-level constraints do not work, the most reliable approach is to revert to the previous-generation mechanism and replace elastic recursion with fixed levels. The cost is losing several collaboration capabilities: appending messages to an existing sub-agent, dispatching follow-up tasks to an existing sub-agent, interrupting a running sub-agent, and enumerating currently active agents. These capabilities were never written into the global prompt in the newer mechanism, so the model rarely uses them proactively. If they are genuinely needed, explicitly document when to call them and what the parameters mean in the project-level instruction file; otherwise it amounts to “having an interface that no one uses.”
4. Trade-Offs and Acceptance
To choose between the newer and the previous generation, use three criteria: whether you need multi-turn follow-up collaboration with existing sub-agents; whether you can accept the expressiveness loss from fixed levels; and whether the team is willing to maintain the model catalog and behavior constraint files. If all three are no, prefer the simpler, more controllable option.
For acceptance, look at four metrics: the total number of sub-agents spawned per task, the maximum nesting depth, whether the models used by sub-agents match expectations, and whether the context consumption curve stays flat. Only when all four converge can you conclude that governance is truly effective, rather than being temporarily suppressed by prompts.
