Multi-Agent Collaboration Architecture: Design and Practical Guide
This article explains why a single conversation cannot support multiple concurrent tasks and introduces a two-layer multi-agent architecture that separates a routing layer from isolated execution workers. It covers thread subscription to prevent the scheduler from becoming a throughput bottleneck, the challenge of long-term memory across sessions, and practical recommendations for context boundaries, unified entry points, explicit decision records, and observability. Readers will learn a pragmatic approach to keeping context connected when needed and isolated when appropriate.
1. The Starting Problem: Why a Single Session Cannot Handle Multiple Tasks
When building an intelligent coding assistant or a multi-agent collaboration system, the first obstacle is usually not model capability. It is context ownership. When a user asks in a group chat to “modify the code according to plan A,” then adds a comment in a code review platform saying “let’s go with plan B instead,” a human developer immediately understands that this is a revision of the previous decision. A system, however, has to perform three steps of reasoning: identify which existing task the new message refers to, align information scattered across different channels, and deliver the updated intent to the execution unit that is already running.
If every message is placed into the same session, the execution unit can see the full evolution of the decision. The cost is that code logs, user instructions, and tool results are all mixed together, so tasks can only be queued and executed serially. Conversely, opening a separate session for every item increases parallelism, but as soon as two items involve the same decision, or the user adds clarification through a different entry point, someone has to act as a “human message bus.” In practice, that person is often the developer who already has five or six windows open.
This is the core trade-off of a multi-agent architecture: the more sessions are split apart, the stronger the parallelism, and the harder it becomes to carry forward the original context.
2. A Two-Layer Architecture: Decoupling Interaction from Execution
A common approach in the industry is to introduce a two-layer structure. The upper layer receives messages, assigns tasks, and coordinates. The lower layer does the actual work in isolated environments.
- Upper-layer scheduler (Router): The single entry point for information. It maintains the task list and the dependencies and conflicts between tasks, and decides whether a new message should enter an existing work item or whether a new work item is needed.
- Lower-layer execution unit (Worker): Each work item maps to an independent session and an independent working directory. They do not pollute each other and can run in parallel.
The user experience stays the same: users still raise requirements in the group chat and add comments in the review system. Behind the scenes, the system routes messages to the execution unit responsible for that item. After an authorized user submits a request, the system creates a work item, executes it in an independent session and directory, and returns to the original conversation to deliver the result, such as submitting a code merge request.
The routing logic can be abstracted schematically as:
def on_message(msg):key = extract_thread_key(msg) # group topic / review item / ticket IDif key and key in active_workers:active_workers[key].deliver(msg) # direct delivery, bypass the schedulerelse:router.assign_or_create(msg) # new task or cross-task coordination
3. Thread Subscription: Preventing the Scheduler from Becoming a Throughput Bottleneck
If every follow-up comment has to pass through the scheduler for interpretation and forwarding, the time saved by parallel workers will be consumed again by queueing. A common engineering practice is to organize messages within the same review item or the same group topic into a thread. The first message is dispatched by the scheduler. Once a worker takes over, it subscribes to that thread, and subsequent messages in the thread are delivered directly to the corresponding worker. The scheduler only handles new tasks and cross-task coordination.
This is essentially the idea of “separating the control plane from the data plane.” The control plane handles low-frequency decisions that require a global view. The data plane handles high-frequency message routing that can be determined locally. In implementation, a message queue can handle subscription and distribution, a container platform can host the isolated execution environments, and logging services with monitoring and alerting can track the status and elapsed time of each work item.
4. The Real Difficulty: Long-Term Memory Across Sessions
Thread subscription solves follow-ups under the same review item, where the anchor still exists. The harder scenario is this: that merge request was merged last week, and a week later the user says in a new session, “go with the plan we agreed on last time.” The system must answer three questions: which project, which discussion, and which plan was ultimately chosen.
The industry has not reached a consensus on how to implement long-term memory. This is one reason the two-layer architecture is widely adopted: the scheduling layer can maintain a relationship graph between tasks, while the execution layer each retains the local context needed for execution. These naturally correspond to a division between “global memory” and “local memory.” Which decisions are worth retaining after a session ends, and when they should be recalled, remains an open question. A viable engineering direction includes structuring work item conclusions into decision records with timestamps and source references, using a retrieval mechanism to recall them when they are semantically relevant, and defining clear write and expiration policies for memory to prevent stale conclusions from contaminating new tasks.
5. Practical Recommendations
- Define context boundaries first: Use “a work item that can be delivered independently” as the unit for session division, rather than dividing by user or channel.
- Unified entry, isolated execution: Route all channel messages through a unified entry point first, then let the scheduling layer dispatch them, avoiding direct exposure of execution units.
- Prioritize direct thread delivery: Do not send messages to the scheduler when an anchor can determine their destination. Reserve global decision-making for when it is truly needed.
- Persist decisions explicitly: Write “which plan was chosen, why, and when it was overturned” into structured records to lay the foundation for future cross-session memory.
- Observability first: Failures in a parallel architecture often appear as misrouted messages rather than crashes. Without tracing across the pipeline, they are extremely difficult to locate.
The value of multiple agents is not opening more windows. It is keeping context connected when it should be connected and isolated when it should be isolated. Two-layer scheduling plus thread subscription is a pragmatic landing point today, while long-term memory across sessions is the next key piece to complete.
