Multi-Model Routing for Office Agents: A Practical Technical Guide

    This article presents a vendor-neutral approach to building a model routing layer for office AI agents. It covers the quality, cost, and latency trade-offs behind routing, a five-layer reference architecture, structured model capability profiles and a constrained scoring function, context-aware task profiling, budget and latency controls, observability and evaluation loops, common anti-patterns, and a phased rollout plan. Readers will learn how to design a measurable, evolvable multi-model scheduling system instead of simply picking the strongest model.

    1. Why Office Agents Need Model Routing

    Office agents differ fundamentally from single-turn chatbots. Their task chains are longer, tool calls are more frequent, and inputs often mix long documents, spreadsheets, email threads, and meeting notes. Outputs usually need to translate into executable actions. No single model leads on every subtask: some excel at long-context summarization, some at structured extraction, some are more reliable for code and spreadsheet computation, and others are faster and cheaper per unit.

    This has led to a shared engineering direction in the industry: treat model selection itself as an optimizable problem and build a model router. This article does not evaluate or recommend any specific vendor product. Instead, it abstracts a general technical approach. In related work at Baidu AI Cloud, this capability typically falls under a common combination of model serving, gateway, and observability, with implementation varying by scenario.

    The routing layer addresses three core tensions:

    • Quality: output quality varies significantly across subtasks, and the cost of errors differs too.
    • Cost: long contexts and high call frequency can quickly inflate expenses, so budget constraints are required.
    • Latency: office interactions are sensitive to time-to-first-token, and serially waiting on multiple models is unacceptable.

    2. Reference Architecture: Five Decoupled Layers

    A maintainable multi-model scheduling system should be split into five layers that communicate through explicit contracts.

    1. Access layer: unified authentication, tenant isolation, rate limiting, and quotas that hide backend differences.
    2. Orchestration layer: task decomposition, tool calls, state machines, and retries that decide what needs to be done.
    3. Routing layer: decides who does it and outputs the model and parameter selection.
    4. Adapter layer: normalizes different interface shapes into internal standard request and response structures.
    5. Observability layer: logs, metrics, tracing, and evaluation feedback that drive strategy iteration.

    The key design principle is that the orchestration layer is unaware of specific models, and the routing layer is unaware of business semantics. The two interact only through a task profile plus constraints.

    3. Model Capability Profiles and Scoring Functions

    Routing starts by abstracting candidate models into structured profiles rather than relying on subjective impressions. A profile should include at least context window, structured output stability, tool-calling support, multimodal input capability, typical latency percentiles, unit cost, rate-limit thresholds, and available regions.

    Scoring can be written as a constrained linear utility function:

    1. score(m) = w1*quality(t, m) + w2*speed(m) - w3*cost(m) - w4*risk(m)
    2. subject to: budget_left >= cost(m), p95_latency(m) <= SLA

    Here, quality(t, m) must be derived from regression on an offline evaluation set, not set arbitrarily. It is recommended to maintain a separate evaluation set for each task type: summarization, extraction, rewriting, spreadsheet computation, code generation, and multi-turn tool calls. Keep 100–300 samples per task type with reference answers or automatic scoring, and run regression regularly.

    Illustrative pseudocode:

    1. def route(task, ctx):
    2. cands = [m for m in registry if m.supports(task.type)]
    3. cands = [m for m in cands if m.window >= ctx.tokens and m.available()]
    4. scored = [(score(m, task, ctx), m) for m in cands]
    5. scored.sort(reverse=True)
    6. for s, m in scored:
    7. if m.cost <= ctx.budget_left and m.p95 <= ctx.sla_ms:
    8. return m
    9. return fallback_chain(ctx)

    4. Context Awareness: Let Routing Understand the Task

    High-quality routing relies on task profile features. Common features include input length and language, whether the input contains tables or code blocks, whether citation traceability is needed, the number of historical failures, explicit user preferences, remaining budget, and time-of-day load.

    A practical technique is triage with a small model: first use a low-latency model to roughly classify the task and estimate its difficulty, then let the routing layer choose the execution model. This is more robust than pure rules, but triage itself adds latency and cost, so it usually pays off only when the task type space is large.

    5. Cost and Latency Constraint Engineering

    • Budget tokenization: split budgets across tenant, session, and task levels, and make routing choices only within the affordable set.
    • Cascades and fallbacks: try smaller models first and escalate on failure or low confidence; escalation must include timeouts and a maximum hop count to avoid cascading failures.
    • Cache first: check result caches and semantic cache hits for deterministic subtasks such as fixed-template rewriting.
    • Batching and streaming: combine non-real-time subtasks into batch submissions, and force streaming first-token returns on real-time paths.

    6. Observability and the Evaluation Loop

    Without measurement there is no optimization. The minimum viable metric set includes success rate by model and task, time-to-first-token P50/P95, cost per task, tool-call failure rate, fallback rate, and human adoption rate. Tracing must record the basis for routing decisions, including score breakdowns and reasons for pruning; otherwise production issues cannot be reviewed.

    The evaluation loop should run weekly: production sampling, automatic scoring, failure clustering, evaluation set expansion, and weight recomputation. Weight changes should go through a canary release, observing core metrics on 5% of traffic first before rolling out fully.

    7. Common Anti-Patterns

    • Writing routing as a giant if-else block that becomes unmanageable as task types grow.
    • Making decisions on average latency alone and ignoring timeouts caused by the long tail.
    • Lacking a unified adapter layer, leaving vendor interface differences scattered across business code.
    • Having no fallback chain, so a single rate limit makes the whole path unavailable.
    • Leaving the evaluation set unchanged for a long time, causing weights to gradually drift.

    In the first phase, build the unified gateway and adapter layer to standardize interfaces and connect observability. In the second phase, introduce rule-based routing and budget constraints to capture cost benefits. In the third phase, add automatic scoring and canary mechanisms to close the loop. In the fourth phase, consider triage models and multi-objective optimization. Every step should have a rollback switch.

    Overall, model routing for office agents is not about picking the single strongest model. It is about building a constrained, measurable, and evolvable scheduling system. Get task profiles, capability profiles, constraints, and evaluation right, and a multi-model strategy can reliably deliver business value.