What is the difference between task-aware routing and per-request routing?
Summary
- Per-request routing decides which model serves each individual inference call. Task-aware routing decides once per task: it sizes up the work and sends the whole task to a model, and sometimes a harness, that fits it.
- The unit of decision drives the trade-off. Per-request routing reacts to every call but has to protect prompt caches and session consistency; task-aware routing keeps a task's context on one model but lives with its first judgment.
- Both serve the same cost goal for agents: send each piece of work to the lowest-cost model that can handle it.
- On Databricks, Unity Gateway traffic splitting and fallbacks route per request, and Smart Routing (Beta) routes each subagent's task to the lowest-cost capable model.
What is the difference between task-aware routing and per-request routing?
The difference is the unit of decision. Per-request routing chooses a model for every inference call as it passes through a proxy or gateway, so two calls in the same session can land on different models. Task-aware routing chooses once for a unit of work: it reads the task, judges how hard it is, and hands the whole task to a model (and, in meta-harness designs, a coding harness) that fits. For agents, where one task can mean many model calls over a large shared context, that choice decides what routing costs and saves.
What is per-request routing?
A per-request router sits between the client and the models and picks a destination for each request. The simplest form is weighted: each model gets a share of traffic, which is how teams roll out a new model or run an A/B test. Fallbacks add a second rule: if the chosen model fails, retry on a backup. Cost-aware request routers go further and try to send each call to the lowest-cost model that can answer it.
The catch for agents is caching. Databricks' engineering write-up on managing AI coding costs notes that request-level routing for agentic work has to account for server-side caching, because a cold cache is expensive on large-context workloads. Unity Gateway's traffic splitting handles this with session affinity, covered below, which pins a session to one destination to take advantage of prefix caching.
What is task-aware routing?
A task-aware router looks at the task itself, such as "rename this component" or "explore design changes that would reduce latency", and delegates the entire task to the level of model it needs. In coding, the dispatcher is often a meta-harness: a layer that gives developers one interface and sends each task to an underlying harness and model. The dispatcher examines which level of model a task requires, then delegates that entire end-to-end task to the model.
A third pattern sits between the two: escalation, where one harness pairs a low-cost worker model with a high-capability one and passes work between them.
How do the two approaches differ?
| Dimension | Per-request routing | Task-aware routing |
|---|---|---|
| Unit of decision | Each inference call | A whole task, or a delegated subtask |
| Where it runs | A proxy or gateway between client and models | A client-side dispatcher, often a meta-harness |
| Signal used | Configured traffic weights, backend failures, or an estimate of which model can answer the request | The task description and the level of model it requires |
| Context and caching | Has to account for server-side caching on large-context workloads | Delegates the entire end-to-end task to the chosen model |
| Typical uses | Rollouts, A/B tests, load spreading, failover, per-call cost routing | Routine tasks to low-cost models, hard tasks to capable ones |
How Databricks approaches model routing
Unity Gateway, which is generally available, supports both styles.
Per request: traffic splitting and fallbacks. A model service can split traffic across several model destinations by percentage, and Unity Gateway randomly routes each request according to those weights. When splitting is configured, session affinity turns on automatically: requests that carry a session-identifying header stay on one destination, which takes advantage of prefix caching. Fallbacks retry a failed request, for example on a 429 or 5xx error, against backup destinations in the order you define. Each routing decision is logged in the routing_information field of system.ai_gateway.usage.
Per task: Smart Routing (Beta). Smart Routing selects the lowest-cost model capable of handling a task, and works with Claude Code and Codex launched through the Unity Gateway CLI (ug). With it on, the agent hands tasks to subagents and each subagent's task is routed independently, while the main session stays on its default. It chooses only among system.ai model services the developer can execute, and an account admin enables it through the Enhanced Unity Gateway preview.
Across harnesses: Omnigent (Beta). The Unity Gateway CLI routes among models within the harness you launched. Omnigent, the open-source agent meta-harness, is in Beta on Databricks and can select both the harness and the model for a task, including work delegated to subagents.
FAQs
Is Smart Routing per-request or task-aware?
The Unity Gateway docs describe it at the task level: the agent hands tasks to subagents, and each subagent's task is routed independently. The agent shows each subagent's selected model and, when available, the reason for the choice. Databricks' August cost write-up listed Smart Routing among request-level routers, so check the current docs for how it behaves.
Does per-request routing break prompt caching?
It can: Databricks notes that a cold cache hit is very costly for large-context workloads. Session affinity pins a session's requests to one destination, and Unity Gateway enables it automatically when traffic splitting is configured.
Which should I use for coding agents?
Both, for different jobs. Use per-request controls such as splitting and fallbacks for rollouts and resilience, and task-aware routing for cost, so each task lands on a model that can handle it.
Can I still pick the model myself?
Yes. Launching with --model turns Smart Routing off for that launch.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.