A Deep Dive into Two Implementation Paths for Sub-Agents in Multi-Agent Systems

    This article examines the two dominant technical approaches for implementing sub-agents in multi-agent systems: the full-instance derivation path, where a sub-agent is an independent, addressable agent runtime, and the in-loop invocation path, where a sub-agent is a special tool call executed within the parent agent's reasoning loop. It compares their architectural models, dispatch workflows, context handling, communication semantics, observability, concurrency costs, and engineering complexity, and provides selection guidance and best practices for building scalable, observable, and fault-tolerant multi-agent systems.

    Two Implementation Paths for Sub-Agents in Multi-Agent Systems

    When building complex agent systems, one core question is unavoidable: how does one agent delegate a task to another agent? Popular AI coding tools and agent frameworks have converged on two distinct technical routes. The first is full-instance derivation—each sub-agent is a complete, independently running agent instance. The second is in-loop invocation—a sub-agent is essentially a specially wrapped model call inside the parent agent’s reasoning loop. Understanding the differences between these two paths is critical for designing stable, observable, and scalable multi-agent systems.

    1. Overall Mental Models of the Two Paths

    1.1 Full-Instance Derivation: Sub-Agent as an Independent Runtime

    In this path, the main agent and sub-agents are structurally homogeneous—they are all “threads.” Each thread is backed by a session that serves as the runtime container, managing the agent’s context, input processing, tool calls, model requests, event emission, and state.

    Agents are not isolated islands; they are managed by a unified control plane. This control plane maintains an “agent tree”: each agent can spawn its own sub-agents, creating a hierarchy. The control plane provides primitive operations such as spawn, send, wait, and close. The core modules can be summarized as:

    Module Responsibility
    Session Runtime container for a single agent thread; holds context and state
    Thread Wrapper Exposed thread handle holding an agent instance
    Thread Manager Creates, resumes, looks up, and manages thread lifecycle
    Control Plane Scheduler for multi-agent coordination: spawning, communication, state query, and shutdown
    Registry In-memory agent tree structure and metadata management
    Persistence History Disk-backed records of threads/sessions for failure recovery and branch forking

    The essence of this design is to elevate “multi-agent collaboration” to a first-class, framework-level capability, rather than an ad-hoc application-layer assembly.

    1.2 In-Loop Invocation: Sub-Agent as a Tool Execution

    The second route is considerably lighter. A sub-agent is not an independent entity—it is a special tool inside the parent agent’s toolset. When the model decides to “call a sub-agent,” the framework does the following: it starts an isolated sub-reasoning loop using the sub-agent’s system prompt and task description as input. When that loop finishes, the final result is returned to the parent agent’s main loop as a tool result.

    In this path, the sub-agent has no persistent thread, no addressable handle, and no independent asynchronous event stream. Its “lifecycle” starts with the tool call and ends with the return value—fully nested inside one execution of the parent agent. The parent receives only a text result, not an object with which it can continue a conversation.

    2. Differences in Dispatch Workflows

    2.1 Typical Workflow for Full-Instance Derivation

    A typical sub-agent spawning operation follows this call chain:

    1. Model emits a spawn instruction
    2. -> Tool handler parses parameters (task description, config, context inheritance policy)
    3. -> Constructs sub-agent configuration and spawn origin identifier
    4. -> Control plane receives the spawn request and registers metadata
    5. -> Thread manager creates a new thread + session (or forks from parent context)
    6. -> Decides whether to inherit parent context based on persistence history
    7. -> Sends the task to the sub-agent via the inter-agent communication channel
    8. -> Sub-agent starts running as an independent event stream

    Two key design points deserve emphasis:

    • Spawn vs. fork: Spawning creates a clean session from scratch, carrying only the task description. Forking takes a “snapshot copy” of the parent thread’s persistence history, allowing the sub-agent to see prior conversations and tool calls. The former offers stronger isolation and lower context window consumption; the latter provides full information, suitable for subtasks requiring deep context. Frameworks typically expose this choice via parameters, letting the model or developer decide explicitly.

    • Asynchronous event streams: Once created, a sub-agent has its own event output stream. The parent can choose to block and wait, or continue other work and later query the sub-agent’s status or collect results. This makes “spawning multiple sub-agents in parallel to explore different approaches” a natural programming pattern.

    • Addressability and intervention: Because sub-agents are first-class entities in the registry, the parent (or an upper-level system) can send additional messages, correct direction, or force shutdown after a timeout—rather than being limited to waiting for a single call’s return.

    2.2 Typical Workflow for In-Loop Invocation

    In contrast, the in-loop invocation workflow is flat:

    1. Model emits a "call subtask tool" instruction
    2. -> Framework reads the sub-agent definition (prompt template + allowed tool subset)
    3. -> Starts an isolated sub-reasoning loop (separate message list, does not pollute main context)
    4. -> Executes model requests and tool calls inside the sub-loop until a result is produced
    5. -> Serializes the result as a string and returns it as a tool result into the main loop

    The advantages of this implementation are obvious: no control plane, no registry, no cross-instance communication protocol—it is simply a recursive call executor. State management is minimal—the sub-agent is destroyed after the call ends; there are no leaking sessions or dangling threads.

    3. Systematic Comparison Across Key Dimensions

    3.1 Context and State

    • Full-instance path: Context inheritance is optional. Through persistence history, forking lets the sub-agent carry part or all of the parent’s context, and state accumulates during execution in its own session.
    • In-loop invocation path: Context is manually passed. The parent must write necessary information into the task description in the call parameters. The sub-agent’s intermediate state is discarded after return; only the final result is preserved.

    3.2 Communication Patterns

    • Full-instance path: Supports bidirectional, multi-turn, asynchronous messaging. The parent can intervene mid-execution.
    • In-loop invocation path: Single request-response semantics. Once called, there is no way to interact until the result returns. If a sub-agent needs to ask the parent for clarification during execution, the full-instance path supports it naturally; the in-loop path requires additional interrupt-resume mechanisms, which are awkward to implement.

    3.3 Observability and Fault Tolerance

    • Full-instance path: Each agent has its own event stream and state machine, enabling independent logging, trace linking, and failure retries. A sub-agent crash does not directly interrupt the parent; the control plane can mark the failure and let the parent choose to re-dispatch or degrade.
    • In-loop invocation path: A sub-agent failure typically appears as a single tool-call error. Observability granularity is limited to “did this call succeed or fail”; internal reasoning traces are usually only available in temporary logs.

    3.4 Concurrency and Resource Overhead

    • Full-instance path: Naturally supports parallel execution of multiple sub-agents, but each instance maintains its own session state and context window, increasing memory and model-call costs. Lifecycle management (concurrent shutdown, timeout reclamation) is needed.
    • In-loop invocation path: Light on resources, but parallelism depends on whether the executor supports concurrent tool calls. Parallel subtasks cannot directly collaborate with each other.

    3.5 Engineering Complexity

    • Full-instance path: Complexity concentrates in the framework layer—control plane, registry, persistence, communication protocols all need careful design.
    • In-loop invocation path: Complexity is pushed to the application layer—developers must design prompt templates, plan information passing, and accept limited expressiveness.

    In one sentence: the full-instance path is “heavy framework, light usage”; the in-loop path is “light framework, heavy usage.”

    4. Selection Guidance and Best Practices

    In real-world engineering, the two paths are not mutually exclusive. Mature multi-agent systems often mix them:

    1. Task granularity: Short, quick, one-off information-processing tasks (e.g., “summarize this file”, “check the style of this code”) are suitable for in-loop invocation, avoiding the overhead of a full instance for a few seconds of work. Long-running, multi-turn, or direction-changing tasks (e.g., “independently complete a module’s development and self-testing”) should use full-instance derivation.
    2. Context isolation first: Regardless of path, avoid blindly dumping the parent’s full history into the sub-agent. The more focused the sub-agent’s context, the better the output quality and the lower the cost. Forking should be an option, not a default.
    3. Lifecycle safeguards: When using the full-instance path, set maximum runtime, maximum turns, and forced reclamation mechanisms for sub-agents to prevent runaway derivation trees from exhausting resources. Also ensure persistence history integrity for post-failure recovery.
    4. Unified observability: Assign traceable identifiers to each agent instance and include derivation relationships in distributed tracing topology. This is invaluable when debugging “strange behavior” in multi-agent systems.
    5. Incremental evolution: If your system currently uses in-loop invocation, watch for signals such as “subtasks need clarification,” “need parallel exploration,” or “need checkpoint and resume.” When these appear, it is time to introduce a control plane and independent sessions.

    5. Conclusion

    The two implementation paths for sub-agents reflect two worldviews: treating an agent as a persistent, addressable computational entity versus treating it as a one-shot functional call. The former uses a heavier framework to gain comprehensive capabilities in communication, concurrency, fault tolerance, and observability—ideal for enterprise-grade multi-agent collaboration systems. The latter, with minimal implementation, covers most delegation scenarios and is a reasonable choice for rapid prototyping and lightweight applications. Understanding their dispatch workflows, state models, and communication semantics is essential for making architecture decisions that match business scale. For teams aiming to build such systems on the cloud, the article’s concepts can be operationalized by running agent runtimes on container platforms, using message queues for asynchronous inter-agent communication, object storage for session persistence, and log services plus monitoring alerts for end-to-end observability—resulting in a stable, reliable multi-agent infrastructure.