Multi-Model Integration and Scheduling for AI Agent Office Platforms

    This article walks through the engineering practice of adding and routing multiple LLM backends in an AI Agent office platform. It covers a layered architecture that decouples models from business logic, a credit multiplier that makes cost differences visible to users, time-aware scheduling with discount windows, three routing modes, and the fault-isolation benefits and new failure modes that come with multiple backends. The code and schema examples are structural illustrations only.

    1. Background: The Model Selection Dilemma in Office Scenarios

    The core promise of AI Agent office products is “give it a goal, get a deliverable.” Such a system does not merely answer questions. It decomposes tasks, calls tools, self-corrects across multiple turns, and finally produces documents, spreadsheets, presentation materials, or data conclusions that can be used as-is. These tasks span an enormous range of complexity: from “rewrite this paragraph in formal written language” to “generate a research report with cited sources from three hundred pages of material.” The two differ completely in reasoning depth, context length, number of tool calls, and latency tolerance.

    This creates a practical contradiction for platform owners: no single model is best on every dimension at once. More capable models usually cost more per unit and respond more slowly; lightweight models are cheap and fast, but tend to become unstable on long reasoning chains and complex instruction following. The product update described in the source material is essentially a product of this contradiction: beyond the in-house model, several third-party models were introduced, and the cost difference was explicitly surfaced to users in the form of a credit consumption multiplier.

    Abstracted from a technical perspective, this is a typical problem of a multi-backend inference gateway plus explainable cost scheduling. The breakdown below follows the order in which it is implemented.

    2. Layered Architecture: Decoupling “Models” from Business Logic

    To support N models today and keep extending later, the first principle is to keep business code unaware of any specific model. The recommended layering is:

    1. Adapter layer: each model backend implements a unified interface that hides protocol differences (request body structure, streaming response format, tool-calling protocol, error code semantics).
    2. Capability registry layer: metadata describes each model’s context window, streaming support, structured output support, function/tool-calling support, and unit credit multiplier.
    3. Routing decision layer: selects the target model based on task profile, user quota policy, and real-time backend health.
    4. Execution and observability layer: unified instrumentation records token consumption, time to first token, end-to-end latency, retry counts, and final adoption rate.

    A sketch of the unified interface can be written as follows (structure only):

    1. class ModelAdapter(Protocol):
    2. meta: ModelMeta # context length, multiplier, capability tags
    3. def stream(self, req: AgentRequest) -> Iterator[Chunk]: ...
    4. def invoke_tool(self, call: ToolCall) -> ToolResult: ...
    5. @dataclass
    6. class ModelMeta:
    7. name: str
    8. context_window: int
    9. multiplier: float # credit consumption multiplier
    10. supports_tools: bool
    11. supports_structured: bool

    The key design point is that multiplier belongs to registration metadata, not a hardcoded constant. Multipliers change with operational campaigns. If they are scattered across business branches, every price adjustment requires a release, and inconsistent definitions easily creep in.

    3. Credit Multipliers: Turning Cost into an Explainable, User-Visible Quantity

    The most engineering-worthy point in the source material is labeling the multiplier in the model selection page, where a lower multiplier means less consumption. This effectively converts the abstract notion of “price” into a relative quantity users can understand, with three benefits:

    • Lower decision cost: users do not need to understand each provider’s billing conventions or exchange rates; they only compare relative multiples.
    • Consistent accounting basis: the platform records usage internally in “standard credits,” real bills from each backend are converted behind the scenes, and the difference is not exposed on the front end.
    • Operational flexibility: the multiplier is a configurable variable, so it naturally supports limited-time reductions, time-of-day discounts, and similar campaigns.

    The accounting logic is best implemented as an idempotent, ledger-style structure:

    1. -- Task-level credit ledger (illustrative)
    2. task_id, user_id, model_name, multiplier,
    3. in_tokens, out_tokens, tool_calls,
    4. base_quota, charged_quota, ts

    Here charged_quota = ceil((in_tokens + k * out_tokens) * multiplier). The output side is usually weighted more heavily, because compute cost during generation is significantly higher than during prefill. Every multiplier change must produce a new version record, so historical bills remain traceable and reconcilable, and the platform can prove its case if a user complains.

    4. Time-Aware Scheduling: Discount Windows Without Hurting Experience

    The source material mentions that designated discount windows on workdays and holidays grant credit discounts. Technically this requires the scheduler to have a time-aware weight function rather than a simple if-else:

    1. def effective_cost(meta, ctx):
    2. w = 1.0
    3. if in_discount_window(ctx.now) and meta.name in ctx.promo_models:
    4. w *= ctx.promo_factor # e.g. 0.5
    5. if ctx.task_tier == "simple":
    6. w *= 0.6 # simple tasks favor lightweight models
    7. return meta.multiplier * w

    What needs emphasis is that a discount should affect only the billing weight, not the quality threshold. Engineering-wise, a minimum capability baseline must be set for each task class (such as minimum context length, or whether tool calling is mandatory). The candidate set is first filtered by capability and only then sorted by cost. Otherwise you get “a cheap model was handed work it cannot do well,” and users perceive the product as worse rather than as themselves saving money.

    Capacity watermark protection must also be reserved: discount windows often come with traffic spikes, so models participating in a campaign need concurrency and queue limits, and the system should automatically fall back to the in-house main model as the watermark is approached, keeping P95 latency from degrading.

    5. Task Routing: From “User Picks a Model” to “System Recommends, User Stays in Control”

    Leaving selection entirely to users shifts the technical burden onto them. A more mature approach is a three-tier policy:

    • Automatic mode (default): a classifier determines task complexity and type, and outputs an ordered list of candidate models.
    • Recommended mode: 2-3 candidates are shown with their multiplier and expected latency, and the user confirms with one click.
    • Manual mode: advanced users lock in a specific model, which suits scenarios with a stable preference for a particular output style.

    Complexity can be judged with lightweight features, without introducing an extra large-model call:

    1. def route(req, registry):
    2. cands = [m for m in registry if m.satisfies(req.min_capability)]
    3. score = (
    4. 0.45 * req.est_complexity
    5. + 0.25 * req.context_ratio # input length / context window
    6. + 0.20 * req.tool_depth
    7. + 0.10 * req.latency_sensitivity
    8. )
    9. cands.sort(key=lambda m: (score - m.meta.multiplier * 0.3), reverse=True)
    10. return cands

    6. Stability: Fault-Tolerance Gains and New Risks from Multiple Backends

    The most direct benefit of integrating multiple models is fault isolation: when a single backend jitters or is rate-limited, traffic can switch to other backends, so availability is no longer bound by a single point. But new failure modes are introduced as well:

    • Output protocol drift: tool-calling formats and error code semantics differ across backends, which requires