A journal of architectural patterns, failure modes, and design principles for engineers building AI agents that run continuously at scale.

Routing Logic Design for Specialized Subagent Selection

Smart routing decides whether specialized agents succeed or fail at their tasks.

· 9 min read
Cover illustration for “Routing Logic Design for Specialized Subagent Selection”
Multi-Agent Coordination · October 28, 2026 · 9 min read · 2,024 words

The design of routing logic decides whether specialized subagents do the work well or share the same mistakes a generalist would make. For an agent-powered product, the design must match each request to the right specialist, model tier, tool scope, and isolated customer environment. Managed agent infrastructure can remove the work of operating those environments, but the runtime details here do not establish which platform provisions a persistent per-user sandbox through a single API call.

Why a multi-agent system's value lives or dies at the routing layer

A customer asks for a billing investigation and a sales action in the same message. Sending both jobs to one general-purpose agent can produce an answer that is mediocre on both counts. The request contains two jobs. Separating them lets a billing specialist investigate the charge while a sales specialist handles the other action. Routing is the decision layer that makes that separation possible.

Without it, specialization exists only on paper. An agent stretched across billing, sales, support, and onboarding gets a bloated prompt, a confusing tool set, and diluted attention. Request routing chooses the specialist by intent and domain, while model routing chooses the model tier by task complexity. Tool routing adds a third axis after dispatch, when the agent selects a tool or knowledge source. A mistake at the first decision can cascade through every downstream step.

How routing relates to orchestration, handoff, and parallelization — and why the distinctions matter for design

Routing makes one decision about which destination handles a request. Orchestration coordinates several agents across a multi-step task. Handoff transfers ownership from one agent to another during a conversation, while parallelization runs several agents at once and merges their outputs. These are different operations, with different failure modes. A router can choose the wrong agent, an orchestrator can create brittle and slow coordination, a handoff can loop indefinitely, and parallel outputs can conflict.

Routing usually feeds orchestration, and an orchestrator’s first choice between one agent and a team is itself a routing decision. The two therefore layer together rather than compete. Microsoft’s AI agent design patterns reference uses “handoff orchestration” for routing and includes triage, transfer, dispatch, and delegation as aliases. That vocabulary overlap makes the underlying operation more useful than the label when comparing designs.

The six routing patterns available in production and what each one costs

Rule-based routing uses keywords and regex patterns to select a destination. It is fast, simple, and easy to inspect. Its weakness is language variation. A request such as “I paid but nothing arrived” contains no “order” keyword, so a rule built around that word can miss the intended route. Rules fit signals that are unambiguous and exhaustively enumerable.

Semantic routing matches a request against example utterances in a shared vector space. It needs only a few examples per route. Closely related intents remain its weak spot. If their embeddings are hard to separate, nearest-neighbor lookup can pick the wrong specialist. Intent-based routing uses a dedicated ML classifier to predict a category and handles varied language better, but it needs labeled data and must be retrained when new agents arrive.

LLM-based routing gives a model descriptions of the available agents and asks it to select one. It handles ambiguity well, but adds another model call. That flexibility costs time and money. An LLM-based decision can add roughly 500–2000ms, compared with roughly 50–100ms for lighter semantic or ML classifiers. LangGraph’s conditional edges and Amazon Bedrock’s supervisor with routing mode provide named framework primitives for this pattern.

Confidence gating makes that flexibility less reckless. The router returns an agent name and confidence score, with results above a threshold taking the specialist branch and lower-confidence results taking a fallback. The recommended response to ambiguity is to gather one clarifying signal, then decide again. Without that check, the model can pick a destination that looks right even when it is unsure. A valid output is not necessarily a sound decision.

Hierarchical routing puts an orchestrator above specialized workers. MasRouter, presented at ACL 2025, formalizes this through a collaboration mode determiner, a role allocator, and an LLM router. The layers decide how many agents are needed, which roles they need to fill, and which model fits. The structure makes delegation explicit, but also creates successive decisions that can be wrong. Its cost includes coordination and the first classification call.

Auction-based or dynamic agent selection changes which agents can be chosen as the task moves forward. MoMA, short for Mixture of Models and Agents, uses a context-aware state machine and dynamic masking to exclude agents that cannot contribute in the current state. This goes beyond matching a request to advertised capabilities. Its tradeoff is dependence on the representation of task state and eligibility. If that representation excludes a useful agent, the remaining selection cannot recover it.

Why static, dynamic, and hybrid dispatch are different implementation strategies, not just performance choices

Static dispatch assigns routing choices in code before execution. CrewAI lets developers pass an LLM instance to each Agent object when they create it, while Claude subagent definitions let them fix the model or inherit it from the parent session. Ownership sits with the application developer. This fits predictable pipelines such as Coordinator, Implementor, and Reviewer, where roles map cleanly to workloads. It fits less well when work within a role ranges from simple to much harder tasks.

Dynamic dispatch makes those choices by classifying requests at runtime. A LangGraph routing node can use structured LLM output to classify a request, with conditional edges sending it to different agents or models. Flexibility comes with an operating burden. Maintaining a classifier can cost more engineering effort than it saves in model spending at lower call volumes. The design therefore changes who owns the decision.

Hybrid dispatch divides that ownership deliberately. Rules or semantic checks handle clear cases, an LLM handles ambiguity, and rule-based overrides protect safety-critical paths. The cheap checks come first. This cascade avoids paying for model judgment when the answer is already clear, without forcing every unfamiliar request through rigid code. Swiggy’s customer support system combines rule-based routing with a lightweight LLM for agent assignment, illustrating that split in a high-volume product.

How model-tier routing inside a multi-agent system amplifies or destroys the gains from agent specialization

Giving every specialist the same model creates two opposing failures, namely expensive over-provisioning for simple work and weak reasoning for difficult work. Both can spread across a pipeline. File navigation on a frontier model can cost roughly 5× as much as on a lighter model, despite needing only pattern matching. The agent is right, but its compute allocation is wrong.

Context and scheduling create related mismatches. A fixed context window can discard instructions on large code-generation tasks or waste resources on small edits. Code review can become a synchronous frontier-model bottleneck, while a lightweight reviewer risks missing vulnerabilities. MasRouter finds that larger models do not always outperform smaller ones. MoMA treats agent routing and model routing as a unified problem, matching task domain and difficulty to execution capabilities rather than assuming the strongest model is the safest default.

Assigning model tiers to agent roles in a coding or research pipeline

Implementation maps to Sonnet 4.6 for improved coding performance and consistency at lower cost than Opus. File navigation and symbol resolution map to Haiku 4.5 for high-volume, cost-sensitive processing that relies on pattern matching. Different jobs deserve different starting points. The useful criteria are reasoning depth, context length, and call frequency.

Code review maps to GPT-5.2 in this template. Review can also become a bottleneck depending on whether it runs synchronously or asynchronously. These assignments are a static baseline, while the dynamic-routing approach described above handles changes in how hard the work is within a role. The same criteria apply to a research pipeline, but the available material does not say which named model to use for each role in one.

How tool scoping at the integration layer functions as a routing-adjacent design decision

An agent that can see too many tools has a harder time choosing one. The larger context inflates token costs, distracts the model, and weakens its choice of action. Dispatch does not end at agent selection. The router chooses the specialist, but the tools exposed to that specialist shape what happens next. Tool scoping adds this control without leaving the front-door router in charge of every tool call.

Composio makes granular scoping tractable by filtering tools by toolkit or individual action and supporting tool search. Its connected accounts store each user’s OAuth credentials, so scope also limits the blast radius of unintended actions. This is both a cost and safety choice. Providers for frameworks including the OpenAI Agents SDK, Anthropic Claude Agent SDK, LangGraph, and CrewAI let that choice sit at the framework layer without bespoke integration work. An agent’s visibility into actions at each point in the workflow is an important design variable.

What the trust model of each agent runtime means for routing architecture in multi-tenant systems

Customer isolation constrains routing before any pattern is chosen. The relevant runtime comparisons concern approval, isolation, and recovery, rather than a single claim that an agent is “sandboxed.” These controls answer different operational questions. Approval governs whether an action may run, isolation limits where it can act, and recovery determines how work can be undone. A setup that is safe for a single-operator can still be unsafe in a multi-tenant system.

OpenClaw offers sandbox options including Docker, Podman, SSH, and OpenShell, plus per-agent scopes, workspace permissions, audits, and secrets handling. Sandboxing is off by default, however, and its documentation assumes a trusted operator. For a multi-tenant setup, the recommendation is to give each tenant a separate gateway. Hermes starts from smart approval that evaluates commands before execution. Its container backends drop Linux capabilities, disable privilege escalation, use namespace isolation, and support read-only root filesystems.

Codex ties its recommendation to the workspace. Version-controlled folders get Auto, which combines workspace write with on-request approvals, while non-version-controlled folders get read-only. Claude Code provides credential masking and organization-level managed policies that individual developers cannot override. Rollback, permission reset, and checkpoint rewind are distinct recovery approaches, and the available descriptions do not support assigning each one to a runtime.

Input trust remains a separate routing concern. Claude Code’s CVE-2026-54316, fixed in v2.1.163, affected CI workflows that trusted the text in an issue or PR as input. It shows how prompt injection can pass through a routing path when its trust boundary is unclear. For multi-tenant operators, the design lesson is to match the runtime boundary to the required customer isolation. A separate gateway per tenant is an architectural and cost commitment.

How cross-agent communication protocols shape the outer boundary of any routing architecture

Routing changes when the specialist is part of another system. Agent2Agent, or A2A, addresses communication across those system and trust boundaries. A2A v1.0 anchors that external protocol layer. But a communication protocol does not by itself solve discovery, which is needed to find the right external specialist.

The Agentverse infrastructure paper identifies keyword-based agent discovery as a gap and calls for semantic, trust-weighted agent DNS. It also calls for a move from single-protocol communication to a multi-standard agent lingua franca. These are proposed infrastructure directions. An internal design should allow for named-agent discovery and cross-system handoff as extensions. Routing’s connective tissue now reaches beyond one operator’s stack.

Composing these patterns into a coherent dispatch architecture for an agent-powered product

Rule-based and semantic checks handle clear requests first, LLM-based routing handles what remains, and confidence gating catches ambiguity before specialist execution. Hierarchical coordination then governs work inside the selected branch. Each subagent receives an appropriate model tier and tool scope, subject to the runtime’s trust boundary. Routing is recursive.

Per-user isolation means provisioning, securing, monitoring, updating, and recovering a separate routing-plus-agent stack for every customer. Managed agent infrastructure takes on that work so product teams can build the product without also running the infrastructure. The Stripe analogy is useful here, because the value lies in making a necessary capability repeatable without rebuilding its machinery. A single-call provisioning promise is meaningful only when it delivers the isolated environment that the routing architecture actually requires.

Sources

  1. Towards Generalized Routing: Model and Agent Orchestration for Adaptive and Efficient Inference
  2. Infrastructure for the Agentic Web: Gap Analysis and Architecture from the Agentverse Platform

More in Multi-Agent Coordination