The Evolution of Large Agent Architectures: A Practical Guide to Router and Worker Layering
This article examines two structural problems that appear when a single monolithic agent is pushed into production: cross-task context contamination and synchronous blocking. It explains why prompt-level instructions cannot reliably solve either issue, then makes the case for a layered architecture that separates a routing layer from an execution layer. You will find the responsibility boundaries of each layer, a sample task contract, guidance on context isolation, concurrency control, timeouts and cancellation, observability and least-privilege access, plus practical rollout advice and three common pitfalls to avoid.
Introduction: When the Monolithic Agent Hits Engineering Limits
When teams start engineering agent systems, many begin with a “single large agent does everything” design: one conversation context, one prompt, one execution loop, all meant to handle every type of request a user might send. This works well during prototype validation. But as task complexity grows, concurrent requests pile up, and execution chains get longer, two structural problems surface quickly: cross-task context contamination and synchronous blocking. Neither can be fixed by tuning prompts, because both are architectural defects. This article starts from the nature of the problems, argues for introducing a layered architecture with a routing layer (Router) and an execution layer (Worker), and lays out the design points you can actually implement.
Problem One in the Monolithic Design: Cross-Task Context Contamination
How the contamination happens
Assume the same agent session handles two unrelated tasks in sequence, task A and task B. While task A runs, it usually produces a large amount of intermediate material: rejected candidate approaches, verbose execution logs, records of failed retries, temporary debugging output. Once this content enters the context window, it keeps consuming a valuable token budget, and it is not released automatically just because the task has ended.
When the system switches to task B, the model is looking at a mixed context. The most typical failure here is premise bleed-through: the model may treat a conclusion that was already overturned in A as an established fact for B and keep reasoning from it; it may also be distracted by log noise from A and produce associations that have nothing to do with B.
Why prompt constraints are unreliable
A common shortcut is to write “ignore the above” or “forget the previous content” into the prompt. Natural-language constraints like this have three limitations:
- The budget is not released: window occupancy is a physical fact. A single instruction will not make the token count go down, and once long tasks accumulate, truncation or compression still kicks in and critical information is lost.
- Attention is not controllable: how a model uses context is not a switch. Old content still influences new output through the attention mechanism, and the effect is more pronounced in long-context scenarios.
- It cannot be verified: you cannot assert, as an engineering matter, that “the model really forgot.” There is no observable, regression-testable guarantee.
The fix: physical isolation with sub-sessions
The right direction is to build isolation into the architecture rather than into the wording: assign each task its own sub-session (a Worker session) with its own context, tool state, and intermediate artifact storage. Tasks do not share a window; they exchange information only through structured results. This way, noise from A physically cannot enter the reasoning process for B, and the context budget is reclaimed in full when the sub-session ends.
Problem Two in the Monolithic Design: Synchronous Blocking
Long-running tasks stall the main loop
The second structural problem comes from synchronous waiting. When the main session waits synchronously for a long-running operation to return—a full build, a complete test run, a batch data processing job—the main loop is fully occupied until it does: it can neither accept new user messages nor advance judgment and decisions for other tasks in parallel. From the user’s point of view, the system is simply frozen.
The knock-on effects of blocking
Blocking costs more than perceived latency; it also lowers resource utilization: executors sit idle, connections time out, retry storms build up, and tasks may even be resubmitted because a timeout was misread as a failure, which amplifies the load further.
The fix: an asynchronous dispatch-and-return model
Once the layers are in place, the routing layer dispatches a task to the execution layer and returns immediately, free to receive new requests and schedule new tasks. The execution layer advances the long-running flow in the background and sends results back as events or callbacks when it finishes. The main path changes from “synchronous wait” to “submit, track, converge,” improving both responsiveness and throughput.
Design Points for the Router/Worker Layered Architecture
Responsibility boundaries
- Router (routing layer): responsible for intent recognition, task decomposition, capability matching, dispatch and priority management, and result aggregation. It keeps a lightweight context, makes decisions and orchestrates work, and does not carry heavy execution.
- Worker (execution layer): responsible for completing the actual work in an isolated sub-session, holding its own tool set and intermediate state, and reporting structured conclusions back to the routing layer.
Communication and state management
The routing layer and the execution layer should agree on a clear message contract: task identifier, input summary, status enum (received/running/succeeded/failed/cancelled), artifact reference, and error classification. State and artifacts for long tasks are best kept outside the context in general-purpose services (object storage for artifacts, a message queue for events, logging plus monitoring and alerting for observability), so that large objects are never carried through the context.
An illustrative task contract:
{"task_id": "t-20260826-001","intent": "code_change","payload_ref": "storage://artifacts/t-001/input.json","status": "running","result_ref": null,"error": null}
Isolation, concurrency, and governance
- Context isolation: one task, one sub-session; the budget is reclaimed as soon as it ends.
- Concurrency control: set concurrency limits and a queue for the execution layer to prevent resource contention.
- Timeouts and cancellation: define timeouts and cancellable semantics for each task type so nothing hangs.
- Observability: carry the task identifier through logs, metrics, and traces to make contamination and blocking problems easy to locate.
- Permissions and security: grant tool capabilities to the execution layer under least privilege, and authorize artifact access on demand.
Rollout Advice and Common Pitfalls
To get started, begin with a lightweight router and a small number of execution slots, covering first the two capabilities with the clearest payoff: making long tasks asynchronous and isolating tasks from one another. Then fill in priority scheduling, failure retries, and result aggregation step by step. There are three common pitfalls. The first is turning the routing layer into a “small monolith” that piles context back up. The second is incomplete isolation, where state is still passed quietly through shared variables or a global cache. The third is having no task contract, so results cannot converge and failures cannot be attributed.
Conclusion
Cross-task contamination and synchronous blocking both come down to the same thing: the complexity of multiple tasks is being forced onto a single context and a single execution loop. Router/Worker layering redistributes that complexity into a structure you can govern, through separation of responsibilities, session isolation, and asynchronous dispatch: the routing layer focuses on decisions, the execution layer focuses on doing the work, contexts no longer interfere with each other, and long tasks no longer block the main path. For teams moving agents from a demo into production, this layer of architectural change is often the decisive dividing line for reliability and concurrency.
