Why Multi-Agent Systems Need a Router/Worker Hierarchy
This article explains why multi-agent systems benefit from a Router/Worker layered architecture. It compares the resource profiles of the main session and execution workers, shows how layering prevents cross-task context pollution and synchronous blocking, and outlines the input, output, budget, and permission contracts that keep boundaries stable. A checklist helps you decide when layering is worth the added complexity.
Start With the Conclusion
When many teams build a multi-agent system, their first instinct is to pick a model that is smart enough, attach a set of tools, and write a long prompt that makes it handle everything. This approach works smoothly for a demo, but as the number of tasks grows and execution chains get longer, problems surface all at once: the context window fills up with irrelevant information, the main flow stalls on long-running commands, and separate tasks start interfering with each other.
The core motivation for a layered architecture is not to imitate some organizational chart, nor is it the idea that “more complex means more advanced.” The real starting point is this: the context window is a scarce resource, and scheduling and execution have completely different demands on that resource. Physically separating the parts that compete for the same window, then guarding the boundary with explicit contracts, is what layering is really about.
Two Roles, Two Resource Profiles
1. Main Session (Router): Low Bandwidth, Short Turns
The main session handles global coordination. It keeps an eye on multiple tasks at once, knows how far each one has progressed, where it is stuck, and who should take the next step. What it needs are summaries, identifiers, and key states, not the full details of every task. Its rhythm is short-turn judgment: receive a request, dispatch a task, aggregate results, and decide what comes next.
2. Execution Worker: High Bandwidth, Long Turns
An execution worker drives a single task forward: modifying code, running commands, and locating problems. A stack trace, the approaches already tried, or the raw output returned by a tool—any of these can determine the next action. It needs high-bandwidth context, and its rhythm is long-turn progress.
If one session takes on both roles at once, its window quickly fills with two kinds of information that have completely different natures, leading to two typical failures.
Pitfall 1: Cross-Task Context Pollution
Suppose the same session handles task A and task B in parallel. The abandoned approaches from trial and error in A, along with large blocks of logs, keep occupying the window. When it is B’s turn, the model may mistake A’s old conclusions for B’s premises and produce output that looks reasonable but goes completely off track.
Relying on a prompt to tell the model to “ignore the earlier content” is unreliable, because one sentence does not free up any window budget. A workable approach is physical isolation: each task runs in its own sub-session, contexts do not leak into one another, and the sub-session is reclaimed entirely once the task finishes.
Main session (summaries and states only)├── Sub-session A (full tool output, trial-and-error records)├── Sub-session B (independent context)└── Sub-session C (independent context)
Pitfall 2: Synchronous Blocking
If the main session waits synchronously for a long command to return, such as a full test run or build, it can neither receive new messages nor check the progress of other tasks until that command finishes. From the user’s side, it simply feels “stuck.”
After layering, the main session dispatches a task and moves on to handle new requests, while the long task progresses asynchronously in a sub-session and flows back as a result summary once done. Combined with common cloud capabilities such as message queues, task state storage, and monitoring alerts, you can further make state observable and failures retryable.
Boundaries Come From Contracts, Not Prompts
The stability of layering depends on how clear the interface contracts are. It is worth defining at least four:
- Input contract: the task goal, constraints, and the available tool scope;
- Output contract: structured results, status codes, and any necessary evidence summary;
- Budget contract: maximum turns, context limit, and timeout;
- Permission contract: writable directories and a whitelist of executable commands.
Example structure:
{"task_id": "t-001","goal": "Fix the failing test cases in the specified module","constraints": ["Do not modify public interfaces"],"budget": {"max_turns": 30, "timeout_sec": 600},"result": {"status": "done", "summary": "...", "evidence": ["..."]}}
When Layering Is Not Worth It
Layering is not the default answer. In scenarios with a single task, a very short chain, and almost no need for parallelism, layering only adds scheduling overhead and debugging complexity. If you cannot clearly state after adopting it “which kind of pollution was isolated and which kind of blocking was resolved,” then it is not necessary for now.
Implementation Checklist
- Does the main session keep only summaries and states, without carrying raw long output?
- Does every task have its own sub-session and a reclamation mechanism?
- Are long tasks truly asynchronous, and can the main flow keep responding?
- Do the contracts cover input, output, budget, and permissions?
- Are failure retries, timeout termination, and full-chain observability in place?
The value of layering ultimately shows in whether the system can maintain stable responsiveness and clear context boundaries as tasks multiply and chains grow longer.
