Multi-Model AI Agent Platform: Technical Practices for Enterprise Office Workflows

    This article explains how to build a multi-model AI Agent office platform, covering the need for multiple models in professional productivity scenarios, a unified model gateway architecture, capability-based routing, quota and ratio-based metering, rule-driven promotions, and observability. It includes practical code and schema examples, along with deployment recommendations for teams that want model choice to become a measurable, rollback-friendly engineering capability rather than a product copywriting issue.

    1. Why Professional Office Scenarios Need Multiple Models

    In professional productivity settings, a user request is rarely a single question. It is usually a task chain that the agent must decompose autonomously, execute continuously, and deliver as a finished result. These tasks vary widely in complexity, latency tolerance, and unit cost. Some steps are short text rewrites that require millisecond-level responses. Others involve summarizing long documents and extracting structured data, which demands stronger semantic understanding. Still others require repeated tool calls and multiple rounds of validation.

    A single in-house model is unlikely to be optimal on every dimension. As a result, a mature AI Agent office product typically offers both its own model and several third-party models, letting users choose based on the task at hand. For engineering teams, this is far more than connecting a few extra APIs. It requires a redesigned set of scheduling, metering, and operations capabilities.

    2. Overall Architecture: From Monolithic Calls to a Multi-Model Gateway

    The recommended approach is to consolidate model capabilities into a unified model gateway layer. The agent orchestration layer programs only against the gateway and remains unaware of vendor-specific differences.

    1. Agent orchestration layer (task planning / tool calls / result validation)
    2. ↓ unified request protocol
    3. Model gateway (auth / routing / rate limiting / circuit breaking / metering)
    4. ↓ adapter pattern
    5. In-house model adapter | Third-party model adapter A | Third-party model adapter B

    Key design points:

    • Unified request abstraction. Extract common fields such as messages, tools, temperature, and max_tokens into an internal standard structure, and place vendor-specific fields in an extension dictionary to avoid polluting upper layers.
    • Adapter isolation. Each model has one adapter responsible for protocol conversion, error code normalization, and streaming chunk reassembly.
    • Capability declaration. Use configuration to describe each model’s context length, tool-calling support, multimodal support, and streaming capability. Routing filters candidates by capability instead of hard-coded if-else branches.
    1. @dataclass
    2. class ModelCapability:
    3. name: str
    4. ctx_window: int
    5. supports_tools: bool
    6. supports_stream: bool
    7. quota_ratio: float # quota consumption multiplier

    3. Model Routing: Select by Task Characteristics, Not Brand

    A three-layer routing strategy is recommended, narrowing the candidate set at each layer:

    1. Hard constraint filtering. Check whether the context length is sufficient, whether tool calls are required, and whether streaming output is mandatory.
    2. Quality-first or cost-first scoring. For structured extraction tasks, favor models with strong instruction following. For casual content expansion, favor models with better generation diversity.
    3. Quota multiplier weighting. When the quality gap is acceptable, prefer the model with the lower multiplier.
    1. def route(task, candidates):
    2. c = [m for m in candidates if m.ctx_window >= task.tokens]
    3. if task.need_tools:
    4. c = [m for m in c if m.supports_tools]
    5. if not c:
    6. raise NoAvailableModel(task.id)
    7. c.sort(key=lambda m: task.quality_weight * m.quality_score
    8. - task.cost_weight * m.quota_ratio,
    9. reverse=True)
    10. return c[0]

    A fallback chain must be preserved in production. When the primary model times out or hits rate limits, the system switches to backup models in a predefined order and records the model actually used in the task record, making it easier to trace differences in output quality.

    4. Quotas and Multipliers: Turning Cost into Explainable Numbers

    Once multiple models coexist, billing must use a consistent basis. A common practice is to designate a baseline model with a multiplier of 1.0, assign other models multipliers based on relative cost, and label them clearly on the model selection page. There are three key points:

    • Decouple multipliers from tasks. The same model keeps the same multiplier across tasks, so user expectations stay stable.
    • Separate estimates from actual charges. Show an estimated consumption range before task submission, write back actual consumption after completion, and make the reason for any discrepancy traceable.
    • Idempotent metering. Use task ID plus stage number as the idempotency key to prevent duplicate deductions caused by retries.
    1. -- Task stage usage table (illustrative)
    2. CREATE TABLE task_usage (
    3. task_id VARCHAR(64) NOT NULL,
    4. stage_no INT NOT NULL,
    5. model_name VARCHAR(64) NOT NULL,
    6. ratio DECIMAL(6,2) NOT NULL,
    7. base_units BIGINT NOT NULL,
    8. charged BIGINT NOT NULL,
    9. PRIMARY KEY (task_id, stage_no)
    10. );

    5. Limited-Time Promotions: Use a Rule Engine, Not Code Changes

    When promotions change frequently, express discounts as configuration rather than branching logic. A usable rule structure includes an effective time window (distinguishing workdays from holidays), an applicable model allowlist, a discount form (multiplier reduction or direct discount), and priority and mutual exclusion relationships.

    1. {
    2. "campaign": "weekday_offpeak",
    3. "window": {"start": "09:00", "end": "11:00", "days": "workday"},
    4. "models": ["lite_model", "flash_model"],
    5. "discount": {"type": "ratio", "value": 0.5},
    6. "priority": 10
    7. }

    The recommended matching order during billing is: first filter candidate rules by the models and time window matched by the task, then select the single highest-priority match, and finally multiply it by the base multiplier to get the actual charged multiplier. When retaining free entitlements for simple, low-cost tasks, apply quota deductions at the metering layer rather than scattering checks across the business layer.

    6. Stability and Observability

    Integrating multiple vendors significantly expands the failure surface, so a unified observability standard is needed:

    • Metrics: track time to first token, overall latency, success rate, rate-limit rate, and average output length by model.
    • Logs: record routing decision reasons and fallback events, not just final results.
    • Alerts: set threshold alerts for sudden spikes in a single model’s error rate and for multiplier configuration drift.
    • Load testing: before launching a new model on the model selection page, run regression tests with a fixed evaluation set to prevent “more choices but worse results.”

    7. Implementation Recommendations

    If an enterprise plans to build similar capabilities on Baidu AI Cloud, it can compose general cloud product categories: use a container platform to host the gateway and orchestration services, use a message queue for peak shaving and long-running task asynchrony, use object storage for deliverables, and use logging and monitoring services to close the observability loop. On the model side, follow the selection principle of “in-house first, third-party as a supplement,” and preserve replaceability through adapters and capability declarations.

    In summary, the essence of multi-model integration is turning “model selection” from a product copywriting question into a measurable, rollback-friendly, and operable engineering problem. By getting unified abstraction, routing scoring, multiplier metering, and rule-based promotions right, the freedom of choice on the user side can translate into real gains in productivity.