Multi-Model Routing for Office Agents: Scheduling Strategies for Quality, Latency, and Cost

    This article explains how model routing enables office agents to select among multiple models at request time. It covers the routing architecture, complexity/latency/cost criteria, unified quota accounting, evaluation-set-based quality checks, fallback and escalation, observability, and engineering deployment practices.

    1. Background: Office Agents Enter the Multi-Model Era

    In office scenarios, agents handle tasks that vary widely. Meeting-note summarization, spreadsheet data aggregation, external email drafting, and contract-clause review have different requirements for reasoning depth, response time, and invocation cost. If every request is sent to the same model, two problems commonly appear: simple tasks become too expensive, and output quality for complex tasks becomes unstable.

    As a result, more office products are integrating multiple models at the same time and letting the system make choices at the request layer. This mechanism is commonly called model routing. It moves “which model to use” from a manual user decision to automatic selection by rules or algorithms. The quality of the routing layer directly affects the product’s response experience, per-task cost, and result stability.

    2. Basic Structure of Multi-Model Routing

    A typical routing system can be divided into four parts.

    1. Request analysis: extract features such as task type, input length, whether tool calls are needed, and whether there are latency requirements.
    2. Policy decision: filter candidate models based on features and configuration, such as lightweight models, general-purpose models, and high-precision models.
    3. Invocation and fallback: call the selected model; if it times out or returns an error, switch to a backup model.
    4. Logging and feedback: record the model used for each call, latency, token usage, and result quality to support later policy adjustments.

    The interfaces between these parts need to remain stable. The scheduling layer and specific models should be isolated through a unified adapter. This way, when adding or replacing models, business code does not need to change; only the adapter and routing configuration need to be updated.

    3. Routing Criteria: Complexity, Latency, and Cost

    3.1 Task Complexity

    Complexity is usually estimated from several dimensions: input length, whether multi-step reasoning is involved, whether structured output is required, and whether external tools need to be called. A common engineering practice is to score these features and select a high-precision model when the score exceeds a threshold. Scoring rules can first be defined based on experience and then calibrated with evaluation data.

    3.2 Response Latency

    Interactive scenarios, such as a user waiting in an editor for an immediate reply, are sensitive to first-token latency and should prioritize fast-responding models. Background batch tasks, such as nightly batch generation of weekly reports, can tolerate longer processing time and are better suited to cost-effective models. The latency budget should be written into the routing policy as a hard constraint, not observed after the fact.

    3.3 Usage Cost

    Cost needs to be measured precisely per request. The cost of a single call can be estimated with the following formula:

    Cost per call = input tokens × input unit price + output tokens × output unit price

    Some platforms also set quota consumption multipliers for different models to convert costs within a unified quota system. Developers should read multipliers as configuration items rather than hard-code them, because multipliers may change with operational policies.

    3.4 Example Code

    The following code shows a simplified routing decision flow. The model names, thresholds, and multipliers are placeholder examples and do not represent any real data. They should be replaced with configuration from your own environment in actual use.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class ModelProfile:
    4. name: str
    5. max_complexity: int # highest complexity level the model can handle
    6. p95_latency_ms: int # recently measured P95 latency
    7. cost_multiplier: float # quota consumption multiplier, read from the config center
    8. PROFILES = [
    9. ModelProfile("light-model", max_complexity=2, p95_latency_ms=800, cost_multiplier=0.5),
    10. ModelProfile("general-model", max_complexity=4, p95_latency_ms=2000, cost_multiplier=1.0),
    11. ModelProfile("expert-model", max_complexity=5, p95_latency_ms=5000, cost_multiplier=2.0),
    12. ]
    13. def estimate_complexity(prompt: str, needs_tools: bool, needs_structured: bool) -> int:
    14. score = 1
    15. if len(prompt) > 2000:
    16. score += 1
    17. if needs_tools:
    18. score += 1
    19. if needs_structured:
    20. score += 1
    21. return min(score, 5)
    22. def choose_model(prompt, needs_tools=False, needs_structured=False,
    23. latency_budget_ms=3000, mode="balanced"):
    24. complexity = estimate_complexity(prompt, needs_tools, needs_structured)
    25. candidates = [
    26. p for p in PROFILES
    27. if p.max_complexity >= complexity and p.p95_latency_ms <= latency_budget_ms
    28. ]
    29. if not candidates:
    30. # No model satisfies both complexity and latency constraints; fall back to the most capable model
    31. return PROFILES[-1]
    32. if mode == "cost":
    33. return min(candidates, key=lambda p: p.cost_multiplier)
    34. # Default policy: choose the lightest model that meets the constraints
    35. return candidates[0]

    This code illustrates three principles. First, complexity estimation is separated from model selection, making it easier to debug independently. Second, constraints such as complexity and latency are applied before the optimization objective of cost. Third, there is a clear fallback behavior when no candidate is available. In real systems, complexity estimation usually also combines task-type labels and historical invocation data, rather than relying only on input length.

    4. Unified Modeling of Quotas and Costs

    In a multi-model environment, cost accounting can easily get out of control. If the same task is routed to a high-multiplier model, a single invocation may consume several times more than a low-multiplier model. For this reason, it is advisable to model this uniformly at the routing layer.

    First, convert each invocation into a standard quota:

    Converted quota = base usage × model multiplier

    Second, set budget ceilings by user, team, and business line. When a team’s monthly consumption approaches its ceiling, the routing policy can automatically tighten and prioritize low-multiplier models.

    Third, set approval or alert thresholds for high-multiplier models. For example, when a single task exceeds a certain quota, log the event and notify the owner to prevent abnormal requests from continuously amplifying costs.

    Finally, review the cost structure periodically. Track the average converted quota for each task category, determine which tasks can move to lightweight models, and which high costs are justified. These data are more useful than simply comparing model unit prices.

    5. Quality Safeguards: Evaluation Sets and Fallback Strategies

    The effectiveness of a routing policy must be validated with data. Setting thresholds based only on intuition can easily lead to unnoticed quality degradation on certain tasks.

    5.1 Build Per-Task Evaluation Sets

    Build representative samples by task type, such as summarization, data extraction, email drafting, and contract-clause comparison. Each sample should include the input, expected output, or scoring criteria. Evaluation dimensions can include:

    • Content accuracy: whether key information is correct;
    • Format compliance: whether structured output passes validation;
    • Human rating: business staff scoring readability and completeness.

    Evaluation results should be used directly to calibrate routing thresholds. For example, if a lightweight model meets the format-compliance requirement on data extraction tasks, that task category can be moved to the lightweight model.

    5.2 Fallback and Escalation

    Fallback means switching to a backup model when the primary model times out or returns an error. Escalation means retrying with a more capable model when output fails validation, such as unparseable JSON or missing required fields. Both mechanisms need retry limits; otherwise, costs may multiply during failures.

    A practical approach is to set a maximum number of calls per request and record the full call chain for later troubleshooting.

    6. Observability Design

    Without observability, it is difficult to judge whether a routing policy is effective. At minimum, record the following fields for each request:

    • request_id: unique request identifier, used to link the entire call chain;
    • task_type: task type label;
    • selected_model: the final selected model;
    • fallback_chain: the fallback or escalation path;
    • latency_ms: end-to-end latency;
    • input_tokens, output_tokens: usage statistics;
    • validation_result: output validation result;
    • cost_units: converted quota consumption.

    Based on these fields, dashboards can be built to observe each model’s call share, failure rate, P95 latency, and unit cost per task category. Alert rules can be set for sudden failure-rate increases, abnormal cost growth, or prolonged timeouts on a model.

    7. Engineering Implementation Recommendations

    1. Externalized configuration. Put routing rules, thresholds, and multipliers in a config center with hot-update support, so every adjustment does not require republishing the service.
    2. Gray release. Apply new policies to a small percentage of traffic first, compare quality, latency, and cost metrics, and switch to full traffic after confirming there is no significant regression.
    3. Data masking. Fields involving personal information or trade secrets should be masked before entering external models, following enterprise data-classification rules.
    4. Key management. Store access credentials for each model in a key management service and inject them through environment variables or at runtime; do not write them into code or logs.
    5. Elasticity and peak shaving. Deploy the scheduling service on a container platform and auto-scale it based on load. Peak-period requests can be buffered through a message queue to avoid instantaneous traffic overwhelming downstream model rate limits.

    8. Conclusion

    The core value of model routing is turning “which model to choose” from experience-based judgment into a measurable, adjustable engineering problem. During implementation, first clarify task classification and constraints, then calibrate the policy with evaluation data, and continuously verify effectiveness through a complete observability system. As long as these three links are solid, a multi-model architecture can achieve a controllable balance among quality, latency, and cost.