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

    This article explains how to design a routing layer for office AI agents that work across multiple large language models. It defines the router's responsibilities, compares four mainstream routing strategies (rule-based, classifier-based, cost-aware, and adaptive feedback routing), and covers capability adaptation for context windows and tool calls, cost control, observability, canary releases, and common anti-patterns. The goal is stable latency, predictable cost, and reproducible output quality as the model lineup keeps expanding.

    1. Why Office Agents Move Toward Multiple Models

    In mid-November, an office agent platform announced an expanded model lineup, adding several third-party general-purpose large models alongside its own lightweight and high-performance tiers. Such updates are no longer unusual, but they push a long-underestimated engineering problem to the forefront: once the number of available models grows from two to five or more, the quality of the scheduling layer directly determines response speed, output quality, and cost per task in office scenarios.

    Task distribution in office agents is highly uneven. Writing a short confirmation email may only require a low-latency, low-cost lightweight model. Organizing a cross-document quarterly review, generating structured tables, or filling contract clauses from a template demands stronger long-context understanding and instruction-following. No single model is optimal for every task, so multiple models are inevitable, and routing is what turns “selection” into an operable capability.

    2. Defining the Routing Layer’s Boundaries

    First, routing is not a simple if-else branch. It is an independent component with a clear input and output contract.

    • Inputs: task description, conversation history summary, available tool list, size of files and attachments, and the user’s latency and cost preferences.
    • Outputs: target model identifier, inference parameters (temperature, maximum output length, and so on), timeout and retry policy, and fallback chain.
    • Constraint: the routing decision itself must be low-overhead, typically completing in milliseconds, and must not become a new bottleneck.

    A common mistake is pushing business logic into the router. Routing only answers “who executes,” not “how to execute.” Prompt assembly, tool orchestration, and result validation should stay in the agent execution layer; otherwise routing rules will expand with business requirements until they can no longer be maintained.

    3. Four Mainstream Routing Strategies

    3.1 Rule-Based Routing

    Match on explicit features such as task type, input length, whether a table attachment is present, or whether JSON output is required. Rule-based routing offers the best explainability and the lowest troubleshooting cost, making it suitable as a fallback and a canary baseline.

    1. routes:
    2. - name: short_text
    3. match: { task_type: reply, tokens_lt: 800 }
    4. model: lite
    5. timeout_ms: 3000
    6. - name: long_doc
    7. match: { attachments: true, tokens_gt: 12000 }
    8. model: strong
    9. timeout_ms: 20000
    10. - name: structured
    11. match: { output_schema: true }
    12. model: strong
    13. params: { temperature: 0.1 }

    3.2 Classifier-Based Routing

    Use a lightweight classifier to predict task difficulty or the required capability dimensions, then decide based on thresholds applied to the output probability distribution. Compared with rules, it is more robust to phrasing differences, but it requires labeled data and periodic evaluation, and you must prevent the classifier itself from becoming an unexplainable black box.

    3.3 Cost-Aware Routing

    Minimize cost while satisfying quality constraints. In engineering practice this is usually simplified into tiers: first filter out models that fail a minimum quality bar, then pick the lowest unit cost among the remaining candidates. The key is a trustworthy quality baseline; otherwise “saving money” turns into rework, and rework often costs more than the original call.

    3.4 Adaptive and Feedback-Based Routing

    Dynamically adjust weights based on historical success rate, time to first token, and user adoption rate, similar to a multi-armed bandit approach. This strategy has a high upside, but it requires stable metric collection and a rollback mechanism; otherwise model quality fluctuations can be amplified into an overall decline in user experience.

    4. Adapting to Context and Tool Calls

    The real difficulty with multiple models is not “choosing” but “adapting.” Models differ in context window, adherence to system prompts, function-calling format, and structured output stability, so routing must carry capability descriptions.

    1. {
    2. "model_caps": {
    3. "lite": { "ctx": 32000, "tools": true, "json_mode": "strict" },
    4. "strong": { "ctx": 200000, "tools": true, "json_mode": "loose" }
    5. }
    6. }

    Three practical recommendations: first, trim the context budget to each model’s capability, and summarize very long documents in segments before inference; second, keep tool descriptions behind a unified abstraction layer and let adapters convert them into each model’s calling format, so business code stays unaware of the differences; third, apply schema validation and one automatic retry to structured output uniformly, containing instability within the adaptation layer.

    5. Cost Control and Observability

    Cost governance must be measurable: track call volume, input and output tokens, retry rate, and human adoption rate by task type to build a cost-per-task dashboard. Set budget thresholds and circuit breakers so that when a task category’s cost rises abnormally, the system automatically falls back to the lightweight model and triggers an alert.

    Observability should cover at least four categories of data: routing decision reasons (which rule matched or which model scored highest), latency breakdown (queueing, time to first token, overall), failure classification (timeout, format error, non-compliant content), and the retry and fallback chain. Without records of the “decision reason,” production issues become nearly impossible to review after the fact.

    6. Canary Releases and an Evaluation Loop

    Because the model lineup changes frequently, you need two channels: an offline evaluation set and online canary releases. Offline, compare accuracy, format compliance rate, and cost on a fixed task set; online, roll out by percentage while watching adoption and complaint rates. If any metric crosses its threshold, automatically roll back to the previous routing configuration. Separating configuration from code and versioning both are prerequisites for fast rollback.

    7. Common Anti-Patterns

    • Routing layers nested too deeply; beyond two levels, debugging cost rises sharply.
    • Optimizing only average latency while ignoring the long tail, causing a few users’ experience to collapse.
    • Hardcoding prompts in the router, so everything breaks when the model changes.
    • Lacking a unified abstraction layer, leaving model-specific call details scattered across business code.
    • Replacing continuous regression with a one-off evaluation, letting quality quietly degrade as models iterate.

    8. Conclusion

    Adding multiple models is not a multiple-choice question but an architecture problem. By making routing an independent layer with clear boundaries, pluggable strategies, observable metrics, and rollback-capable configuration, an office agent can keep latency stable, cost under control, and quality reproducible even as the model lineup keeps expanding. For teams that want to build similar capabilities quickly, you can start with rule-based routing and an evaluation loop on top of general capabilities such as the model services, container platform, and log monitoring offered by Baidu AI Cloud, then gradually introduce cost-aware and adaptive strategies.