Sub-Agent Architecture: From Tool Plugins to Runtime Capabilities

    This article argues that the central challenge of sub-agent systems is not whether a main agent can spawn sub-agents, but who controls the delegation boundary. It explains why sub-agents cannot be treated as ordinary tools, introduces a "capability seam" architecture with four layers (intent, policy, orchestration, execution), and details three layers of protection: explicit contracts, runtime-enforced depth/permission/budget limits, and persistent task identity and lifecycle. It also covers structured result handoff, a phased approach to retrofitting existing systems, and how to measure architectural value. Readers will learn how to turn delegation from model-interpreted text rules into a runtime protocol the system can validate, enforce, and trace.

    1. The Core Problem Is Not Whether Sub-Agents Can Start, but Who Controls the Delegation Boundary

    In intelligent coding, data analysis, and complex workflow automation, a main agent typically splits a task across multiple sub-agents. A single code refactor, for example, may be broken into dependency mapping, interface changes, test additions, and result review.

    This division reduces the cognitive load of any single task, but it introduces new governance problems: Can a sub-agent delegate further? How many layers deep can a task chain go? Which resources can a subtask access? Can an interrupted task resume?

    If these constraints live only in the prompt, the system hands execution boundaries over to the model’s own interpretation. A line in the prompt such as “do not create further subtasks” can influence the model’s decisions, but it cannot replace deterministic runtime control. Faced with complex context, conflicting instructions, or an incomplete task description, the model may still issue delegation requests that do not match expectations.

    What truly needs to be solved is not whether the model is obedient enough, but: even if the model issues an out-of-bounds request, can the system clearly identify and refuse to execute it.

    The design focus of sub-agent architecture should therefore shift from “providing an entry point to create subtasks” to “establishing a complete delegation control protocol.”

    2. Why Sub-Agents Cannot Be Understood as Ordinary Tools

    Ordinary tools usually have a relatively clear execution model: receive parameters, perform an operation, return a result. Even when execution takes a long time, its responsibility is typically concentrated on a single, well-defined action.

    Sub-agents are different. They usually have an independent context, a continuous reasoning process, and multiple tool calls, and they may need to wait for external input, pause and resume, create lower-level tasks, or accept cancellation requests.

    The difference can be summarized as follows:

    Design Dimension Ordinary Tool Call Sub-Agent Execution
    Execution Form Single operation or bounded flow Continuous task lifecycle
    State Management Mainly input and output Context, progress, and checkpoints
    Permission Control Validate the current operation Validate permission inheritance and subsequent actions
    Resource Consumption Usually around a single call May span multiple reasoning rounds and multi-level delegation
    Interruption Handling Return a failure or cancellation result Also handle lower-level tasks and recovery state
    Observability Call records Complete task tree and event chain

    This does not mean the tool interface cannot be used to start a sub-agent. The model side can still express delegation intent through something resembling a tool call. The key point is that the tool interface is only an interaction entry point and should not be the sole layer carrying sub-agent lifecycle management.

    If logic for permissions, budgets, recovery, and cancellation is all piled into the tool handler, the system becomes prone to duplicated implementations and inconsistent behavior as execution backends and task types grow.

    3. Establishing Stable Architectural Boundaries with “Capability Seams”

    A capability seam can be understood as a set of stable extension boundaries reserved by the runtime: the upper layer uses capabilities through a unified contract, while the lower layer can swap out concrete implementations without changing the overall task scheduling logic.

    In the sub-agent scenario, this design can be split into four layers:

    1. Intent layer: The model proposes the task goal, expected result, and delegation request.
    2. Policy layer: Determines whether the request complies with depth, permission, budget, and approval rules.
    3. Orchestration layer: Maintains task state, parent-child relationships, scheduling, cancellation, and result aggregation.
    4. Execution layer: Actually executes the subtask and reports progress and results.

    The basic flow can be expressed as:

    Main agent issues a delegation request
    → Runtime loads the parent task state
    → Validate capabilities and policy
    → Atomically record the subtask and reserve resources
    → Schedule execution
    → Continuously record events
    → Aggregate results and update the parent task

    The value of this layering is that the execution method can change, but governance rules do not drift along with the execution implementation. For example, a subtask can run in the current process, an isolated process, or a remote worker node, while the upper layer still manages it through a unified task state and result contract.

    Note that a “capability seam” is an architectural organizing approach; it does not mean the system automatically gains some fixed multiplier of scalability. Scalability improvements must be validated through actual integration cost, policy reuse rate, and failure recovery behavior.

    4. First Layer of Protection: Writing Delegation Rules as Explicit Contracts

    An explicit contract must first answer three questions: what the system supports, what the caller requests, and what the task is ultimately allowed to do.

    1. Capability Declaration

    An execution implementation should declare the capabilities it supports, for example:

    • Whether it supports pause and resume;
    • Whether it supports cancelling a running task;
    • Whether it supports isolated execution;
    • Whether it supports structured results;
    • Whether it allows new delegation requests during execution.

    These capabilities cannot be inferred from descriptive text alone. For features the system must rely on, verifiable structured information should be used.

    2. Request Description

    Beyond the task body, a delegation request should include the expected result, required permissions, resource limits, and recovery requirements.

    It is especially important to distinguish the “requested capability” from the “actually granted capability.” The model may request write access to a working directory, but whether the system authorizes it depends on the parent task’s permissions and the current policy; the permission must not be granted simply because it appears in the request.

    3. Effective Contract

    The final effective contract is usually determined jointly by execution capability, parent task authorization, and system policy:

    Executable scope = scope supported by the execution implementation ∩ scope allowed by the parent task ∩ scope allowed by the current policy.

    If a request contains a capability that must be satisfied but is currently unsupported, execution should be refused rather than silently downgraded. For example, if a task requires the ability to resume execution but the execution backend does not support reliable state recovery, the system should clearly return a capability mismatch.

    Type declarations help detect missing fields and structural errors, but they cannot alone prove that authorization is legitimate. Permission relationships, budget balances, and task state must still be validated at runtime.

    5. Second Layer of Protection: Handing Depth, Permissions, and Budget to the Runtime

    1. Delegation Depth Must Be Computed by the System

    Delegation depth should not be filled in by the model itself. The runtime must compute it from a trusted parent task record:

    Subtask depth = parent task depth + 1

    The depth definition of the root task should also be made explicit to avoid boundary discrepancies across modules. Requests that exceed the limit should be rejected before the task is created.

    Depth is only one dimension. Even if only one level of delegation is allowed, the main task may still create a large number of subtasks at once. It is therefore also necessary to limit the number of child nodes per task, the cumulative number of nodes in the entire task tree, and the number of concurrent executions.

    2. Permission Inheritance Can Only Shrink, Never Implicitly Expand

    A subtask’s permissions should in principle not exceed those of the parent task. A parent task authorized only to read code should not be able to create, through delegation, a subtask with permission to modify configuration or access other directories.

    Permission control should also be enforced as close to the resource access entry point as possible. Recording “read-only” only at task startup, while subsequent write tools do not check that permission, still fails to form effective isolation.

    For file writes, external network access, and high-risk operations, independent approval conditions can be set so that task permissions and per-operation authorization work together.

    3. Budget Must Cover the Entire Task Tree

    Limiting only the consumption of a single subtask cannot prevent multiple subtasks from jointly exhausting resources. A more reasonable approach is to set both a per-task budget and a root-task shared budget.

    When creating a subtask, resources can be reserved first; settlement happens continuously during execution; and unused portions are released after the task ends. Concurrent reservations must be atomic; otherwise multiple requests may read the same balance at the same time, leading to over-allocation.

    For resources that cannot be measured precisely in real time, a safety margin should be kept, and possible metering delays should be stated, so that “best-effort control” is not described as an absolute guarantee.

    6. Third Layer of Protection: Persisting Task Identity and Lifecycle

    If depth and permissions are kept only in process memory, boundary information may be lost after a system restart, task recovery, or cross-node scheduling. Sub-agents should have an independent and persistent task record.

    The record should cover at least:

    • The identity relationship among the root task, parent task, and current task;
    • Delegation depth and policy version;
    • Granted permissions and resource budget;
    • Current state, creation time, and last update time;
    • Recovery checkpoint or execution state reference;
    • Failure reason, cancellation reason, and result reference.

    The task lifecycle can adopt a clear set of states, such as pending scheduling, running, waiting for input, completed, failed, and cancelled. State changes must follow legal transition rules; a task in a terminal state must not re-enter the running state without a defined recovery flow.

    In addition, two easily overlooked problems must be handled.

    First, duplicate submission. Network retries may cause the same delegation request to be processed repeatedly. The system should use an idempotency identifier to detect duplicate requests and avoid creating duplicate tasks and reserving budget twice.

    Second, cancellation propagation. Whether all lower-level tasks are cancelled after a parent task is cancelled requires a clear policy. Issuing a cancellation request does not mean the task has already stopped; the runtime must also track cancellation acknowledgement, timeout handling, and resource reclamation.

    7. Result Handoff Is More Than Concatenating Text

    When a subtask completes, the main task needs not a long natural-language output but a result it can use to keep making decisions.

    The result contract can distinguish:

    • Execution status: completed, partially completed, or failed;
    • Deliverables: conclusions, a change summary, or artifact references;
    • Evidence scope: what was checked and what was not covered;
    • Risk notes: unresolved issues and their potential impact;
    • Follow-up suggestions: whether review, additional authorization, or human handling is needed.

    Structured results reduce the chance of the main task misjudging, but they cannot guarantee the content is necessarily correct. When code changes or important business actions are involved, results should still be verified with tests, rule checks, or human review.

    Context management should also follow the principle of least necessity: do not copy the parent task’s entire history to every subtask by default; instead, provide the goal, constraints, and relevant materials needed to complete the task; and on return, prioritize passing summaries and artifact references to avoid unbounded expansion of the main task’s context.

    8. How to Gradually Refactor an Existing System

    An existing system does not need to be rewritten all at once. It can be advanced by risk priority:

    Step 1: Unify the Delegation Entry Point

    Consolidate all paths that create subtasks, including model calls, automatic retries, and recovery flows. No path should bypass the policy check.

    Step 2: First Add Task Identity and Hard Limits

    Establish parent-child relationships, depth limits, concurrency limits, and permission inheritance rules. Prioritize problems that can directly cause resource loss of control or privilege escalation.

    Step 3: Extract Lifecycle Management

    Move task state, cancellation, idempotency, and result aggregation out of the tool handler into a unified orchestration layer, so that the execution implementation is responsible only for execution and feedback.

    Step 4: Introduce Capability Negotiation and Recovery Mechanisms

    Establish capability declarations for different execution implementations, explicitly refuse incompatible requests, and verify that identity, permissions, and budget boundaries are still honored after recovery.

    Step 5: Build an Observability and Verification System

    Logs should be able to string together the entire task tree and record the delegation initiator, policy decision, state changes, resource consumption, and cancellation result. When sensitive input is involved, log content and access permissions should also be controlled.

    Verification cannot rely only on the normal flow. Abnormal cases such as excessive delegation depth, concurrent budget contention, duplicate requests, unauthorized access, execution node interruption, and cancellation timeouts should also be tested.

    9. How to Measure the Architectural Value

    Making sub-agents a first-class runtime capability does not mean a more complex system is more advanced. Its value should be reflected in verifiable engineering metrics:

    • When adding a new execution implementation, can existing governance logic be reused;
    • Are all delegation paths subject to a unified policy;
    • Does the system still preserve task boundaries after recovery;
    • Can resources be released promptly after a task is cancelled;
    • Can the source of an anomalous delegation be accurately traced;
    • Can interface and policy changes be contained within well-defined modules.

    If these capabilities do not improve, merely renaming a “tool plugin” to a “foundational capability” brings no real scalability.

    Conclusion

    The key to sub-agent architecture is turning task delegation from text rules interpreted by the model into a runtime protocol the system can validate, enforce, and trace.

    The model is responsible for proposing goals and action suggestions, while the runtime is responsible for maintaining the boundaries of permissions, resources, and lifecycle. Through explicit contracts, centralized policy validation, and persistent task state, a system can support flexible division of labor while avoiding recursive delegation, permission expansion, and resource loss of control. Truly reliable scalability comes from stable separation of responsibilities and verifiable governance mechanisms, not from unmeasured multiplier promises.