Multi-Agent Architecture Design: From Session Fragmentation to Task Orchestration

    As AI programming assistants become engineering-ready, managing context across multiple agents presents a significant challenge. This article examines the limitations of both single-session and multi-session approaches from a general architectural perspective. It introduces a two-layer architecture that separates interaction from execution, leverages thread subscriptions for efficient message routing, and discusses the complexities of cross-session long-term memory in multi-agent systems.

    As AI programming assistants become increasingly engineering-ready, a critical question emerges: when an Agent transitions from an “assistant” within a single session to a “team” across multiple sessions, how should context be managed? The industry has explored various practices, with some vendors introducing multi-agent teaming mechanisms in coding tools and teams discussing progress on cross-session long-term memory. Stripping away specific products, this article analyzes the problem from a general architectural perspective: why a single session is insufficient, the costs of multiple sessions, and a valuable two-layer design.

    1. Architectural Implications Behind the Naming: Sub vs. Super

    In English typography, superscript refers to above, and subscript refers to below. Applied to the Agent ecosystem, these terms perfectly describe two different organizational approaches:

    • Sub-agent: An additional layer attached beneath the main Agent. The main Agent delegates subtasks to the lower layer and is responsible for aggregation. This is a relatively common hierarchical model today.
    • Super-agent: An additional layer added above the Agents doing the actual work. This new layer does not execute tasks directly but is responsible for receiving messages, assigning work, and coordinating multiple executors.

    This naming difference is not merely a play on words; it reveals two architectural philosophies: the former is “one brain commanding multiple hands,” while the latter is “one dispatch console managing multiple independent workstations.”

    2. The Starting Point of the Problem: A Cross-Channel Decision Change

    Consider a typical development scenario. A developer tells an Agent in an instant messaging group: “Change this code according to Plan A.” The Agent starts working and subsequently submits a Pull Request (PR). A moment later, the developer adds a comment in the PR: “Let’s just use Plan B.”

    A human can understand at a glance that this statement overturns the previous decision. For the system, however, this requires two steps: first, linking the previous requirement in the group chat to this current PR, and second, conveying the new plan to the session that is actively modifying the code.

    Existing approaches have trade-offs:

    1. Everything in a single session: The Agent can see the complete context of the decision-making process, but when multiple tasks run in parallel, code logs, user instructions, and execution results are all crammed together. Tasks must queue for sequential processing, limiting efficiency.
    2. A separate session for each task: Tasks can proceed in parallel, but if two tasks involve the same decision, or if a user adds a comment via another channel, someone must accurately deliver the message to the corresponding session. Most of the time, this “someone” is the developer juggling multiple windows simultaneously.

    This is the core trade-off in multi-agent systems: the more sessions are split, the higher the parallelism, but the harder it is to connect the original context.

    3. Two-Layer Architecture: Separating Interaction from Execution

    To address this contradiction, a natural solution is to split interaction and execution into two layers:

    • Upper Layer (Router): Receives all incoming messages, identifies new tasks, dispatches them, and handles cross-task coordination.
    • Lower Layer (Worker): Each Worker executes specific tasks in an independent session and an independent working directory without interfering with each other.

    Users’ habits do not need to change: they can still make requests in group chats and add comments on code hosting platforms, while the system locates the Worker responsible for the task in the background.

    However, there is an efficiency trap here: if every message must be reviewed and forwarded by the Router, the time saved by Worker parallelism might be wasted waiting for message forwarding.

    4. Thread Subscription: Delivering Messages Directly to Executors

    The optimization approach is to organize strongly correlated messages into “threads.” Take a PR review as an example:

    1. 1. Group message "Change code according to Plan A"
    2. -> Router identifies it as a new task and creates Worker-1
    3. 2. PR is created, Router binds "the message stream of this PR" to Worker-1
    4. -> Worker-1 subscribes to this thread
    5. 3. New comment under the PR
    6. -> Matches thread rules, delivered directly to Worker-1, bypassing the Router
    7. 4. New requirements in the group
    8. -> Router processes it, potentially creating a new task or coordinating existing Workers

    This way, the Router only needs to handle new tasks and items requiring cross-task coordination. Subsequent communication within the same thread can reach the executor directly, balancing parallel efficiency with message accuracy.

    5. A Harder Boundary: Cross-Session Long-Term Memory

    The thread mechanism solves the delivery of messages for “ongoing matters.” But there is a more challenging scenario: the PR has been merged, and a week later, the user says in a new session, “Follow the plan we decided on last time.”

    At this point, the system must answer three questions: which project is the user referring to? Which discussion? Which plan was ultimately chosen? This exceeds the context scope of any single session.

    The industry has not yet reached a consensus on implementing long-term memory. The two-layer architecture offers a progressive approach:

    • The Router maintains a relationship graph of tasks: which tasks originated from the same requirement, which decisions were referenced multiple times.
    • Each Worker retains the local context required for execution.

    As for which decisions are worth preserving after a session ends and when they should be recalled in the future, this is the core problem that cross-session long-term memory must solve. These capabilities have not yet been fully implemented in existing systems, but architecturally, the two-layer design has reserved a place for them.

    6. The Complete Closed Loop from a Single Delivery

    The currently deployable form is: after an authorized user makes a request, the system establishes a work item, executes it in an independent session and directory, and returns the result to the original conversation upon completion, such as submitting a PR. Although this closed loop does not involve cross-session memory, it has already validated the basic pattern of “task isolation + result return.”

    Conclusion

    The true difficulty of multi-agent collaboration is never about getting multiple models to work simultaneously, but rather ensuring that information scattered across different sessions and channels reaches the right executor at the right time. The two-layer architecture and thread subscription provide a phased engineering answer, while long-term memory—determining “what is worth remembering and when it can be recalled”—remains an open question for the entire industry. For developers, understanding this trade-off logic is far more valuable than memorizing any specific implementation.