Multi-Model Agent Office: Unified Access and Cost Governance in Practice
This article explores the engineering practices behind integrating multiple large language models (LLMs) into office-oriented AI agents. It covers the architectural design of a unified adapter layer, routing strategies, fallback and retry mechanisms, cost metering and budgeting, observability, and compliance considerations. The goal is to help teams build flexible, cost-efficient, and resilient multi-model systems.
Why Office Agents Need Multiple Models
Office agents typically handle a variety of tasks, such as summarizing long documents, organizing spreadsheet data, generating meeting minutes, explaining code snippets, and conducting multi-turn Q&A. Different tasks place different demands on models. Some require deep reasoning, while others are more sensitive to latency and unit cost. No single model excels across all dimensions. As a result, many products adopt a multi-model architecture, treating models as interchangeable capability units.
This approach offers three main benefits. First, tasks can be matched more precisely to models, achieving a better balance between quality and cost. Second, when a model service experiences capacity pressure or instability, the system can switch to backup models, reducing the likelihood of business disruption. Third, product teams can adjust the model mix based on user feedback without modifying core business logic.
Core Challenges in Multi-Model Integration
1. Inconsistent interface protocols. Different model services differ in request formats, streaming output formats, tool-calling protocols, and error code definitions. If business code is tightly coupled to a single protocol, the cost of adding a new model grows linearly with the number of models.
2. Inconsistent capability boundaries. Context window size, multimodal support, structured output stability, and function-calling accuracy vary significantly. The routing layer needs a clear capability profile for each model to make sound selections.
3. Different metering methods. Most models are billed per input and output token, while some charge per request or apply multiplier coefficients. A common practice in office products is to assign a consumption multiplier to each model, letting users see actual usage. The system must convert these rules into a unified internal metering unit.
4. Stability and latency fluctuations. Model services may experience rate limiting, timeouts, or temporary unavailability. Without a degradation strategy, the system will simply report errors to users in these situations.
Architecture Design: Unified Adapter, Routing, and Degradation
3.1 Unified Adapter Layer
The goal of the adapter layer is to encapsulate all models behind a single internal interface. Business code only interacts with that internal interface; protocol conversion, authentication, and error mapping are handled inside adapters. A recommended layering is:
- Business layer: task-oriented, e.g., summarization, rewriting, information extraction.
- Orchestration layer: decides which model to use, and when to retry or degrade.
- Adapter layer: one adapter per model, responsible for protocol conversion.
- Transport layer: unified handling of timeouts, connection pools, logging, and trace tracking.
With this layering, adding a new model only requires a new adapter and a configuration entry—business code remains untouched.
3.2 Routing Strategies
Routing can be designed along four dimensions: task type, context length, latency target, and cost ceiling. In the early stages, a static rule table is recommended, and dynamic routing based on evaluation results can be introduced later as data accumulates.
Example rules:
- Short-text rewriting or title generation: prefer low-multiplier, low-latency models.
- Long-document summarization: first check input length, then select only models that support the required context length.
- Structured extraction: select models with validated structured output performance, and validate output format.
- User-specified model: respect the user’s choice, and display the model’s multiplier in the interface.
3.3 Degradation and Retry
Degradation strategies should follow one principle: retry retryable errors, switch immediately for non-retryable errors, and return a clear message when all candidates fail. Timeouts, rate limits, and temporary service errors are retryable. Parameter errors and authorization errors should not be retried—they only waste quota. Retries should use exponential backoff and a maximum attempt count to avoid amplifying failures.
Example Code
The following code demonstrates a unified adapter interface and a call path with degradation. This is a design pattern illustration; model identifiers and configurations are placeholders.
from dataclasses import dataclassfrom typing import Protocol, Optionalimport time@dataclassclass ChatRequest:task_type: strmessages: list[dict]max_tokens: int = 1024temperature: float = 0.2@dataclassclass ChatResult:text: strmodel_id: strinput_tokens: intoutput_tokens: intcost_units: float # Unified internal metering unitclass ModelAdapter(Protocol):model_id: strdef invoke(self, req: ChatRequest) -> ChatResult: ...class RetryableError(Exception):"""Retryable errors: timeouts, rate limits, etc."""class Router:def __init__(self, routes: dict[str, list[ModelAdapter]]):self.routes = routesdef call(self, req: ChatRequest, max_retry: int = 2) -> ChatResult:candidates = self.routes.get(req.task_type, [])if not candidates:raise ValueError(f"no model configured for task: {req.task_type}")last_error: Optional[Exception] = Nonefor adapter in candidates:for attempt in range(max_retry + 1):try:return adapter.invoke(req)except RetryableError as e:last_error = etime.sleep(0.5 * (2 ** attempt)) # Exponential backoffexcept Exception as e:last_error = ebreak # Non-retryable, switch to next candidateraise RuntimeError("all candidates failed") from last_error
Key points: the adapter exposes a unified return structure, and the routing layer only works with internal types. Retryable and non-retryable errors are handled separately, and retry counts are capped.
Cost Governance
5.1 Unified Metering
Each call should be converted to an internal metering unit. A common formula:
Metering units = (input tokens × input price coefficient + output tokens × output price coefficient) × model multiplier
Multipliers and price coefficients should be maintained in a centralized configuration table, not hard-coded. A sample configuration (values are placeholders, not actual billing rules):
model_multiplier:fast_model: 1.0standard_model: 2.5reasoning_model: 4.0
5.2 Usage Budgets
Set quota limits per user, team, or functional module. When approaching the limit, send notifications; when exceeding the limit, automatically switch to a lower-multiplier model or request user confirmation. Budget checks should be placed in the orchestration layer so all entry points follow the same rules.
5.3 Transparent Display
Show users the consumption multiplier of the model being used, allowing them to weigh quality against cost. Transparent billing reduces user confusion about quota usage and helps teams adjust routing rules based on real usage data.
Observability
Recommended metrics: invocation success rate, P95 latency per model, retry count, fallback count, average metering cost per task type, and structured output validation failure rate. These metrics directly reflect whether routing strategies are reasonable.
Logs should include request_id, model_id, and task_type to aid in problem diagnosis. Logs must not contain user raw input or sensitive fields, respecting the principle of data minimization.
Compliance Considerations for Generative and Embodied AI Models
When providing generative services to the public in certain jurisdictions, security assessments or algorithm filing may be required according to local regulations. For embodied intelligence models operating on physical devices such as robots, additional attention must be paid to device safety, functional safety, and data source compliance.
Key questions to address early in the project:
- Does the service target the public? Does it have public opinion attributes or social mobilization capabilities?
- Does the model process sensitive personal information such as faces or voices?
- Are training data sources traceable, and is the authorization chain complete?
- Are there mechanisms for human review, content filtering, and emergency stop?
- Do filing materials match the deployed model version and service scope?
Implementation Checklist
- Is a unified adapter layer established, with business code decoupled from specific models?
- Does each model have a capability profile and a fixed evaluation set?
- Are routing rules configurable, and are changes recorded?
- Are retry and fallback configured with attempt and timeout limits?
- Are metering multipliers centrally managed and visible to users?
- Are logs properly redacted?
- Is compliance review completed in the early research and development phase, rather than postponed until just before launch?
