Multi-Model Architecture for Enterprise AI Agents: Routing, Governance, and Evaluation
This article explains how to build an office AI agent that supports multiple LLM models without sacrificing quality, latency, or cost. It covers a four-layer architecture (access, routing, execution, and governance), a tiered task classification (L1/L2/L3), hard versus soft routing constraints, incremental delivery with a plan-solve-verify loop for complex tasks, three-dimensional enterprise authorization and quota control, invocation logging for cost attribution, and a dual-track offline evaluation plus online canary strategy. Code samples and a log table schema are included, along with common pitfalls to avoid.
1. Why Office Agents Need Multiple Models
As office scenarios move from single-turn Q&A to multi-step task execution, no single model can balance quality, latency, and cost at the same time. The source material describes an office agent platform that integrated ten models at once and exposed model selection to both personal and enterprise standard users. The reason was straightforward: users had noticed that different models differed significantly in task complexity handling, output quality, response speed, and cost.
Abstracted from an engineering perspective, this is a classic problem of model capability tiering and routing. Office tasks can be roughly divided into three layers:
- L1 lightweight layer: copywriting, information extraction, content organization, format conversion. Short context, shallow logic, high call frequency, and extreme sensitivity to unit cost.
- L2 rule layer: rule consolidation, solution review, simulated walkthroughs, structured presentation. Many constraints, requires stable instruction following, and values consistency over creativity.
- L3 complex layer: multi-step reasoning, operations modeling, constraint solving, agent orchestration. Long chains, requires autonomous planning and continuous iteration, and demands the highest model ceiling.
The original text notes that in multi-step complex reasoning tasks, a new generation of foundation models with a “continuous delivery mechanism” can first produce a usable first version, then expand it version by version based on feedback, modeling, solving, and verifying around complex goals and constraints, and autonomously orchestrating agents to complete tasks such as site design and resource scheduling. Technically, this description maps to two general capabilities: incremental delivery and a plan-solve-verify loop.
2. Target Architecture: Access, Routing, Execution, and Governance
An enterprise office agent platform with freely switchable models should be split into four layers:
- Model access layer: hides differences between models behind a unified abstraction and exposes only a consistent invocation contract.
- Routing decision layer: decides which model tier a request lands on, based on task labels, budget, latency, and permissions.
- Execution orchestration layer: handles task decomposition, tool calls, result validation, and retries.
- Governance and observability layer: handles permissions, quotas, auditing, and cost and quality monitoring.
The key design of the access layer is a “minimal common capability set.” Do not try to abstract every proprietary feature of every model; keep only the general semantics widely accepted across the industry:
from dataclasses import dataclassfrom typing import List, Dict, Optional@dataclassclass ChatMessage:role: str # system / user / assistant / toolcontent: str@dataclassclass ModelSpec:name: strtier: str # L1 / L2 / L3max_context: intsupports_tools: boolsupports_stream: boolprice_weight: float # relative cost weight, configured on the platform sidelatency_weight: floatclass ModelAdapter:"""Unified invocation contract that hides model differences"""def chat(self,model: ModelSpec,messages: List[ChatMessage],tools: Optional[List[Dict]] = None,stream: bool = False):raise NotImplementedError
3. Routing Strategy: From Manual Selection to Automatic Recommendation
The product form in the original text hands selection to users while allowing administrators to configure model permissions by department, user group, or member. In engineering terms, this becomes a tiered routing chain:
def route(task, user, policy) -> ModelSpec:# 1) Hard permission constraints first: admin policy cannot be overriddenallowed = policy.allowed_models(user)candidates = [m for m in REGISTRY.values() if m.name in allowed]# 2) Task tieringtier = classify(task) # L1 / L2 / L3# 3) Budget and latency soft constraintsbudget = policy.budget(user)candidates = [m for m in candidates if m.price_weight <= budget]candidates.sort(key=lambda m: (m.tier != tier, m.latency_weight))return candidates[0]
Three practical points:
- Separate hard and soft constraints. Permissions, compliance, and data residency are hard constraints and non-negotiable; cost and latency are soft constraints that can float within thresholds.
- Automatic by default, manual when needed. Most users do not need to understand model differences, so the platform should recommend a tier while keeping a manual override entry point.
- Fallback chain. When the preferred model times out or is rate limited, fall back in order within the same tier or one tier down, so tasks do not fail outright.
4. Complex Tasks: Incremental Delivery and a Solving Loop
L3 tasks cannot be completed with a single generation. A practical orchestration pattern is “first version, review, expand”:
def solve_complex(goal, constraints, adapter, model):draft = adapter.chat(model, [ChatMessage("user", goal)])for round in range(MAX_ROUNDS):review = adapter.chat(model, [ChatMessage("user", f"Goal:{goal}\nConstraints:{constraints}\nDraft:{draft}\nPoint out where constraints are not met and give revision suggestions")])if passed(review, constraints):breakdraft = adapter.chat(model, [ChatMessage("user", f"Revise based on the review:{review}")])return draft, verify(draft, constraints)
The core idea here is decoupling generation from verification. The verifier can be a rule engine, unit tests, schema validation, or a separate checking model. Only artifacts that pass verification enter the delivery flow, which is more controllable than simply chasing single-shot generation quality.
5. Enterprise Governance: Permissions, Quotas, and Cost Attribution
For enterprise users, model management permissions are a hard requirement. A three-dimensional authorization model is recommended:
- Dimensions: department / user group / individual, with precedence overriding from specific to broad.
- Capabilities: list of available models, whether manual switching is allowed, whether tool calls are allowed, and per-call context limit.
- Quotas: request counts, token budgets, and cost caps per time window; exceeding a limit triggers degradation rather than outright rejection.
For cost attribution, every call should record user_id / dept / task_tier / model / tokens / latency / status, forming an auditable invocation trail. Example table structure:
CREATE TABLE model_invocation_log (id BIGINT PRIMARY KEY,user_id VARCHAR(64),dept VARCHAR(64),task_tier VARCHAR(8),model_name VARCHAR(64),in_tokens INT,out_tokens INT,latency_ms INT,status VARCHAR(16),created_at TIMESTAMP);
With this trail in place, three management questions can be answered: which department consumes the most, which model tier is being misused on high-cost tasks, and which task types have the highest rework rate.
6. Evaluation: Do Not Rely on Subjective Feel
Once multiple models coexist, the biggest risk is “choosing by gut feeling.” A dual track of an offline evaluation set plus online canary is recommended:
- Offline evaluation set: fixed samples prepared per L1/L2/L3 tier, with metrics including task completion rate, constraint satisfaction rate, average rounds, average latency, and unit cost.
- Online canary: new models are first opened to a small-traffic user group and compared against the same-tier baseline; full rollout happens only if metrics do not degrade.
- A/B and rollback: keep the ability to revert to the baseline tier with one action.
A simplified weighted score can drive automatic selection:
score = 0.45 * quality + 0.25 * constraint_pass \+ 0.15 * (1 - norm_latency) + 0.15 * (1 - norm_cost)
Weights should be adjusted per scenario: raise cost and latency weights for L1 scenarios, and raise quality and constraint satisfaction weights for L3 scenarios.
7. Common Pitfalls
- Treating model count as a selling point. More models does not mean a better experience; “multi-model” without routing and governance only drives up cost and amplifies inconsistency.
- Over-abstraction. Trying to unify every proprietary parameter ends up producing an interface that nobody can use well.
- Ignoring verification. Most failures in complex tasks are not failures to generate, but failures to detect problems.
- Missing permissions and quotas. In enterprise scenarios, the absence of organization-level authorization and limits directly leads to uncontrolled asset usage.
- No observability. Without an invocation trail, cost attribution and continuous optimization are impossible.
8. Conclusion
Technically, free model selection turns “the model” from a fixed dependency into a replaceable runtime resource. What determines success is not how many models are integrated, but whether five pieces of infrastructure exist: unified abstraction, tiered routing, a verification loop, permissions and quotas, and observability. If an enterprise wants to build similar capabilities in its own environment, it can use general cloud product capabilities such as the container platform, message queue, object storage, and log monitoring offered by Baidu AI Cloud as the foundation, and treat model invocation as a pluggable component within a unified governance system, achieving a sustainable balance among quality, latency, and cost.
