Choosing LLMs for Office AI Agents: Balancing Cost and Performance

    Office AI agents handle tasks with very different reasoning, context, latency, and cost requirements, so no single LLM fits every request. This article presents a practical framework for multi-model selection: classify tasks by complexity, build model profiles from internal evaluations and real logs, quantify cost with quota multipliers, incorporate time-based discount windows, route requests through filtering and fallback, add quality safeguards, and monitor the right metrics after launch. It also includes configuration-oriented code examples and a production checklist.

    1. Background: Why Office AI Agents Need Multiple Models

    An office AI agent is designed to break down a user goal into steps, call tools, and deliver a result. These tasks vary widely. Summarizing meeting minutes only requires short-text understanding and rewriting, while analyzing multi-sheet financial data and producing conclusions requires stronger reasoning, a longer context window, and stable structured output.

    A single model can hardly satisfy all these needs. Stronger models are often slower and more expensive per call. Fast, low-cost models are more likely to miss details or make logic errors on complex tasks. As a result, most products connect to multiple models and delegate the question of “which model to use” to a clear set of rules or policies.

    For developers, the key issue is not the number of models. It is whether the step from “task requirements” to “model selection” can be executed by code.

    2. Core Trade-off: Quality, Latency, and Cost

    Model selection comes down to three mutually constraining dimensions.

    1. Quality: whether the output is accurate and complete, and whether it meets format and business constraints.
    2. Latency: the wait time from submitting a request to receiving the result, including time to first token and overall completion time.
    3. Cost: the compute or quota consumed by a single call, usually proportional to model size and input/output length.

    It is difficult to optimize all three at once. Improving quality often means adding reasoning steps, which increases latency and cost. Reducing cost may sacrifice quality. A practical engineering approach is to first define the minimum acceptable quality for each task type, and then compare latency and cost only among models that meet that baseline.

    One approach to avoid is defaulting every request to the strongest model. That makes simple tasks carry unnecessary cost and lengthens user wait times.

    3. Task Classification: First Determine How Strong the Model Needs to Be

    Task classification is the starting point for model selection. Complexity can be judged from several characteristics.

    • Input length: longer text places higher demands on context understanding.
    • Number of reasoning steps: whether multi-step calculation, cross-source comparison, or conditional judgment is required.
    • Output constraints: whether strict JSON structure, tables, or a specific template is required.
    • Tolerance for error: whether the result needs human review and how costly a mistake would be.

    Based on these factors, tasks can be roughly divided into three levels.

    Level Typical tasks Quality requirement Latency sensitivity
    L1 Basic Summarization, polishing, translation, format conversion Basically correct High
    L2 General Document drafting, information synthesis, simple data processing Complete logic, minor manual correction Medium
    L3 Advanced Complex data analysis, multi-step planning, proposal review Reliable conclusions, strong reasoning needed Low to medium

    Classification rules should live in configuration rather than being scattered across conditional statements in code. This way, changing thresholds or adding task types later does not require modifying core logic.

    4. Candidate Model Profiles: Quantify Capability and Cost

    Build a unified profile for each candidate model, recording its quality tier, latency tier, and quota multiplier. Profile data should come from internal evaluations and real call logs, not marketing materials.

    Evaluation can follow these steps.

    1. Build test sets covering each task level, with at least dozens of samples per task type.
    2. Score with the same rubric, combining automated checks and manual spot checks.
    3. Record average time to first token and overall completion time for each model, and use percentiles rather than averages alone.
    4. Compare quality scores, latency, and cost in the same table to find the best value for each level.

    Profiles need regular updates. After a model version changes, previous conclusions may no longer hold, so a fixed re-evaluation cycle is recommended.

    5. Quota Multipliers: Make Cost a Computable Parameter

    Many office products use a “quota multiplier” to describe consumption differences across models. The lower the multiplier, the less quota the same task consumes. The key to understanding the multiplier is to identify the base to which it is applied.

    Quota consumption for a task can usually be expressed as:

    Actual consumption = base metering units × model multiplier

    The base metering unit is related to the input and output size of the task. If the same task switches to a model with a lower multiplier, consumption drops proportionally, but quality may change. This is exactly the trade-off that model selection must address.

    The following illustrative code shows how to estimate cost before routing. The values are only for explaining the calculation and do not represent any actual billing standard.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Task:
    4. name: str
    5. base_units: float # Base metering units, estimated from input/output length
    6. def estimate_cost(task: Task, multiplier: float) -> float:
    7. """Quota consumption = base metering units × model multiplier"""
    8. return task.base_units * multiplier
    9. tasks = [
    10. Task("Meeting minutes generation", base_units=2.0),
    11. Task("Multi-sheet data analysis", base_units=18.0),
    12. ]
    13. for t in tasks:
    14. for m in (0.5, 1.0, 2.0):
    15. print(f"{t.name} multiplier {m}: cost {estimate_cost(t, m):.2f}")

    The output shows that the same task consumes quota linearly across different multipliers. This means cost optimization mainly comes from two levers: routing simple tasks to low-multiplier models, and avoiding repeated calls to high-multiplier models for sub-steps of advanced tasks.

    6. Time-Based Discounts: Include Scheduling Time in the Policy

    Some platforms offer quota discounts for certain models during specific time windows. For developers, this means routing policy can include a time dimension.

    Keep the following points in mind.

    • Discount windows are defined by the platform. The program should read them from configuration or platform-provided rules rather than hard-coding them.
    • Rules for weekdays and holidays may differ and should be evaluated separately.
    • Time calculations must use timezone-aware datetime objects; otherwise, deployments across time zones may produce incorrect results.
    • Non-urgent tasks can be scheduled into discount windows, while urgent tasks should run immediately and should not be delayed just to wait for a discount.

    The following code shows how to determine whether the current time falls within a discount window.

    1. from datetime import datetime, time
    2. from zoneinfo import ZoneInfo
    3. def in_discount_window(
    4. now: datetime,
    5. windows: list[tuple[time, time]],
    6. is_holiday: bool,
    7. ) -> bool:
    8. """Return whether the current time falls within the configured discount windows."""
    9. local = now.astimezone(ZoneInfo("Asia/Shanghai"))
    10. current = local.time()
    11. for start, end in windows:
    12. if start <= current < end:
    13. return True
    14. return False

    In this example, the holiday parameter is not yet used in the judgment. In practice, combine it with a holiday calendar and configure separate window lists for different day types.

    7. Routing Strategy: Automatically Select Models Based on Constraints

    The routing layer maps tasks to specific models. A usable routing logic usually includes three steps: filtering, sorting, and fallback.

    1. Filtering: remove models whose quality tier is below the task requirement.
    2. Sorting: if the user is cost-sensitive, sort by multiplier ascending; if the user is latency-sensitive, sort by latency tier ascending.
    3. Fallback: if the preferred model fails or times out, switch to the next-best model and record the reason for the switch.
    1. from dataclasses import dataclass
    2. @dataclass
    3. class ModelProfile:
    4. name: str
    5. multiplier: float # Quota multiplier; lower is cheaper
    6. quality_tier: int # 1 basic, 2 general, 3 advanced
    7. latency_tier: int # 1 fast, 3 slow
    8. def route(
    9. required_tier: int,
    10. budget_sensitive: bool,
    11. models: list[ModelProfile],
    12. ) -> list[ModelProfile]:
    13. """Return candidate models in priority order; the first element is preferred."""
    14. candidates = [m for m in models if m.quality_tier >= required_tier]
    15. if not candidates:
    16. raise ValueError("No model satisfies the quality requirement")
    17. if budget_sensitive:
    18. candidates.sort(key=lambda m: (m.multiplier, m.latency_tier))
    19. else:
    20. candidates.sort(key=lambda m: (m.latency_tier, m.multiplier))
    21. return candidates
    22. def call_with_fallback(task_input: str, candidates: list[ModelProfile], invoke) -> str:
    23. last_error = None
    24. for model in candidates:
    25. try:
    26. return invoke(model.name, task_input)
    27. except Exception as exc:
    28. last_error = exc
    29. continue
    30. raise RuntimeError(f"All candidate models failed: {last_error}")

    invoke is a placeholder for the invocation function. A real implementation should include timeout control, retry limits, and logging. If all candidate models fail, the program should return a clear error rather than silently returning an empty result.

    8. Quality Safeguards: Do Not Leave Everything to the Model

    Even with good routing, model output can still be wrong. Quality safeguards can be designed at three levels.

    • Structure validation: for outputs that require JSON or tables, parse the format first. If parsing fails, request again or degrade the result.
    • Content validation: perform range checks on numeric results and require sources for key conclusions.
    • Human review: for high-risk tasks such as those involving amounts, contract terms, or externally published content, keep a human confirmation step.

    Degradation triggers should also be defined in advance. For example, if format validation fails twice in a row, escalate to a higher-quality model. This is more economical than using the strongest model for every request.

    9. Monitoring Metrics: Use Data to Validate Model Selection

    After launch, continuously observe the following metrics.

    Metric Meaning Warning signal
    Preferred model hit rate Share of tasks completed successfully by the preferred model Continual decline suggests profiles need updating
    Average quota consumption Average consumption per task type Above budget line; check whether classification is too high
    Latency percentiles P50 and P95 completion time P95 rises notably; consider adding fast models
    Fallback rate Share of requests that trigger fallback switching Too high suggests the preferred routing strategy is unreasonable
    Manual correction rate Share of user-edited outputs Rising suggests the quality tier may be insufficient

    Monitoring data should be broken down by task type. Overall averages can hide the real performance of each task type and lead to incorrect decisions.

    10. Production Checklist

    Before putting multi-model routing into production, confirm each item.

    • Task classification rules are stored in configuration and have corresponding test samples.
    • Every candidate model has a quality, latency, and multiplier profile based on internal evaluation.
    • The cost estimation function can be reconciled with actual billing records.
    • Discount window rules are read from configuration and distinguish weekdays from holidays.
    • Routing logic includes timeouts, retry limits, and explicit failure returns.
    • Critical outputs have structure validation and a human review path.
    • The monitoring dashboard shows core metrics by task type and has alert thresholds.
    • Configuration changes are versioned for traceability and performance comparison.

    The value of a multi-model architecture is that it turns model selection from experience-based judgment into a verifiable, adjustable engineering process. As long as task classification, model profiles, and cost measurement are all based on real data, the system can maintain a stable balance between quality and cost.