How to Build an Enterprise AI Agent Platform: Four Hard Boundaries

    This article explains how to build an enterprise AI agent platform by setting four hard boundaries on day one: a single agent domain model, three version tracks, six-layer one-way dependencies, and five core state identifiers backed by two aggregate roots. It covers why type-enum models fail, how to make candidate and stable versions immutable, how to enforce layer rules at build time, and how to keep permissions and token costs aligned, along with a rollout order and acceptance checklist.

    1. Why Day One Decides Month Three

    Almost every enterprise AI agent platform repeats the same story of scope creep.

    In week 1, the business team wants only an internal web chat entry point that can search policy documents and query runtime logs. By week 3, the monitoring, alerting, and ticketing teams want that entry point embedded in a corner of their existing systems, automatically carrying the current page’s application ID, cluster number, and ticket context when opened. In week 5, the R&D and release-pipeline teams ask for an open API or a local SDK with zero framework intrusion, so they can call the agent for risk assessment at change gates. In week 7, frontline developers and operators want to connect the same controlled operations capabilities and code repositories directly inside their local coding tools, without switching browsers.

    If you react to each request in turn, split the four demands into four separate product lines, and then create a set of disconnected entities in the admin console based on whatever concept is trending — “Q&A agent,” “retrieval agent,” “orchestration agent,” “tool service” — three months later you will face four consequences: the permission model has fractured into several variants, canary strategies each go their own way, every tool parameter change must be synchronized in four places, and month-end token costs cannot be reconciled.

    What determines whether the platform grows thicker or turns into a mess is not a clever runtime trick, but the static skeleton you set on day one: how domain entities are modeled, how version evolution is split into tracks, how module boundaries are locked down, and how underlying state and the data backbone are separated. The following four hard boundaries are reusable engineering solutions.

    2. Hard Boundary 1: One Agent Domain Model, No Type-Enum Forks

    The most common opening mistake is to add a type field to the core main table first:

    1. -- Counter-example: pushing capability differences down into a type enum
    2. CREATE TABLE agent (
    3. id BIGINT PRIMARY KEY,
    4. agent_type VARCHAR(16), -- CHAT | RAG | WORKFLOW | MULTI_AGENT
    5. name VARCHAR(64)
    6. );

    This classification looks clean during prototyping, but hits a dead end within two weeks of real business use: an enterprise business assistant is naturally a composite. It needs to search the policy repository, call ticketing and monitoring tools, break multi-step tasks down by workflow, and, when necessary, dispatch subtasks to dedicated sub-agents. A type enum means these capabilities are mutually exclusive, while reality requires them to stack.

    The right approach is to abstract stable capability dimensions and demote “type” to the result of a configuration combination rather than a basis for classifying the entity:

    1. # Capabilities as configuration, not as a type
    2. agent_spec = {
    3. "id": "agt_01J8...",
    4. "retrieval": {"enabled": True, "knowledge_scope": ["policy", "runbook"]},
    5. "tools": ["incident_query", "change_risk_eval"],
    6. "orchestration": {"mode": "plan_and_execute", "max_depth": 3},
    7. "sub_agents": ["agt_01J9..."],
    8. "guardrails": {"pii_mask": True, "citation_required": True}
    9. }

    The test is simple: when you add a new business form, if all you need is new configuration and a new knowledge scope — no new table, no new enum branch, no new permission code path — the model holds. Conversely, any urge to “just add one more type” is a signal that the skeleton is leaking.

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

    The real complexity of an agent is not “release,” but “multiple versions in use at the same time.” Keep only three tracks, with strictly mutually exclusive semantics:

    • Draft track: the editing state; can be overwritten at will, carries no real traffic, and is not subject to audit trails;
    • Candidate track: can be canaried, A/B tested, and bound to designated groups; behavior is reproducible, configuration cannot be modified in place, and only new versions can be derived;
    • Stable track: serves full traffic; changes must pass through the candidate track, and a rollback pointer is retained.

    The three tracks share the same domain model and the same tool registry; they differ only in three attributes: visibility, mutability, and rollback capability. This avoids copying a set of entities for each environment and avoids canary rules going their own separate ways. In engineering terms, you only need one version table plus a track field and an immutability constraint:

    1. ALTER TABLE agent_version ADD COLUMN track VARCHAR(16)
    2. CHECK (track IN ('draft','candidate','stable'));
    3. -- Candidate and stable tracks forbid in-place updates; only new versions may be inserted
    4. CREATE OR REPLACE FUNCTION forbid_mutable_track()
    5. RETURNS TRIGGER AS $$
    6. BEGIN
    7. IF OLD.track IN ('candidate','stable') THEN
    8. RAISE EXCEPTION 'immutable track: %', OLD.track;
    9. END IF;
    10. RETURN NEW;
    11. END; $$ LANGUAGE plpgsql;

    The accompanying rule: every session must record “track + version number + configuration digest”; otherwise production issues cannot be reproduced and costs cannot be attributed.

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

    Module decay almost always starts with “convenient reverse dependencies”: the tool layer reads the session table directly, and the orchestration layer assembles SQL to query the knowledge base itself. Holding the boundary requires physical constraints, not documentation conventions. Use six layers with one-way dependencies: upper layers may depend on lower layers, and lower layers must not reference upper ones in reverse:

    1. Interface layer: protocol adaptation, authentication entry, rate limiting;
    2. Application layer: use-case orchestration, transaction boundaries;
    3. Agent orchestration layer: planning, task decomposition, sub-agent dispatch;
    4. Capability layer: retrieval, tool invocation, model invocation;
    5. Domain layer: entities, value objects, domain events;
    6. Infrastructure layer: storage, message queues, logging and monitoring adapters.

    The way to enforce this is to put the gate into the build pipeline so violations fail the build, instead of relying on reviewers’ memory:

    1. # Dependency check in the build script (illustrative)
    2. check-layers:
    3. for each module in $(MODULES):
    4. assert imports(module) ⊆ allowed_above(module)
    5. assert no import from domain -> infra
    6. assert no import from capability -> app

    Zero framework intrusion belongs to the same layer of discipline: the open APIs and local SDK offered externally depend only on domain contracts, with no binding to any specific framework annotations or container APIs. This way, pipeline gates, local coding tools, and existing alerting systems can all connect through the same contract instead of each forking its own copy of the logic.

    5. Hard Boundary 4: Five Core State Identifiers and a Two-Aggregate-Root Data Foundation

    Permission fragmentation and unreconcilable costs usually trace back to the absence of a unified identification system. Fix five core identifiers that run through the entire chain:

    • Principal identifier: who is calling (a person, a service account, a pipeline task);
    • Agent identifier: which agent definition;
    • Version identifier: which version on which track;
    • Session identifier: one continuous interaction;
    • Execution identifier: one run within a session, including step and tool-call details.

    On top of this, keep only two aggregate roots: the agent definition aggregate (including versions and configuration) and the run aggregate (including sessions, executions, tool calls, tokens, and latency). The knowledge base, tool registry, and model routing exist only as referenced resources and do not each hold agent state. The direct benefits: a permission decision only needs to answer “whether the principal can see the agent on a given track,” cost aggregation only needs to group by execution identifier, and tool parameters have a single authoritative source.

    For data partitioning, definition data requires strong consistency and immutable history and suits relational storage; run data is high-volume and write-heavy with few reads, so it suits time-based partitioning with archival to object storage; cross-layer events are decoupled through a message queue, and logs and metrics go into a unified logging service and the monitoring and alerting system.

    6. Rollout Order and Acceptance Checklist

    The recommended order is: first define the domain model and the five identifiers, then build the three tracks and the immutability constraint, then add the six-layer dependency gate, and finally connect retrieval, tools, and model routing. At acceptance time, ask yourself each of the following:

    • Does adding a new business form require zero schema changes?
    • Can a candidate version be canaried and rolled back without copying entities?
    • Will reverse dependencies be blocked directly by the build?
    • Can a production incident be fully reproduced from the execution identifier alone?
    • Can month-end costs be reconciled along both the principal and agent dimensions?

    The common logic of the four boundaries is: lock the volatile parts into configuration and versions, and weld the stable parts into the model and dependencies. Once the skeleton holds, whether it is a floating entry point embedded in an existing system, risk assessment at a pipeline gate, or controlled operations inside a local coding tool, each is just a different projection of the same model. To further lower the barrier to building your own, you can build on general-purpose capabilities such as the container platform, object storage, message queue, and monitoring and alerting offered by Baidu AI Cloud to carry the layers above, and focus your effort on domain modeling and boundary governance.