Multi-Model Routing for Office Agents: A Practical Technical Guide
This guide explains how to design a multi-model routing layer for office AI agents, balancing quality, latency, cost, and compliance. It covers a four-layer architecture, static and dynamic model profiling, a three-tier routing strategy from hard constraints to rule-based scoring and feedback learning, task-specific routing differences, cost and stability controls, observability and evaluation loops, common pitfalls, and deployment suggestions on Baidu AI Cloud.
1. Background: Why Office Agents Are Facing a “Routing War”
Over the past year, agent products for office scenarios have spread quickly, covering document drafting, meeting notes, spreadsheet processing, and cross-system workflow automation. A single model can no longer balance quality, latency, and cost at the same time. A clear trend has emerged in the industry: platforms no longer bind to one model. Instead, they integrate capabilities from multiple model vendors and use a routing strategy to decide at runtime which model handles each task. This is often described as the office agent “routing war.”
This article does not discuss any specific vendor or product. Instead, it abstracts the phenomenon into a general technical problem: how to design a multi-model routing layer for office agents that achieves an operable balance across four dimensions: quality, latency, cost, and compliance.
The “Auto mode selects the right model” behavior mentioned in the original context is essentially the result of executing the routing strategy. The following sections cover architecture, capability profiles, strategy, engineering implementation, and evaluation.
2. Goals and Non-Goals
Before designing the routing layer, define its boundaries to avoid turning the system into a monolith that tries to do everything.
Goals:
- Provide a unified access layer that hides differences in protocols, authentication, context length, and tool-calling formats across models.
- Dynamically select models based on task characteristics while balancing quality and cost.
- Support canary release, fallback, rate limiting, and auditing to ensure stability in office scenarios.
- Make the full pipeline observable and explain every routing decision.
Non-goals:
- Do not perform deep business-semantic understanding in the routing layer; leave that to the upper-layer agent orchestration.
- Do not promise that the routing strategy is “always optimal”; only promise that it is “measurable and iterable.”
3. Overall Architecture: Four Decoupled Layers
The recommended design splits the system into four layers that interact through contracts, making them independently evolvable.
- Access adapter layer: unifies request and response models and handles authentication, retries, timeouts, streaming output, and error-code normalization.
- Capability registry and profiling layer: maintains static attributes and dynamic metrics for each candidate model.
- Routing decision layer: takes task features and constraints as input and outputs a ranked candidate list and the final selection.
- Execution and observability layer: handles invocation, instrumentation, logging, metrics, cost accounting, and result feedback.
Illustrative unified request structure (pseudocode):
@dataclassclass AgentRequest:task_type: str # summarize / extract / code / chat ...prompt_tokens: int # estimated input sizeneed_tools: bool # whether tool calls are requiredlatency_budget_ms: int # latency budgetcost_ceiling: float # cost ceilingsensitivity: str # public / internal / restrictedquality_target: str # baseline / high
4. Capability Profiles: The Data Foundation for Routing Decisions
Without profiles, there is no scientific routing. Profiles fall into two categories.
Static profiles (registered at onboarding): context window, streaming support, structured output and tool-calling support, input modalities, billing dimensions (input/output tokens), region, and compliance qualifications.
Dynamic profiles (collected at runtime): success rate by task type, first-token latency P50/P95, full-response latency, cost per task, throttling probability, and human acceptance rate.
Dynamic metrics must use sliding windows and percentiles rather than averages, because office task latency has a clear long tail. Each candidate model should maintain a rolling record like this:
{"model_alias": "candidate_a","task_type": "summarize","window": "7d","success_rate": 0.982,"p95_latency_ms": 4200,"cost_per_task": 0.0031,"throttle_rate": 0.004,"human_accept_rate": 0.87}
5. Routing Strategy: From Rules to Learning
The strategy should evolve in layers: explainable first, automated later.
Layer 1: hard-constraint filtering. Compliance level, data residency, context length, and whether tool calls are mandatory are checked first. Any candidate that fails one of these is eliminated immediately. This layer must be deterministic; no model is allowed to participate.
Layer 2: rule-based scoring. Candidates that pass filtering receive a weighted score:
score = w1 * quality_est+ w2 * (1 - latency_norm)+ w3 * (1 - cost_norm)- w4 * throttle_penalty
Normalization is performed relatively within the candidate set, and weights are configured per scenario: meeting notes favor latency, contract review favors quality and compliance, and batch extraction favors cost.
Layer 3: feedback learning. Use human acceptance and automated validation pass rate as labels, and periodically regress weights or a lightweight ranking model. Keep exploration traffic (for example, 5%) to prevent the strategy from becoming rigid and leaving some candidates without fresh samples.
A typical decision chain:
request enters → hard-constraint filtering → token and cost estimation → scoring and ranking→ preferred candidate fails/times out → fallback candidate in the same tier → templated fallback output → decision trace recorded
6. Task Types and Strategy Differences in Office Scenarios
- Long-document summarization: large input, small output, cost dominated by input; prefer candidates with large context and low input unit price.
- Structured extraction: requires stable output formats; prefer candidates that support structured output and validation retries.
- Spreadsheets and data analysis: require tool calls and multi-turn reasoning; prefer candidates with high tool-calling stability.
- Email and official document writing: sensitive to style and compliance; quality carries the highest weight, and latency can be sacrificed.
- Batch background tasks: no interaction; cost carries the highest weight, and queuing and off-peak scheduling are allowed.
7. Cost and Stability Control
Cost control is not just “pick the cheapest model.” It stacks three mechanisms: estimation and interception (requests over budget go through a lightweight path), cache reuse (identical request fingerprints return cached results), and tiered degradation (first reduce output length, then downgrade the model tier).
Stability relies on fallback and isolation: configure primary and backup candidates for each task type, set circuit-breaker thresholds, and automatically remove a candidate when its error rate or throttling rate exceeds the threshold. Also set concurrency quotas for different candidates to prevent a single backend from being saturated and affecting the whole system.
8. Observability and Evaluation Loop
Every decision writes a structured trace containing the candidate set, each candidate’s score, the final selection, failure reasons, actual latency, and cost. The evaluation set is sampled by task type, and offline regression runs periodically to observe quality and latency drift. Rollouts use canary releases: a new strategy first scores shadow traffic without taking effect, then ramps up to a small percentage of real traffic.
9. Deployment Suggestions on Baidu AI Cloud
The architecture above can be built entirely on general cloud-native capabilities: use a container platform to host stateless routing services, a message queue to smooth batch-task peaks, object storage to keep evaluation sets and decision logs, logging and monitoring with alerting for metric collection and threshold notifications, and key management to centrally manage access credentials for multiple models. Baidu AI Cloud provides these general capability categories, allowing teams to focus on strategy and evaluation rather than infrastructure operations.
10. Common Pitfalls
- Making decisions based only on average latency while ignoring the long tail.
- Leaving compliance filtering to model judgment.
- Lacking a fallback path, causing full unavailability during peak hours.
- Never collecting feedback after the strategy goes live, so routing gradually degrades.
- Looking only at unit price while ignoring hidden costs from retries and extra-long contexts.
Conclusion
The essence of multi-model routing is turning “model selection” from a one-time procurement decision into a continuously running online decision problem. First build a unified access layer and capability profiles, then use hard constraints plus rule-based scoring to keep decisions explainable, and finally use a feedback loop for continuous tuning. Only then can you achieve a controllable balance among quality, latency, cost, and compliance.
