Multi-Model Scheduling for Office AI Agents: Selection, Cost, and Optimization Practices

    As office AI agents handle increasingly complex tasks involving multiple steps like retrieval, reasoning, and generation, relying on a single LLM struggles to balance performance, latency, and cost. This article explores the engineering design of multi-model scheduling architectures for AI agents. It covers task classification, model pool design, evaluation frameworks, cost estimation, off-peak scheduling, routing and degradation strategies, and observability practices to help engineers build robust and cost-effective systems.

    The core capability of office AI agents is to receive a user’s goal, autonomously break it down into steps, call necessary tools, and deliver the final result. Unlike single-turn Q&A, an agent task typically involves multiple model calls, encompassing retrieval, reasoning, document generation, and format validation. As task volume grows, a single model can rarely meet the simultaneous demands for quality, response speed, and cost efficiency. Consequently, an increasing number of products adopt a multi-model parallel architecture, where a scheduling layer selects the appropriate model based on task characteristics. This article discusses the design essentials of this architecture from an engineering perspective.

    1. Office Task Characteristics and Classification

    Tasks in office scenarios vary significantly. Organizing meeting minutes requires completely different model capabilities compared to analyzing cross-departmental financial data. Based on complexity and fault tolerance, tasks can be broadly classified into three tiers:

    • Light tasks: Text polishing, format conversion, short text summarization, and simple translation. These tasks involve few steps and short outputs, have relatively relaxed accuracy requirements, and users typically expect immediate results.
    • Medium tasks: Data table cleanup, email and copywriting, multi-document comparison, and template-based report generation. These tasks require a certain level of context understanding and have high demands for structural integrity and factual consistency.
    • Heavy tasks: Long-document deep analysis, multi-step reasoning, cross-file collaboration, and complex workflows requiring multiple tool calls. These tasks involve many steps, where a single error can amplify along the chain, demanding the highest level of reasoning stability from the model.

    The purpose of classification is to set different default models and budget ceilings for each tier. Using the most powerful model for all tasks results in significantly higher costs, while using the lightest model for everything increases the failure rate of heavy tasks. Classification is the foundation for striking a balance between the two.

    2. Why a Model Pool is Needed

    In engineering practice, a model pool typically includes the following types of members:

    • Self-hosted or privately deployed models: Used for routine tasks, offering better control over data flow and latency.
    • External general-purpose LLMs: Used for tasks requiring stronger reasoning or broader knowledge coverage.
    • Lightweight or distilled models: Used for high-frequency, low-value simple requests.

    The value of a model pool is twofold. First is redundancy. When a model experiences rate limiting, timeouts, or service fluctuations, the scheduling layer can switch to other members to ensure task continuity. Second is cost negotiation. Different models have varying unit prices and quota consumption rates. The scheduling layer can select more cost-effective combinations while meeting the minimum quality threshold.

    The key to making a model pool usable is a unified calling layer. A common approach is to define an abstract interface that consolidates the request formats, authentication methods, error codes, and billing fields of various models into adapters. The business code then relies solely on the unified interface.

    1. from abc import ABC, abstractmethod
    2. class ChatModel(ABC):
    3. """Unified model calling interface, implemented by each model via an adapter."""
    4. @abstractmethod
    5. def complete(self, messages: list[dict], max_tokens: int, timeout_s: float) -> dict:
    6. """Returns a result containing text, input_tokens, output_tokens, and quota_used."""
    7. raise NotImplementedError

    Another benefit of the adapter pattern is easier testing. You can write mock implementations for the scheduling logic to verify routing and degradation rules without consuming real quotas.

    3. Evaluation Dimensions for Model Selection

    Selection cannot rely on a single metric. A practical evaluation framework typically includes the following dimensions:

    1. Task performance: Accuracy, completeness, and format compliance rate on an evaluation set that aligns with business needs.
    2. Response latency: Time to first token and overall completion latency, focusing on P95 rather than average, as long-tail requests impact user experience more.
    3. Cost: Billing unit price per call, as well as additional tool calling fees.
    4. Context capability: Acceptable input length, which is crucial in long-document scenarios.
    5. Tool calling stability: Reliability of structured outputs and whether parameters are frequently missing or incorrectly formatted.
    6. Service stability: Availability, rate limit frequency, and error type distribution.

    Evaluation should be divided into offline and online phases. The offline phase uses a fixed evaluation set to compare scores across models under identical prompts and parameters, ensuring a fair comparison. The online phase uses canary releases or A/B testing to observe the manual correction rate, task abandonment rate, and retry count in real traffic. High offline scores do not guarantee better online performance; the two must mutually validate each other.

    Comprehensive scoring can adopt a weighted approach. Weights should be determined by business priorities. For example, time-sensitive scenarios can increase the latency weight, while compliance-heavy scenarios can increase the stability weight.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class ModelProfile:
    4. name: str
    5. quality: float # Offline evaluation score, ranging from 0 to 1
    6. latency_p95_ms: int # Online observed P95 latency
    7. quota_multiplier: float # Quota consumption multiplier, lower means less consumption
    8. stability: float # Recent success rate, ranging from 0 to 1
    9. def score(profile: ModelProfile, weights: dict[str, float]) -> float:
    10. latency_score = max(0.0, 1 - profile.latency_p95_ms / 10_000)
    11. cost_score = max(0.0, 1 - profile.quota_multiplier)
    12. return (
    13. weights["quality"] * profile.quality
    14. + weights["latency"] * latency_score
    15. + weights["cost"] * cost_score
    16. + weights["stability"] * profile.stability
    17. )

    The scoring function above is merely illustrative. The normalization methods for each metric need adjustment based on actual data distribution, and weights should be periodically reviewed against online feedback.

    4. Quota Multiplier and Single-Task Cost Estimation

    Most office AI agents use a quota-based billing system. When calling different models, the system converts the consumption into a unified quota based on that model’s quota multiplier. The multiplier is a coefficient relative to a baseline value; a lower multiplier means less quota consumed for the same workload. Indicating the multiplier in the product UI helps users understand cost differences and make informed choices.

    The quota consumption for a single task can be estimated using the following method:

    Single task quota = Base quota per step × Number of steps × Model quota multiplier

    Here, the base quota per step is usually related to the token count of inputs and outputs. The number of steps depends on the task breakdown, and retries and tool calls also add to the step count. When estimating, it is recommended to include retry counts in the step number; otherwise, costs will be systematically underestimated.

    1. def estimate_task_quota(base_quota_per_step: float, steps: int,
    2. retry_rate: float, multiplier: float) -> float:
    3. effective_steps = steps * (1 + retry_rate)
    4. return base_quota_per_step * effective_steps * multiplier
    5. # Example data, used only to illustrate the calculation method
    6. for name, mult in [("Model A", 1.0), ("Model B", 0.5), ("Model C", 0.2)]:
    7. cost = estimate_task_quota(base_quota_per_step=10, steps=10,
    8. retry_rate=0.0, multiplier=mult)
    9. print(name, cost)

    In the example above, the multipliers for the three models are 1.0, 0.5, and 0.2, respectively. A 10-step task consumes 100, 50, and 20 quotas respectively. Actual multipliers are subject to official announcements, and during design, the multiplier should be read as a configuration item rather than hardcoded into business logic.

    5. Promotional Windows and Off-Peak Scheduling

    Some platforms offer quota discounts for specific models during certain time windows. For a scheduling system, these rules introduce two challenges. First, rules may vary by workdays, holidays, or specific time slots, requiring precise timezone handling. Second, rules are subject to change, so the system cannot hardcode specific time slots into the code.

    A more robust approach is to abstract the promotional windows into configurations, including start/end times, applicable date types, applicable model lists, and timezones. Before dispatching a task, the scheduling layer checks if the current time hits a rule and determines the execution timing or model selection accordingly.

    1. from datetime import datetime
    2. from zoneinfo import ZoneInfo
    3. def in_window(now: datetime, window: dict) -> bool:
    4. local = now.astimezone(ZoneInfo(window["tz"]))
    5. start, end = window["start_hour"], window["end_hour"]
    6. if local.weekday() >= 5 and not window.get("include_weekend", False):
    7. return False
    8. return start <= local.hour < end

    For non-urgent batch tasks, consider off-peak execution. For example, generation, archiving, and offline analysis tasks can be placed in a queue and scheduled uniformly during promotional windows. Urgent tasks should retain a real-time channel so they are not delayed by waiting. When designing the queue, pay attention to task deadlines to avoid timeouts caused by attempting to save quotas.

    Note that promotional rules may come with activity durations, quota limits, or scope restrictions. When logging billing records, the system should save the rule version and the hit result for post-audit verification.

    6. Routing and Degradation Strategies

    The core responsibility of the scheduling layer is to select a model for each task and switch when anomalies occur. Common routing strategies fall into three categories:

    • Rule-based routing: Directly maps to a model based on task type, input length, and user tier. The logic is transparent and easy to audit.
    • Classifier-based routing: Uses a lightweight classifier to first determine task complexity, then selects the corresponding model. The classifier itself incurs costs, so it is necessary to evaluate whether its benefits outweigh its overhead.
    • Budget-based routing: Prioritizes models with lower multipliers within the user or team’s quota budget, automatically downgrading when the budget is insufficient.

    Degradation strategies must specify clear trigger conditions. Typical triggers include request timeouts, consecutive rate limits, structured output validation failures, and failed quality checks. When degrading, the reason should be logged, and a maximum switch count should be enforced to prevent oscillating between multiple models.

    1. def pick_model(task_level: str, budget_left: float, profiles: list[ModelProfile],
    2. deadline_ms: int, cost_of: dict[str, float]) -> ModelProfile | None:
    3. candidates = [p for p in profiles if p.latency_p95_ms <= deadline_ms]
    4. affordable = [p for p in candidates if cost_of[p.name] <= budget_left]
    5. if not affordable:
    6. return None
    7. if task_level == "heavy":
    8. return max(affordable, key=lambda p: p.quality)
    9. return max(affordable, key=lambda p: p.quality - p.quota_multiplier)

    During retries and degradation, idempotency must be guaranteed. For steps that produce external side effects, such as writing to a file or sending a message, a unique request identifier should be used for deduplication to prevent repeated execution caused by retries. Additionally, intermediate results should be persisted so that tasks can resume from breakpoints rather than being billed from scratch.

    7. Observability and Cost Monitoring

    Without measurement, continuous optimization is impossible. It is recommended to collect at least the following metrics:

    • Average quota consumption per task, grouped by task type and model.
    • Task success rate and manual correction rate, to measure output quality.
    • P50 and P95 latency for each model, along with the timeout ratio.
    • Retry rate and degradation rate, reflecting service stability.
    • Cost comparison inside and outside promotional windows to verify the actual effect of off-peak strategies.

    Logs must be desensitized. Prompts and outputs may contain sensitive information, so it is advisable to log only hashes or summaries, retaining the original text only for a short period within authorized scopes. Alert thresholds should be set based on historical baselines, notifying responsible personnel when anomalies occur, such as abnormal spikes in quota per task, sudden increases in degradation rate, or persistent drops in a model’s success rate.

    Observability data is typically aggregated through general monitoring, alerting, and logging services. Metrics and logs should share a task identifier, making it easy to trace a specific request from a billing anomaly.

    8. Deployment Checklist

    Before deploying multi-model scheduling, verify each item on the following checklist:

    1. Task classification standards are documented and correspond to product features.
    2. The unified calling interface is complete, and all model adapters pass identical contract tests.
    3. The evaluation set covers major task types, and offline results are reproducible.
    4. Quota multipliers, promotional windows, and timezones are managed as configurations with recorded effective versions.
    5. Routing rules have a clear fallback sequence and a maximum switch count limit.
    6. Retries and degradation have idempotency protection, and intermediate states can be recovered.
    7. Monitoring metrics, alert thresholds, and log desensitization strategies are confirmed.
    8. Cost estimates are regularly reconciled with actual bills, triggering a review if deviations exceed the threshold.

    The benefits of multi-model scheduling come from continuous calibration. Model capabilities, pricing rules, and user task structures all change over time, so scheduling strategies need regular re-validation using new evaluation data and online metrics. Configuring rules dynamically and building a comprehensive measurement system are the prerequisites for the long-term stable operation of a multi-model architecture.