What Is Dynamic Routing?
A gateway pattern that selects the model, provider, or policy path for each LLM request based on runtime conditions.
What Is Dynamic Routing?
Dynamic routing is a gateway routing pattern that selects the model, provider, or policy branch for each LLM or agent request at runtime. It belongs to the LLM gateway family because the decision happens between request intake and provider execution, often after a pre-guardrail and before retry or fallback logic. FutureAGI records the chosen route, target, and strategy in gateway traces, so teams can connect each routing decision to downstream latency, cost, safety, and task-completion outcomes.
Why it matters in production LLM/agent systems
Static provider selection fails quietly before it fails loudly. The first failure mode is cascading failure: one degraded model endpoint returns slow 5xx responses, retries pile up, and agent steps time out across the workflow. The second is runaway cost: low-risk summarization, classification, or extraction calls keep hitting a premium model because the app has no runtime rule for cheaper targets. A third is multi-turn degradation, where an agent starts on a strong model, falls back after an error, and never recovers quality because the route change is invisible.
The pain lands on different teams at once. Developers see non-reproducible behavior because identical prompts route to different providers under load. SREs see p99 latency spikes, 429 bursts, queue depth, and fallback storms. Product teams see slower conversations and lower task completion. Compliance teams see data-residency exceptions when requests from one region drift to a provider in another region.
Dynamic routing matters more for 2026-era agent pipelines than for single-turn chat. One customer action can trigger retrieval, planning, tool selection, tool calls, reflection, and final response generation. If every step uses the wrong target, latency and cost compound. If the gateway adapts per step, the system can reserve stronger models for high-risk decisions while sending routine calls to lower-cost, lower-latency paths.
How FutureAGI handles dynamic routing
FutureAGI handles dynamic routing in Agent Command Center’s gateway:routing surface, backed by the routing-policies resource. A policy can combine a routing policy: cost-optimized default with conditional routes such as metadata.tier == "enterprise" or metadata.region == "eu", then attach model fallback, pre-guardrail, post-guardrail, semantic-cache, and traffic-mirroring controls around the same request path.
A realistic production example is an enterprise support agent. The first user message enters through a pre-guardrail. If the request contains regulated account data, the gateway routes it to an approved provider in the right region. If the request is a routine FAQ and the semantic-cache misses, the policy sends it to a cheaper model. If p99 latency on that provider crosses the alert threshold, Agent Command Center switches the target to the next healthy provider and records agentcc.routing.strategy, agentcc.routing.target, and gen_ai.request.model on the trace.
FutureAGI’s approach is to make the routing decision observable, not just configurable. With traceAI-langchain or another traceAI integration, the engineer can compare the route against llm.token_count.prompt, llm.token_count.completion, tool spans, and final eval results. Unlike a basic LiteLLM-style provider list, the route becomes part of the reliability record: the next action can be an alert, a stricter threshold, a temporary fallback, or a regression eval on traces affected by the route change.
How to measure or detect it
Measure dynamic routing by joining gateway spans, provider outcomes, and eval results:
- Route-selection fields — track
agentcc.routing.strategy,agentcc.routing.target, andgen_ai.request.modelon every production trace. - Latency by route — compare p50, p90, and p99 latency per provider/model pair; p99 catches agent-step stalls better than averages.
- Cost by route — roll up
llm.token_count.prompt,llm.token_count.completion, and token-cost-per-trace by routing policy. - Fallback and retry rate — alert when fallback rate rises for one target while global request volume stays flat.
- Policy-match distribution — confirm conditional routes fire at expected rates by region, tenant, tier, and experiment cohort.
- Eval outcome by route — compare
TaskCompletionandToolSelectionAccuracyscores for traces served by each target; a cheaper route is not acceptable if agent completion drops. - User-feedback proxy — watch thumbs-down rate, escalation rate, or human handoff rate after a route change.
A healthy dynamic-routing system has boring distributions: route choice matches policy intent, cost moves in the expected direction, and eval-fail-rate-by-cohort does not spike after a provider shift.
Common mistakes
- Calling every conditional policy dynamic routing. A static tenant rule is conditional; dynamic implies routes can respond to live health, cost, or evaluation state.
- Routing on average latency only. Agents feel tail latency; p99 per trace matters more than daily means.
- Ignoring guardrail order. If pre-guardrails run after routing, unsafe prompts may waste expensive provider calls before rejection.
- Combining model fallback and traffic mirroring without labels. Mirrored calls must not affect user response, cost attribution, or eval cohorts.
- Letting application teams hard-code provider switches. It hides decisions from traces and breaks cross-team rate-limit management.
Frequently Asked Questions
What is dynamic routing?
Dynamic routing is a gateway pattern that selects the model, provider, or policy path for each LLM or agent request at runtime based on live conditions such as cost, latency, health, safety state, or request metadata.
How is dynamic routing different from conditional routing?
Conditional routing follows declared rules, such as region or tenant checks. Dynamic routing can include conditional rules, but it also responds to live signals like provider health, p99 latency, cost budget, and fallback state.
How do you measure dynamic routing?
Measure routing spans with fields such as agentcc.routing.strategy, agentcc.routing.target, gen_ai.request.model, p99 latency, fallback rate, token cost, and eval outcomes like TaskCompletion by route.