How to Build a Controllable Enterprise AI Agent Platform

    This article explains how to build a controllable enterprise AI agent platform by setting the right static architecture from day one. It walks through four key boundaries: a single agent domain model that unifies different agent types through bindings, three separate version tracks for drafts, releases, and sessions, a six-layer one-way dependency structure enforced by a zero-framework compile gate, and a five-level state ID scheme backed by dual aggregate roots. It also covers practical points for local development integration and cost control. Readers will learn how a stable skeleton lets the platform grow thicker over time instead of turning into a swamp.

    How to Build a Controllable Enterprise AI Agent Platform

    Anyone who has run an enterprise platform for more than a year shares a common view: whether a system grows steadily thicker or gets reshaped into a swamp usually has nothing to do with a clever runtime trick. It depends on the static skeleton laid down on day one—how domain entities are modeled, how version evolution is split into tracks, how code module boundaries are welded shut, and how low-level state is separated from the data backbone. Once the skeleton is skewed, every feature added later just amplifies the tilt.

    1. How Requirements Push a Platform Into the Swamp

    By week seven, frontline developers and operations engineers raised a new request. They spend eighty percent of their day writing code and troubleshooting in local development environments. They did not want to be forced to switch to a browser. Instead, they wanted to connect this agent directly from their local coding tools and reuse the company’s controlled operations toolset and code repositories together.

    If the team reacts on autopilot, splitting these requests into four independent product lines and then building four or five disconnected entity tables in the admin console to chase popular concepts—“basic Q&A agent,” “knowledge retrieval agent,” “multi-agent orchestration agent,” “tool service agent”—then within three months four symptoms will inevitably appear: the permission system fractures into three sets, canary rules each go their own way, changing one tool parameter requires syncing four places, and at month-end the model invocation cost simply cannot be reconciled.

    The root cause is clear: these requests are different facets of the same thing in business semantics, yet they were modeled as different things.

    2. The First Boundary: A Single Agent Domain Model

    When many teams design their first core main table, they rush to add a type enum field that splits agents into four categories: Q&A, retrieval, workflow, and multi-agent. This classification looks clean in the prototype stage, but it hits a wall within two weeks of real business—an enterprise business assistant is naturally a cross-type composite.

    Take the most ordinary “production troubleshooting assistant” as an example. An employee asks, “Why did the order service jitter last night?” Its real execution chain is:

    1. Retrieve the incident runbook from the operations knowledge base (retrieval augmentation);
    2. Call the internal APIs of the logging service and monitoring alerts to pull the exception stack (tool invocation);
    3. Discover a slow query is involved, and spawn a database diagnosis sub-agent to investigate concurrently (multi-agent collaboration);
    4. Locate the need to scale up or roll back, and drive a deterministic workflow with supervisor approval according to the company’s change policy (workflow orchestration).

    All four capabilities are indispensable, and their order is decided at runtime. If tables are split by type, which table should this assistant live in?

    The correct approach is to abstract a single entity: agent = identity and permissions + instruction template + knowledge binding + tool binding + sub-agent binding + workflow binding + version pointer. The so-called “form” is just a difference in binding combinations and runtime policy, not a difference in entity. At the storage layer this becomes one main table plus several association tables:

    1. -- Single agent main table, no type enum
    2. CREATE TABLE agent (
    3. agent_id BIGINT PRIMARY KEY,
    4. name VARCHAR(128) NOT NULL,
    5. owner_id BIGINT NOT NULL,
    6. perm_scope JSON NOT NULL, -- permission scope
    7. version_ptr BIGINT NOT NULL, -- points to the active version
    8. status TINYINT NOT NULL
    9. );
    10. -- Unified capability binding table, using kind to distinguish categories rather than entities
    11. CREATE TABLE agent_binding (
    12. agent_id BIGINT NOT NULL,
    13. kind VARCHAR(16) NOT NULL, -- PROMPT/KB/TOOL/SUB_AGENT/FLOW
    14. ref_id BIGINT NOT NULL,
    15. priority INT NOT NULL DEFAULT 0,
    16. PRIMARY KEY (agent_id, kind, ref_id)
    17. );

    The benefit is that permissions, canary rollout, auditing, and billing all revolve around a single subject. Syncing in four places degrades into a change in one place.

    3. The Second Boundary: Three Non-Interfering Version Tracks

    After the single entity, the next problem is evolution. Mixing config versions, release versions, and runtime sessions on one track is the second high-frequency pit: changing a prompt requires a service restart, and rolling back a release interrupts every running session.

    It is recommended to clearly cut three tracks:

    • Draft track: freely editable, supports multi-person collaboration, not visible externally;
    • Release track: immutable snapshots, each release generates a new version number, supports canary and one-click rollback;
    • Session track: records the version snapshot and intermediate state bound to a run, never drifts during runtime.

    The key constraint is that the release track cannot be modified in place. Any change is “new version + canary weight + observation window + full rollout or rollback.” The session track references versions read-only through the version pointer, which ensures that questions like “why did yesterday’s troubleshooting reach a different conclusion” are reproducible and auditable.

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

    Module boundaries cannot be held by human discipline alone; they must be enforced by a gate. A recommended six-layer one-way dependency structure allows upper layers to depend on lower layers, while lower layers are strictly forbidden from referencing back upward:

    1. Access layer: multi-endpoint protocol adaptation, including local development environment access;
    2. Orchestration layer: task planning, sub-agent scheduling, workflow advancement;
    3. Capability layer: retrieval, tool invocation, workflow engine;
    4. Domain layer: models and rules for agents, knowledge, tools, and permissions;
    5. State layer: sessions, memory, checkpoints;
    6. Foundation layer: common capabilities such as storage, message queues, logging services, monitoring alerts, and container platforms.

    A supporting “zero-framework compile gate” applies: the domain layer and state layer must not contain any references to framework or vendor-proprietary types. An illustrative validation rule can be very simple:

    1. def check_no_framework_dep(layer_files):
    2. banned = ("framework", "vendor_sdk", "web")
    3. for f in layer_files:
    4. for imp in parse_imports(f):
    5. assert not imp.startswith(banned), f"Illegal dependency {imp} in {f}"

    The value of this gate is replaceability: access protocols, orchestration frameworks, and underlying cloud resources can all be swapped out while the domain model stays untouched.

    5. The Fourth Boundary: Five-Level State IDs and a Dual Aggregate Root Data Foundation

    State design determines whether the platform can evolve over the long term. A recommended five-level identifier scheme covers tenant, agent version, session, turn, and checkpoint. Any intermediate artifact can be uniquely located, which is the basis for replay and auditing.

    On the data side, adopt dual aggregate roots: a config aggregate root (the agent and its bindings, versions) and a runtime aggregate root (sessions, turns, checkpoints, usage). The two are associated only through version pointers and IDs and do not share a write transaction. This way config changes do not affect running sessions, and usage and cost accounting naturally land on the runtime aggregate root, so month-end reconciliation no longer relies on guesswork.

    6. Local Integration and Cost Control in Practice

    For the request to “connect to the agent directly from a local coding tool,” the practical point is to abstract tool and code repository access into controlled capability APIs, applying unified authentication, parameter validation, auditing, and rate limiting, rather than opening a private channel for each client. Credentials are managed on the platform side and are not persisted on the client.

    Cost control relies on the runtime aggregate root: record input and output usage, tool invocation counts, and retrieval hit counts per session and per turn to form attributable billing dimensions, then layer per-tenant quotas and alerts on top.

    7. Conclusion

    The common logic of the four boundaries is: converge the volatile forms into an invariant entity, and hand the invariant rules to a gate for enforcement. Once this is done, adding a new “popular form” to the platform is just adding a set of bindings and policies, not a new table, a new permission system, or a new canary path. Once the skeleton stands firm, the agent platform grows thicker the more it is used.