How to Build a Controllable and Scalable AI Agent Platform

    This article explains how to keep an AI agent platform from fragmenting as feature requests pile up. It introduces four hard boundaries: a single agent domain model with capability plugins, three isolated version tracks (draft, canary, and stable), a six-layer architecture enforced by a zero-framework compile gate, and five core states backed by dual aggregate roots. It also covers a unified tool-calling access pattern for local development environments and ends with a reusable checklist for reviewing platform design.

    1. The Problem: Why “Yes to Everything” Turns a Platform into Chaos

    By week seven of the project, one scenario kept repeating. Frontline developers and operations engineers said that most of their day is spent writing code, reading logs, and debugging inside local IDEs. They did not want to switch to a browser page every time they needed an agent. Instead, they wanted to connect their local AI coding tools directly to internal enterprise agents and reuse controlled operations capabilities and code repositories.

    The request itself is entirely reasonable. The trouble starts when the team reacts on autopilot, translates it into four unrelated product lines, and then creates a set of non-interoperable entities in the backend based on whatever concept is trending: a basic Q&A agent, a retrieval-augmented knowledge base agent, a multi-agent orchestration agent, and a tool service agent. Within three months, four systemic problems are almost guaranteed:

    • Fragmented permissions: each entity maintains its own visibility scope and invocation allowlist, so there is no consistent audit standard.
    • Uncontrolled release rules: canary strategies, rollback methods, and approval flows all go their own way, and the cost of locating a failure rises sharply.
    • Configuration drift across multiple places: a single change to a tool’s parameter schema has to be repeated across several entities and several admin pages, and one missed edit becomes a production incident.
    • Costs that cannot be attributed: invocation chains are scattered across multiple entities and multiple sets of credentials, so at the end of the month the token and compute bills cannot be aligned to teams or business lines.

    The conclusion is clear: the hard part of an agent platform is not having many features, it is having too few boundaries. To make the platform thick without making it messy, you must set non-negotiable hard boundaries at the static skeleton stage.

    2. Hard Boundary One: A Single Agent Domain Model

    The first boundary allows only one agent domain model. All capabilities are attached as capability plugins rather than spawning multiple entity types.

    The core fields of the unified model can be abstracted as: identity, version pointer, capability list, permission scope, state machine, and cost owner. “Knowledge base Q&A,” “tool calling,” and “multi-agent collaboration” are simply different combinations in the capability list, not different entities.

    An illustrative data structure:

    1. {
    2. "agentId": "ag_01",
    3. "versionRef": "v3",
    4. "capabilities": ["retrieval", "tool_call", "orchestration"],
    5. "permissionScope": ["repo:read", "ops:readonly"],
    6. "state": "PUBLISHED",
    7. "costOwner": "team_sre"
    8. }

    The payoff: one set of permissions to maintain, one table to audit, and a single cost attribution field. When a new requirement arrives, what gets extended is the capability plugins and their parameters, not a new entity type, which eliminates model explosion at the root.

    3. Hard Boundary Two: Three Non-Interfering Version Tracks

    The second boundary splits changes into three independent tracks: draft, canary, and stable. The three are isolated in data, separated in approval, and measured with separate metrics.

    • Draft track: for internal trials, allows frequent changes, and does not consume production invocation quota.
    • Canary track: ramps traffic by tenant or user percentage, and must carry a rollback pointer and an observability dashboard.
    • Stable track: serves all production traffic, and any change requires review and a change window.

    The key engineering constraint is that tracks cannot be written across levels: draft content must pass canary validation before it can be promoted to a stable version, and directly overwriting the stable pointer is forbidden. This preserves iteration speed while keeping the blast radius of a production failure within a controllable range.

    4. Hard Boundary Three: Six-Layer One-Way Dependencies and a Zero-Framework Compile Gate

    The third boundary is a layered architecture with a constrained dependency direction. The recommended split is six layers: access, orchestration, capability, model adapter, data, and infrastructure. Dependencies may only flow downward, one direction at a time; any reverse dependency is a violation.

    The enforcement mechanism is a zero-framework compile gate: add static dependency checks to the CI stage, and if a cross-layer reverse reference or a layer-skipping call is detected, the build fails immediately. Illustrative check logic:

    1. ALLOWED = {
    2. "access": {"orchestration"},
    3. "orchestration": {"capability", "model_adapter"},
    4. "capability": {"model_adapter", "data"},
    5. "model_adapter": {"data"},
    6. "data": {"infra"},
    7. "infra": set(),
    8. }
    9. # If layer_a -> layer_b appears and layer_b is not in ALLOWED[layer_a], the gate fails

    The value here is that swapping a model provider, switching the inference runtime, or connecting a new object storage or message queue is confined to a single layer and does not trigger a full-chain regression.

    5. Hard Boundary Four: Five Core State Identifiers and a Dual Aggregate Root Data Foundation

    The fourth boundary addresses the state and data fragmentation caused by having too many entities. Converge to five core state identifiers: draft, pending review, canary, published, and retired, and organize data around dual aggregate roots. The agent aggregate root owns identity and version; the invocation aggregate root owns sessions, metering, and audit.

    • Agent aggregate root: the single write entry point, guaranteeing consistency of the version pointer and permission scope.
    • Invocation aggregate root: records the input summary of each request, the tool call trace, and token and latency metering.

    The two aggregate roots synchronize through events, avoiding tight coupling across aggregates. Cost attribution therefore holds naturally: any invocation can be traced back through the invocation aggregate root to its agent and team ownership.

    6. An Access Pattern for Local Development Scenarios

    Back to the original request: let developers reuse controlled capabilities directly inside local AI coding tools. The recommended engineering approach is to use a standard tool-calling protocol as the unified access surface, wrap internal capabilities such as code repository retrieval, log queries, and change request lookups as tool services, and register them uniformly in the capability layer.

    The key points: describe tool parameters with a structured schema; validate permissions centrally on the gateway side; include all tool invocations in invocation aggregate root metering; and route sensitive operations through approval and a second confirmation. This way local tools, the browser console, and automation pipelines share the same capabilities and governance instead of each building its own.

    7. A Reusable Checklist

    • Is there only one agent domain model, with new requirements served by capability plugins rather than new entities?
    • Are the three version tracks isolated in data, separated in approval, and measured separately?
    • Are there any reverse or layer-skipping dependencies, and does the compile gate actually block them?
    • Are states converged to five, and are the responsibilities of the dual aggregate roots clear?
    • Do permissions, canary, tool parameters, and cost accounting each have exactly one source of truth?

    Hold these four boundaries and the agent platform stays structurally stable even as requirements keep flooding in: extend with plugins, evolve with tracks, ensure quality with gates, and govern with aggregate roots. If you need a ready-to-use managed foundation, you can evaluate the combination of general capabilities from Baidu AI Cloud, such as container platform, log service, monitoring and alerting, and object storage, to carry the layering and metering system described above.