How to Build an Enterprise AI Agent Platform

    Building an enterprise AI agent platform requires more than connecting a model to prompts and knowledge. This article presents a design sequence for a controllable production system: define a unified domain model and runtime boundary first, then design interaction entry points, and finally expand capabilities. It covers a single composable agent entity, separation of the control and execution planes, three independent version tracks, a six-layer unidirectional dependency model, five-level runtime identifiers, dual aggregate roots, tool governance, and a staged minimum closed-loop rollout. The goal is an engineering system that can evolve without turning every new entry point or capability into a separate silo.

    1. Clarify the Goal First: Are You Building an Assistant or a Platform That Can Keep Evolving?

    Building a chat-capable agent is not difficult: connect a model, write prompts, add a set of knowledge materials, and you can usually produce a demonstrable result. But once it must enter an enterprise production environment, the problem changes quickly.

    At first, the business may need only an internal Q&A page. Later, it may want the assistant to be invoked directly from an incident page. After that, the release process may need to request risk assessment through an API, and developers may want to access the same knowledge and operational capabilities from their local development environment.

    On the surface, these requirements correspond to different product forms. In reality, they share a large amount of underlying capability:

    • The same agent definitions and execution policies;
    • The same knowledge permissions and tool authorization;
    • The same run records, audit evidence, and cost allocation;
    • The same version release and rollback mechanisms.

    If every new entry point requires a new agent management system, the platform will eventually become a set of incompatible islands.

    The build order should therefore be: define unified domain objects and runtime boundaries first, then design interaction entry points, and finally expand specific capabilities. Pages, embedded components, business APIs, and development environment connections are delivery methods for platform capabilities, not four independent core systems.

    2. Define Agents by Real Tasks, Not Functional Tags

    1. Why Should Agents Not Be Split into Mutually Exclusive Types?

    A common design divides agents into “Q&A,” “knowledge,” “workflow,” and “collaboration” types. This classification is convenient for presentation, but it is not necessarily suitable as a core data model.

    For example, a user asks: “Why did the response time of the order service suddenly increase last night?”

    An effective troubleshooting process may include:

    1. Retrieve the troubleshooting runbook to understand common causes;
    2. Query monitoring data to identify the abnormal time window;
    3. Fetch relevant logs to identify error patterns;
    4. Call a read-only database diagnostic capability to check slow queries;
    5. Correlate recent change records;
    6. Summarize evidence and provide a judgment and next-step recommendation.

    This process simultaneously involves retrieval, tool calls, step orchestration, and collaboration among specialized capabilities. Forcing it into one type will cause future extensions to repeatedly break existing fields and permission boundaries.

    A more robust approach is: keep only one agent entity and describe its behavior through capability composition.

    2. What Should a Unified Model Express?

    An agent definition can consist of the following parts:

    Component Main Responsibility
    Identity and ownership Specify tenant, business domain, owner, and purpose
    Behavior policy Describe task goals, output requirements, constraints, and failure handling
    Model policy Configure model selection rules, context constraints, and fallback strategy
    Knowledge binding Specify allowed knowledge scope, filters, and citation requirements
    Tool binding Specify tool set, parameter constraints, authorization method, and risk level
    Execution policy Set step budget, timeout, approval nodes, and termination conditions
    Delivery configuration Define allowed access methods and their authentication requirements

    These fields are domain design examples, not the API of any off-the-shelf product.

    Knowledge retrieval should be treated as a capability, workflow orchestration as an execution policy, and multi-agent collaboration as a task delegation relationship. They can coexist and do not need to become mutually exclusive entity categories.

    3. Different Entry Points Must Follow the Same Runtime Contract

    A unified model does not mean all entry points are identical. A browser page may need streaming output, a release process may need structured results, and a local development environment may need to include the current file or error information.

    These differences should remain in the access layer and be normalized into a standard request:

    1. Run request:
    2. caller identity
    3. tenant and business scope
    4. target agent
    5. session identifier
    6. user input
    7. source context
    8. request deduplication identifier

    In particular, source context must not become an authorization basis. An application name, cluster identifier, or ticket number passed in by a page can only be candidate information; the server still needs to verify whether the caller is authorized to access the corresponding resources.

    This avoids security gaps such as “the web entry point checks permissions, but the embedded entry point lets requests through directly.”

    3. Separate the Control Plane from the Execution Plane

    The control plane is responsible for agent creation, configuration validation, approval and publishing, permission management, and version queries. The execution plane is responsible for model calls, knowledge retrieval, tool execution, result aggregation, and run status updates.

    The two have different resource characteristics:

    • The control plane places more emphasis on configuration consistency and the reliability of management operations;
    • The execution plane must handle long-running calls, external failures, traffic fluctuations, and task cancellation;
    • Control plane changes are relatively infrequent, while execution plane requests may remain highly concurrent;
    • The tools and data accessed by the execution plane usually carry higher risk.

    In enterprise scenarios, deploying the two as independent services or processes can reduce fault propagation. However, this is not a prerequisite for every project. A small-scale validation phase can share a deployment unit, but code boundaries, permission boundaries, and state interfaces should be separated early to avoid rewriting core logic when splitting later.

    The execution plane should not read the “latest draft configuration” at every step. Instead, it should obtain a fixed published snapshot when a run starts. If the control plane is briefly unavailable, whether the execution plane can continue processing tasks must be determined jointly by cache strategy, authorization validity period, and security requirements. Expired permissions must not be reused indefinitely in the name of availability.

    4. Establish Three Version Tracks So Different Changes Follow Different Paths

    Putting all changes into a single version number may look simple, but it makes fault localization and rollback difficult. At minimum, distinguish the following three types of versions.

    1. Agent Definition Version

    This track records changes to prompt strategy, knowledge binding, tool binding, execution flow, and output constraints.

    A “draft—validation—publish” process is recommended. Published definitions remain immutable; modifications produce new versions instead of overwriting old records. Once a run starts, the definition version is locked to prevent rules from changing halfway through execution.

    2. Tool and Access Contract Version

    Tool inputs and outputs, error semantics, authentication methods, and invocation protocols are contract changes.

    For example, if a diagnostic tool changes “a single service identifier” to “a list of service identifiers,” compatibility may be affected even if the tool name stays the same. The platform needs to explicitly declare contract versions and validate whether agent bindings meet the requirements.

    Tool versions should not be forced to stay in sync with agent definition versions. Otherwise, an upgrade to a shared tool could force every agent to be republished.

    3. Execution Engine Version

    Task scheduling, step parsing, retry logic, event generation, and state recovery are runtime implementation concerns.

    Even if agent definitions and tool contracts do not change, an execution engine upgrade can still change runtime behavior. Therefore, every run should record the actual engine version to support issue reproduction and canary comparison.

    The three tracks are not unrelated; they are explicitly linked through compatibility rules. The platform can combine agent definitions, tool contracts, and engine versions into a release manifest and validate it before going live.

    Knowledge content and indexes should also record snapshots or revision identifiers. They do not necessarily belong to the three tracks above, but they affect answers and must not be omitted during traceability.

    5. Enforce Six Layers of Unidirectional Dependencies in Code, Not Team Convention

    Boundaries on an architecture diagram are meaningful only when they are enforced in code dependencies and build checks. The following six-layer organization is one possible approach, not the only standard:

    Layer 1: Domain Model

    Define core concepts such as agents, versions, sessions, runs, steps, and tool authorization, and maintain state transitions and business invariants.

    This layer does not depend on network frameworks, database clients, or model service implementations.

    Layer 2: Application Use Cases

    Organize use cases such as publishing an agent, starting a run, canceling a task, and approving an operation. Define the abstract interfaces required for repositories, event publishing, and external capability calls.

    Layer 3: Execution Orchestration

    Implement task decomposition, step progression, budget control, failure handling, and recovery logic. It uses model, knowledge, and tool capabilities through abstract interfaces and is not directly bound to specific vendor implementations.

    Layer 4: Capability Adapters

    Convert model calls, retrieval requests, and tool operations into forms accepted by various external systems, and unify timeout, error, and result formats.

    Layer 5: Access Adapters

    Handle page requests, business APIs, embedded components, and development environment connections, completing authentication, request validation, and protocol conversion.

    Layer 6: Bootstrap and Assembly

    Load configuration, connect infrastructure, inject implementations, start processes, and register runtime components.

    Unidirectional dependency means outer layers reference inner-layer definitions, and inner layers do not reference outer-layer implementations in reverse. The domain layer only expresses “run state needs to be saved”; it should not know which database is used underneath.

    How to Set a Zero-Framework Compile Gate?

    For the domain layer and application modules that should remain pure, framework dependencies can be restricted at build time:

    • Prohibit network handling frameworks;
    • Prohibit direct use of database access implementations;
    • Prohibit references to specific model invocation clients;
    • Prohibit requiring a global runtime environment to execute unit tests.

    “Zero framework” here applies to core modules, not to the entire system. The goal is to let core rules compile and be tested independently, preventing technical implementation details from gradually leaking into the business model.

    6. Design Five-Level Core State Identifiers to Establish a Traceable Run Mainline

    An agent is not a simple API call. A session may produce multiple runs, a run contains multiple steps, and a step may trigger multiple external calls.

    The following five-level identifiers can be used:

    1. agent_id Agent identity
    2. session_id Session identity
    3. run_id Single task run
    4. step_id Logical step within a run
    5. invocation_id Single external call attempt

    Tenant identifiers, published versions, and trace identifiers still need to be retained, but they serve different purposes and should not all be mixed into this hierarchy.

    1. A Session Is Not a Run

    A session organizes continuous interaction; a run represents a task with an explicit start and end. If a user asks consecutive questions in the same session, those questions should produce different run records.

    Session content should not be passed directly and without limit to the model. It must be filtered based on permissions, context capacity, and data sensitivity.

    2. A Step Is Not a Call Attempt

    A logical step may make multiple external calls because of timeouts. The step identity remains stable, while each attempt should have its own invocation identifier.

    This allows the platform to answer two questions at the same time: “Has this logical work been completed?” and “How many attempts did it actually make?”

    3. Retries Are Not Safe by Default

    A network timeout does not mean the external operation was not executed. For write operations such as creating tickets or submitting changes, use business idempotency keys, external result queries, or explicit human confirmation to avoid duplicate execution.

    Invocation identifiers are for tracing, while idempotency keys identify the same business intent. The two cannot be treated as equivalent.

    7. Use Dual Aggregate Roots to Separate Configuration Consistency from Run Consistency

    In domain modeling, an aggregate root is the core object that maintains a consistency boundary for a group of related data. It is not equivalent to a database table.

    A suitable approach for an agent platform is to set up two primary aggregate roots.

    1. Agent Definition Aggregate

    Manage agent identity, drafts, published versions, and binding relationships, focusing on configuration consistency:

    • Invalid tool bindings cannot be published;
    • Definitions that fail validation cannot enter the production environment;
    • Published versions cannot be modified in place;
    • The same publish operation cannot produce conflicting results repeatedly.

    2. Task Run Aggregate

    Manage run state, step progression, cancellation requests, approval status, and final results, focusing on execution consistency:

    • A terminated run cannot be reactivated by an ordinary result callback;
    • The same step cannot be concurrently advanced into contradictory states;
    • Controlled write operations cannot be executed before approval is complete;
    • Duplicate events cannot cause duplicate state transitions.

    Session history, full logs, knowledge body text, and large tool results can be stored separately and associated through identifiers or references. They should not all be packed into the aggregate. Otherwise, every update may involve large objects and increase lock contention and recovery cost.

    The configuration store and run store can first be logically isolated, then physically split depending on scale. Cross-store operations require consideration of event delivery, duplicate consumption, and eventual consistency. Multiple stores must not be assumed to share transactions naturally.

    8. Tool Governance Must Precede Autonomous Execution

    The stronger the tools, the more clearly the agent’s risk boundary must be defined. At minimum, distinguish three types of operations:

    • Read-only operations: retrieve documents, query metrics, read logs;
    • Controlled write operations: create tickets, adjust non-critical configuration;
    • High-risk operations: modify production state, delete data, execute irreversible changes.

    The model can propose operation suggestions, but it cannot decide authorization on its own. Before tool execution, the platform should revalidate caller identity, resource scope, parameter validity, and approval status.

    Model-generated parameters should be treated as untrusted input. They must not be allowed to arbitrarily concatenate query statements, execute commands, or access unregistered targets. Structured parameters, resource allowlists, and server-side validation should be used to narrow the execution scope.

    Knowledge documents and tool returns may also contain induced instructions. External content can only be treated as task data. It must not override system policy, and it must not grant new permissions.

    9. Build the Minimum Closed Loop First, Then Gradually Increase Autonomy

    A reasonable first phase is not to build all entry points and all tools at once, but to choose a scenario with limited scope and verifiable results.

    Take a production troubleshooting assistant as an example. It can proceed in the following order:

    1. Connect only authorized runbooks and read-only monitoring data;
    2. Require conclusions to include evidence sources and distinguish facts, inferences, and recommendations;
    3. Establish run, step, and invocation records as well as cost allocation;
    4. Complete definition publishing, version rollback, and permission testing;
    5. Add log queries and more business context;
    6. Introduce controlled write operations only after approval and idempotency mechanisms are mature.

    Evaluation should not focus only on whether answers are fluent. It should also cover task completion rate, evidence validity, permission violations, tool selection, parameter correctness, exception recovery, latency, and resource consumption.

    Before launch, prepare normal cases, insufficient-permission cases, missing-data cases, tool-timeout cases, and malicious-input cases. During canary release, keep the run version fixed and clearly define whether old tasks continue, are canceled, or are migrated.

    10. A Real Agent Platform Is a Controllable Engineering System

    The long-term value of an agent platform does not lie in how many feature categories it has or how complete its entry points look. It lies in whether every expansion can still maintain clear boundaries.

    A unified domain model solves capability composition; independent version tracks solve evolution and rollback; unidirectional module dependencies solve code maintainability; layered state identifiers and dual aggregate roots solve traceability and consistency.

    On this foundation, gradually improve permissions, approvals, evaluation, auditing, and cost governance. Only then can an agent grow from a demo that answers questions into a long-term system that can safely participate in enterprise workflows.