Governance for Uncontrolled Subagents in Multi-Agent Coding

    Learn how to govern subagents in multi-agent coding workflows by making model and role selection explicit, enforcing nesting and budget limits at runtime, controlling context sharing, and monitoring orchestration behavior. The article also provides a practical troubleshooting sequence for model-routing and runaway-nesting problems.

    Multi-agent coding divides a complex change into parallel subtasks. A primary agent plans the work, while subagents handle research, code changes, verification, or summaries. This approach can be effective in large codebases when tasks are independent, but it can also lead to two problems: the primary agent cannot choose the right model or role for each task, and subagents create more subagents, producing deep, difficult-to-stop call chains.

    The solution is not to eliminate parallelism. It is to make decisions about who does the work, what capabilities they use, how much context they receive, and how deeply they may delegate explicit and auditable.

    1. Distinguish orchestration failures from model behavior

    Uncontrolled subagent behavior is often blamed on a model being “too eager.” In practice, it usually results from two factors.

    The first is the orchestration contract. The primary agent can use only the fields exposed by the subagent-creation tool. If the tool schema includes a task description but omits routing information such as role, model, reasoning level, or service tier, the primary agent cannot express a choice—even if it understands the cost and capability trade-offs. Tasks then fall back to the default model, often the same high-end model used by the primary agent. Prompt changes will do little if the tool provides no valid parameter for the model to set.

    The second factor is model behavior. Some models trained for complex coding tasks treat delegation as a default way to break down work. They may continue spawning agents even when they are already subagents. If the orchestration layer does not actually enforce a maximum depth, prompt instructions remain suggestions that can be overridden during long tasks.

    Use a consistent troubleshooting order: first check whether the subagent-creation tool exposes routing fields; then verify that the runtime enforces limits on depth, concurrency, and context passing; only then adjust prompts. Reversing this order can lead to a configuration defect being misdiagnosed as a writing problem.

    2. Restore model and role choice

    Make routing fields visible

    The subagent-creation interface should let the primary agent specify at least four things: the task objective, the desired role or skill boundary, the model or capability tier, and whether to inherit conversation history.

    Some systems hide these fields to keep metadata from distracting the primary agent or appearing in user-facing output. Those goals are reasonable, but the control plane should not be confused with the presentation layer. Keep internal identifiers out of user-visible responses while retaining the necessary control fields in the primary agent’s tool schema.

    If the orchestration configuration hides derived metadata by default, explicitly disable that behavior or provide a separate management policy that makes roles and models available as tool parameters. Then run a small test: assign a low-cost tier to a retrieval-only task and a higher-capability tier to a cross-module refactor. Check the model identifiers in runtime logs to confirm that each assignment was honored. The primary agent’s statement that it followed the instructions is not sufficient evidence.

    Use a controlled model catalog

    Even when model fields are visible, the primary agent may supply an unsupported name. Maintain a controlled catalog containing only approved tiers, their context limits, whether they support tool use, and the task types they suit. Validate selections during subagent creation. Reject invalid values with a clear error instead of silently falling back to a high-end default. Silent fallback is particularly risky because it makes an unfulfilled selection look successful.

    The catalog does not need to reproduce every model parameter. Keep only what is needed for routing decisions: tier name, relative cost, maximum context, suitability for long-running reasoning, and whether the model may create subagents. That final property is especially useful: retrieval and formatting roles can be barred from further delegation, preventing nesting at its source.

    Define roles instead of improvising prompts

    Turn common responsibilities into named roles, such as read-only research, scoped code changes, test verification, and result summarization. Bind each role to a default model, an approved tool set, and a delegation policy. The primary agent should select a role first and override its model only when necessary. This reduces one-off agent definitions and makes it possible to audit cost and failure rates by role.

    3. Control nesting and context transfer

    Enforce depth limits in the runtime

    Maximum nesting depth should be a hard orchestration limit, not an instruction in a prompt. A reasonable default is a depth of one: the primary agent may create subagents, but subagents may not create more. If a task genuinely requires divide-and-conquer work, allow depth two selectively and restrict the second level to read-only work or a single verification task.

    Calls that exceed the limit should fail with an explanation. This gives the primary agent a reason to switch to sequential steps or narrow the task, rather than retrying indefinitely.

    Limit breadth as well. Set caps on the number of concurrent subagents per parent task, total token budget, and wall-clock time. A depth limit alone will not prevent a single parent from spawning a large number of redundant agents.

    Isolate context by default

    Giving a subagent the entire conversation may seem useful, but it can also pass along irrelevant discussion, failed attempts, and raw tool output. This increases cost and can encourage the subagent to repeat the parent’s decomposition process.

    A safer default is to pass no conversation history. Provide only the task description, relevant file paths, acceptance criteria, and necessary constraints. If the task depends on recent decisions, pass only a limited number of recent turns and summarize them first, removing raw tool output and failure traces.

    Define explicit context modes, such as no history, a fixed number of recent turns, or summarized task memory. Do not use full-history transfer as the default. If full transfer is necessary, limit it to specific use cases and record the reason.

    Use task contracts instead of open-ended delegation

    Specify each subtask’s inputs, allowed scope, prohibitions, definition of completion, and response format. Prohibitions should state directly that the subagent must not create more subagents, expand the file scope, or change the task objective.

    Keep the response format short and structured—for example: conclusion, changes made, verification results, and unresolved issues. The primary agent can then summarize these results without passing lengthy reasoning to another layer.

    4. Choose the right orchestration model

    Multi-agent systems commonly use one of two orchestration patterns. Lightweight dispatch creates a subagent, waits for it, and collects its result. Session-based dispatch can also send follow-up messages to an existing subagent, assign additional work, interrupt a running agent, and list active agents. The latter is more flexible and can suit long-running collaboration; the former has a simpler lifecycle and is appropriate for most code changes.

    If the workflow is simply “dispatch once, collect the result,” session-based interfaces may add state and opportunities for misuse without providing much value. More importantly, advanced controls will not be used reliably if they are absent from the instructions visible to the primary agent. In that case, the added complexity does not translate into capability. Prefer lightweight orchestration and enforce depth and context policies there.

    Enable session-based capabilities only when all of the following conditions are met:

    • The team needs to add constraints or interrupt a subagent that is going off track.
    • Instructions for these operations are visible to both primary agents and subagents.
    • The runtime can report agent lists and statuses.
    • Failures, timeouts, and interruptions have clearly defined recovery procedures.

    Otherwise, advanced interfaces may remain unused while the nesting problem persists.

    5. Put policies in persistent instructions and keep validating them

    Instructions given only in a single conversation can be diluted by later tasks. Store stable rules in project-level agent guidance and keep them short and actionable:

    • Do not create subagents by default. Delegate only when tasks can run in parallel, have clear boundaries, and do not depend on one another.
    • Subagents must not create further subagents by default.
    • Specify a role when creating a subagent. Select models only from the approved catalog. If no model is specified, use the role’s default tier; never silently upgrade.
    • Disable context transfer by default. When recent context is necessary, state the maximum number of turns to pass.
    • If a subagent times out, repeatedly edits the same scope, or fails to provide an acceptable result twice, the primary agent should stop it and complete the work itself or narrow the task.

    Documentation is not the only control point. The runtime must still enforce depth limits, catalog validation, and budgets. Prompts reduce unnecessary attempts; runtime controls prevent violations. Without both, a policy may forbid an action in writing while still allowing the call to succeed.

    After rollout, track at least four metrics: the number of subagents created, average and maximum nesting depth, model-tier distribution, and the number of policy-based rejections. A persistently high rejection count may indicate that the primary agent cannot see the required fields or that instructions conflict with the tool schema. Depth frequently reaching its limit may indicate overly fine task decomposition or an ineffective runtime limit. A low share of lower-cost tiers may mean role defaults or fallback behavior still favor high-end models.

    6. A reusable troubleshooting sequence

    When all subagents appear to use the same high-end model, work through these steps in order rather than changing many variables at once:

    1. Inspect the subagent-creation tool schema and confirm that role, model, and reasoning-tier fields are visible to the primary agent.
    2. Run a comparison using two clearly different tiers. Verify the actual model in runtime logs.
    3. Restrict model selection to a controlled catalog. Reject invalid values instead of falling back silently.
    4. Set the maximum depth to one and enforce it in the runtime. Check whether nesting stops.
    5. Disable context transfer by default, allowing a limited number of recent turns only for tasks that depend on recent decisions.
    6. If follow-up messages, additional tasks, interruptions, and agent-list queries are not needed, switch to lightweight orchestration.
    7. Add these rules to project-level instructions and monitor depth, tier distribution, and rejection reasons.

    The first four steps resolve many cases of uncontrolled delegation. If nesting continues, first suspect that the depth limit is not being enforced by the current orchestration version rather than adding still longer prompts.

    7. Conclusion

    Subagents are valuable for parallel work and specialized responsibilities—not for giving every agent the same high-end capability or allowing agents to reproduce themselves without limits. Restore routing fields for the primary agent, constrain choices through catalogs and roles, isolate context by default, enforce nesting limits in the runtime, and use persistent instructions to reduce unnecessary delegation. These measures turn an uncontrolled call tree into an auditable layer of collaboration.

    Lightweight orchestration is clearer for most coding tasks. Session-based capabilities are worth enabling only when they are genuinely needed and visible to the models that must use them. Ultimately, governance is measured by runtime records, not by whether a model says it will comply.