How to Build a Controllable and Scalable AI Agent Platform

    This article explains why treating agent types as separate entities is the first major trap when building an AI agent platform, and presents four hard boundaries to set during the static architecture stage: a single agent domain model where capabilities are composable configuration, three independent version tracks for content, capabilities, and runtime, six-layer one-way dependencies enforced by a zero-framework compilation gate, and a five-level state ID scheme backed by a dual-aggregate data foundation. It includes declarative configuration and port definition examples, along with practical guidance on enforcing these boundaries through schema validation, pipeline gates, static checks, and identifier conventions so the platform can add capabilities without fragmenting permissions, cost accounting, or release control.

    1. Why “Classify First” Is the Number One Trap in Agent Platforms

    When many teams build an agent platform, the very first core table they design includes a type enum field that splits capabilities into mutually exclusive categories: chat, retrieval-augmented, workflow orchestration, and multi-agent collaboration. This split looks clean in the prototype stage and neat on the architecture diagram, but within two weeks of entering real business use, it hits a dead end. Assistants inside an enterprise are naturally composites. They simultaneously possess retrieval, tool invocation, collaboration, and workflow progression capabilities, and any single-type label becomes instantly inaccurate.

    Take a common “production troubleshooting assistant” as an example. An employee asks, “Why did the order service fluctuate last night?” The system’s actual chain of actions is as follows. First, it retrieves the incident handbook from the operations knowledge base, which is knowledge recall. Then it calls the internal APIs of the logging service and monitoring alerts to pull exception stacks, which is tool invocation. After discovering a slow query, it spins up a database diagnosis sub-agent for concurrent investigation, which is multi-agent collaboration. Finally, when it determines that scaling or rollback is needed, it must advance a deterministic workflow with supervisor approval according to the company’s change rules. A single question spans four capability forms. If the main table has only one type field, this chain simply cannot be correctly expressed in the system.

    The subsequent evolution is even more troublesome. Once type becomes a first-class citizen, the admin console will keep creating entities around this concept: basic Q&A agents, knowledge base agents, orchestration agents, and tool services, each with its own table and its own set of configurations. Three months later, four systemic problems will inevitably appear: the permission system splits into three mutually incompatible rule sets; canary release rules each go their own way and cannot be observed uniformly; changing a tool parameter requires synchronizing four places; and when reconciling token costs at the end of the month, the accounting standards are inconsistent and the books simply do not balance.

    The conclusion is clear: an agent platform should be made thick, not messy, which means establishing unbreakable hard boundaries at the static skeleton stage. The four boundaries below are, in my view, the most easily overlooked and the most costly.

    2. Hard Boundary One: A Single Agent Domain Model

    The core principle is: type is not an entity; capability is configuration. Only one agent entity exists in the platform. Retrieval, tool invocation, sub-agent collaboration, and deterministic workflows all appear as composable “capability declarations” on that entity, rather than different species in different tables.

    This brings three direct benefits. First, only one permission model is needed, with a single logic for determining a subject’s visibility and executability over an object. Second, canary release and observability standards are unified, so the same identifier can run through release, tracing, and rollback. Third, cost aggregation aligns naturally, because there is only one billing subject.

    In implementation, a declarative structure can describe the capability combination, as shown below:

    1. {
    2. "id": "agent_5f2c",
    3. "name": "Production Troubleshooting Assistant",
    4. "capabilities": [
    5. { "type": "retrieval", "scope": "ops_kb", "top_k": 8 },
    6. { "type": "tool", "ref": "log_query", "timeout_ms": 3000 },
    7. { "type": "sub_agent", "ref": "db_diagnosis", "max_parallel": 3 },
    8. { "type": "workflow", "ref": "change_approval" }
    9. ],
    10. "policy": { "visibility": "internal", "approval": "required_for_write" }
    11. }

    It is important to emphasize that composable capabilities do not mean unconstrained invocation. The platform should define unified timeout, retry, idempotency, and degradation semantics for each type of capability, preventing a fluctuation in one segment of a composite chain from being amplified into overall unavailability.

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

    Agents change frequently, but the nature of the changes is completely different. Mixing prompt adjustments, capability additions and removals, and underlying model replacements on one track means any small change requires full regression. The reasonable approach is to split versions into three tracks: the content track handles prompts and knowledge configuration, the capability track handles tools and workflow orchestration, and the runtime track handles models and inference parameters.

    The three tracks are numbered, released, and rolled back independently, and are aligned through compatibility contracts. The content track can iterate at high frequency and allow canary release to a small traffic share. Capability track changes must pass contract validation to ensure input and output structures do not break existing callers. Runtime track changes must include a baseline comparison of results to prevent hidden quality regression from model replacement.

    The accompanying gates should be written into the pipeline: if a capability track change involves data structures, proof of backward compatibility must be provided; a runtime track change must produce a comparable evaluation report; no track may modify configuration files across tracks, and violations directly block the merge. The value of this boundary is turning “release risk” from uncontrollable into something that can be handled by partition.

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

    As platform complexity rises, the most common corruption is circular dependencies: the domain layer references the infrastructure layer, and the infrastructure layer in turn depends on domain events, until no one dares to touch the core code. The solution is to define a clear six-layer structure and enforce one-way dependencies. From top to bottom, the layers are the access layer, orchestration layer, domain layer, capability adapter layer, infrastructure layer, and observability and governance layer. No lower layer may reference an upper layer.

    The “zero-framework compilation gate” means the domain layer and the capability adapter layer must not depend on a specific inference framework or vendor API, and can only interact through internal abstract ports. This way, replacing the underlying runtime does not require changing business semantics, and it avoids locking the platform into a single technology stack. A sample port definition:

    1. class ModelPort(Protocol):
    2. def complete(self, req: CompletionRequest) -> CompletionResponse: ...
    3. class ToolPort(Protocol):
    4. def invoke(self, ref: str, payload: dict) -> ToolResult: ...

    For gate implementation, static dependency-direction checks and port purity checks can be added during continuous integration. Once an out-of-layer reference or a framework type leaking into the domain layer is found, the build fails directly. This boundary determines whether the platform can still be refactored two years later.

    5. Hard Boundary Four: Five-Level Core State IDs and a Dual-Aggregate Data Foundation

    If the state of an agent runtime is scattered everywhere, troubleshooting and recovery become archaeology. It is advisable to converge on five levels of identifiers: platform ID, agent ID, version ID, session ID, and execution step ID. Each level can be drilled down, so any exception can be located from the session down to the specific step and version.

    The data foundation uses a dual aggregate root: one aggregate root manages the “definition,” meaning what the agent is and which capabilities it has; the other manages the “runtime,” meaning sessions, steps, tool invocations, and consumption records. The two are associated through the version ID. Definition changes do not affect historical runtime facts, and runtime data does not pollute the definition. The reason cost reconciliation often fails is that definition and runtime are mixed in one table, causing the accounting standard to drift with configuration.

    6. Putting the Boundaries into Engineering Practice

    The four boundaries are not document slogans; they need to be turned into executable mechanisms: the domain model is guarded by schema validation, version tracks by pipeline gates, layered dependencies by static checks, and state and data by identifier conventions and aggregate root constraints. If a team uses Baidu AI Cloud or similar general-purpose cloud infrastructure, general-category capabilities such as logging, monitoring alerts, object storage, message queues, and container platforms can be integrated into the observability and governance layer, but port abstraction should be maintained to avoid coupling business semantics with specific implementations.

    By advancing along these four boundaries, adding a new capability to the platform only means adding adapters and configuration, not adding a new species; cost, permissions, and canary release always have only one standard. This is the key to making an agent platform thick rather than messy.