Multi-Model Routing and Cost Control for AI Office Agents

    AI office agents handle tasks with very different requirements for reasoning, latency, and cost. This article explains how to classify tasks, route them across multiple models, estimate quota consumption, schedule non-urgent work in preferred time windows, and protect quality with evaluation sets and fallback mechanisms. It also includes a routing architecture, sample code, a cost calculation example, implementation advice, and common pitfalls.

    1. Why Office Agents Need Multiple Models

    Office agents handle a wide range of tasks. Meeting-note cleanup, contract-clause proofreading, weekly data-report generation, and cross-document information retrieval all have different requirements for reasoning ability, response speed, and per-call cost. If every task is sent to the same model, simple tasks waste compute and quota, while complex tasks may still produce insufficient results.

    As a result, multi-model access has become a common architecture for this type of product. The core idea is to treat models as replaceable capability units and let a routing layer decide which model should execute a task based on task characteristics. This design helps maintain quality for complex tasks while keeping simple tasks inexpensive.

    2. Task Tiering and Model Selection Dimensions

    Before selecting a model, three dimensions need to be clarified.

    1. Quality: Does the task require multi-step reasoning, long-context understanding, or strict output formatting?
    2. Latency: Is the user waiting for a real-time result, or can the task be completed asynchronously in the background?
    3. Cost: What is the cost per call, and how quickly does it consume quota under the quota system?

    In practice, tasks can be divided into three tiers:

    • Lightweight: Short-text rewriting, summarization, and format conversion. These tasks have short inputs and clear rules, making them suitable for low-cost models.
    • Standard: Medium-length document analysis, table cleanup, and email drafting. These tasks require a certain level of comprehension and are suitable for balanced models.
    • Complex: Multi-document reasoning, long-chain planning, and code generation and review. These tasks have a high cost of error and are suitable for the most capable models.

    The tiering rules do not need to be very precise at the beginning. You can start with a rough judgment based on task type and input length, then gradually adjust thresholds according to online failure rates and user revision rates.

    3. Typical Architecture for Multi-Model Routing

    The routing layer usually contains four modules:

    • Task parsing: Extract features such as task type, input size, and output requirements.
    • Routing decision: Select candidate models based on those features.
    • Execution and retry: Handle timeouts and rate limits, using exponential backoff to control retry intervals.
    • Result validation: Check whether the output format is compliant and whether key facts are consistent with the input materials.

    The following sample code uses placeholder model names. In a real implementation, replace them with your own model configuration:

    1. ROUTING_RULES = {
    2. "light": {"model": "model_small", "max_tokens": 1024},
    3. "standard": {"model": "model_mid", "max_tokens": 4096},
    4. "complex": {"model": "model_large", "max_tokens": 8192},
    5. }
    6. def classify_task(task: dict) -> str:
    7. if task["type"] in {"rewrite", "summarize", "convert"}:
    8. return "light"
    9. if task["type"] == "plan" or task.get("input_tokens", 0) > 20000:
    10. return "complex"
    11. return "standard"
    12. def run_task(task: dict, call_model, validate):
    13. level = classify_task(task)
    14. # Execute first with the model for the assigned tier; if validation fails, escalate to the strongest model
    15. candidates = [level] if level == "complex" else [level, "complex"]
    16. for name in candidates:
    17. cfg = ROUTING_RULES[name]
    18. result = call_model(cfg["model"], task["prompt"], cfg["max_tokens"])
    19. if validate(result):
    20. return result
    21. raise RuntimeError("All candidate models failed result validation")

    This code illustrates two key points. First, routing rules are separated from business logic, so model configuration can be changed independently. Second, when validation fails, the system automatically escalates, leaving quality fallback to the system rather than relying on users to retry repeatedly.

    4. Cost Model: From Call Count to Quota Consumption

    Many office products do not bill directly by token. Instead, they tie quota to model consumption multipliers. The lower the multiplier, the less quota the same task consumes. To understand this mechanism, cost needs to be split into two parts:

    • Per-task consumption = base consumption × model multiplier
    • Period total consumption = sum of call count × per-call consumption for each task type

    The following hypothetical numbers illustrate the calculation. They do not represent the pricing of any actual product:

    • Lightweight tasks: 2,000 calls per month, multiplier 0.5, base consumption 10 units, total 2,000 × 10 × 0.5 = 10,000
    • Complex tasks: 300 calls per month, multiplier 3, base consumption 10 units, total 300 × 10 × 3 = 9,000
    • Total consumption with tiered routing: 19,000 units.

    If all 2,300 tasks were sent to the complex-tier model, total consumption would be 2,300 × 10 × 3 = 69,000 units. Tiered routing saves about 70% of quota, with the savings mainly coming from the share of lightweight tasks.

    This calculation shows that the key to cost optimization lies in the call structure, not the unit price alone. Teams should first count the volume and distribution of each task type, then estimate the budget.

    5. Time-Window Strategy and Off-Peak Calls

    Some platforms may offer discounts on quota consumption during specific time windows, such as certain hours on weekdays or holidays. If the system can recognize these rules, it can schedule non-urgent tasks in discounted time windows and keep interactive tasks on the real-time channel.

    Implementation can follow these practices:

    • Add priority and deadline fields to tasks to distinguish real-time tasks from background tasks.
    • Use a scheduler to place background tasks in a queue and execute them in batches during specified time windows.
    • Do not hardcode discount rules into business logic. Rules change, so rely on the latest platform documentation and manage them through a configuration center.
    • For budgets that depend heavily on discounts, reserve additional cost space for scenarios without discounts to prevent budget overruns after a promotion ends.

    6. Quality Assurance: Evaluation Sets and Fallback Mechanisms

    Model switching and routing-threshold adjustments both affect output quality, so systematic evaluation is needed.

    1. Build fixed evaluation sets: Prepare 50 to 200 samples for each task type, with reference answers or scoring rubrics.
    2. Regression testing: Re-run the evaluation sets whenever a model is changed or a tiering threshold is adjusted.
    3. Core metrics: Include accuracy, format compliance rate, average latency, and per-task cost. All four metrics should be observed together to avoid optimizing cost at the expense of quality.
    4. Fallback strategy: Escalate to a stronger model on timeout or validation failure; switch to a backup model when a model service is unavailable.

    Note that public leaderboard scores cannot directly represent performance in office scenarios. Differences in long-context understanding in Chinese, table data processing, and structured-output stability are often larger than differences in overall scores, so your own evaluation set should be the reference.

    7. Implementation Advice and Common Pitfalls

    The following order is recommended for implementation:

    1. First count task types and call volume, complete tiering and cost accounting, and then discuss model selection.
    2. Put model names, prices, and consumption multipliers in a configuration center so they can be adjusted quickly when platform rules change.
    3. Log the task type, model used, latency, and quota consumption of each call for periodic review.
    4. Desensitize data before sending it to external models, and comply with your organization’s data compliance requirements.

    Common pitfalls include the following three types:

    • Pursuing only the strongest model: Complexity is overestimated, quota is exhausted quickly, and most tasks do not need that level of capability.
    • Looking only at unit price instead of total cost: This ignores retries, manual correction time, and hidden costs caused by validation failures.
    • Treating temporary discounts as long-term assumptions: After the discount ends, the original budget model becomes invalid and must be recalculated.