Building an Enterprise AI Agent Platform: Establish the Architecture Skeleton First
Maintaining an enterprise AI agent platform often leads to a tangled mess of fragmented features, permissions, and billing. This article explores how to avoid this pitfall by establishing four hard boundaries in your system architecture from day one: a unified single-agent domain model, three independent version tracks, compile-time layered dependencies, and a five-layer state ID chain with a dual aggregate root data design. By prioritizing a robust skeleton over immediate feature delivery, teams can ensure their agent platform scales healthily and handles requirement creep without chaos.
Building an Enterprise AI Agent Platform: Establish the Architecture Skeleton First
1. Why Most Agent Platforms Get Messy Over Time
Engineers who have maintained enterprise-level foundational platforms for over a year share a common realization: the long-term healthy evolution of a system depends not on a clever runtime optimization, but on the “static skeleton” defined on day one. This includes how domain entities are modeled, how versions evolve, how code module boundaries are drawn, and how underlying data and state are partitioned.
Internal enterprise AI agent platforms almost inevitably experience a suffocating “requirement creep”:
- Week 1: The business team needs a simple web chat window to query internal documentation and check logs.
- Week 3: The monitoring and ticketing team requests a floating entry point within legacy system pages, automatically passing the current error application name, cluster ID, and ticket context.
- Week 5: The CI/CD pipeline team asks for a zero-intrusion SDK or open API to invoke the agent for risk assessment at release gates.
- Week 7: Frontline developers ask: “I spend most of my time writing code and troubleshooting in my local IDE. Can I connect this agent directly to my AI coding tool to reuse our controlled ops tools and code repositories?”
If you tackle these demands reactively, splitting them into four independent product lines and迎合ing popular concepts in the admin backend—creating four or five disconnected entity tables like “Chat Agent,” “Knowledge Base RAG Agent,” “Multi-Agent Orchestration Agent,” and “MCP Tool Service”—disaster will strike within three months:
- The permission system splits into three sets, where the same user has different visibility across different entry points.
- Gray release rules operate independently, requiring changes in four places for a single full rollout.
- Modifying a tool parameter requires syncing across four sides; missing one causes a production incident.
- Token cost accounting at the end of the month fails to reconcile across product lines.
2. First Hard Boundary: Single Agent Domain Model
When designing the first core table, many teams habitually add a type enum:
agent_type ENUM('CHAT', 'RAG', 'WORKFLOW', 'MULTI_AGENT')
This categorization looks clean in wireframes, but running real enterprise business for two weeks reveals a dead end: real enterprise business assistants are inherently cross-type composites.
Consider a typical scenario: an ops troubleshooting assistant needs to search a knowledge base (RAG capability), invoke monitoring query tools (tool calling), orchestrate complex multi-step workflows for tickets (Workflow capability), and even delegate sub-tasks to a specialized log analysis sub-agent (Multi-Agent capability). Which category does it belong to? Regardless of your choice, the model contradicts reality.
The correct approach is to abandon “type-based table splitting” and return to the essence of domain modeling:
- The agent is a unified aggregate root, carrying stable attributes like identity, ownership, permissions, quotas, and lifecycle.
- Capabilities are composable parts: Knowledge base binding, tool mounting, orchestration flows, and sub-agent references exist as components of the agent, not as its “type”.
- The standard: “Type” answers “what it is”, while “composition” answers “what it can do”. For enterprise agents, the answer to “what it is” is always singular—it is an agent. What it can do is continuously layered based on requirements.
With this modeling approach, adding context injection in Week 3 or IDE integration in Week 7 simply expands access methods and capability combinations on the same entity, without requiring a new table or a new permission system.
3. Second Hard Boundary: Three Independent Version Tracks
The biggest difference between an agent platform and a standard business system is that most of its “logic” lives in configuration, not code—prompts, model selection, knowledge bases, tool lists, and orchestration flows. This means version management must be designed across three independent tracks:
- Configuration Track: Every prompt modification or tool addition generates an immutable configuration snapshot, supporting rollback and diffing.
- Release Track: The “published version” for end-users is strictly isolated from editing drafts. A publish action corresponds to an approval and a gray release.
- Runtime Track: Every actual conversation execution precisely records the active configuration snapshot ID, ensuring that any online behavior is reproducible and auditable.
The three tracks serve distinct purposes: the configuration track manages “what changed”, the release track manages “who uses which version”, and the runtime track manages “what actually ran at the time”. Missing any one leads to the awkward situation where a user reports an incorrect result, but you have no idea which version of the prompt they were actually running.
4. Third Hard Boundary: Layered Dependencies and Compile-Time Guardrails
At the code level, we adopt a six-layer unidirectional dependency structure: from the Access Layer (Web, Open API, SDK, IDE plugins unified gateway) → Application Layer (use case orchestration) → Domain Layer (agent aggregate root and domain services) → Capability Layer (RAG, tool calling, orchestration engine implementations) → Infrastructure Layer (storage, messaging, model invocation) → Common Layer. Dependencies must only point inwards and downwards; reverse references and cross-layer jumps are prohibited.
The key is that this rule cannot rely solely on verbal agreements during code reviews; it must be enforced as a compile-time guardrail. Using modular build tools’ dependency declarations or static analysis plugins, any reference violating the layered direction should cause a compilation failure. Human agreements dilute as teams grow; compiler errors do not.
Similarly, “zero-framework intrusion” must be enforced through guardrails. Externally provided SDKs must be decoupled from specific Web or RPC frameworks, relying only on abstract interfaces. Consumers should make thin adapters in their own tech stacks. Otherwise, if the platform upgrades its framework version, all integrated parties are forced to upgrade, destroying the platform’s nature as a “common foundation”.
5. Fourth Hard Boundary: Five-Layer State ID Chain and Dual Aggregate Root Data Base
A single agent execution goes through multiple stages: Agent Configuration → Session → Message → Run/Step → Event. If you store this in a single wide table, rewriting everything will be necessary when implementing step-by-step replay, tool call auditing, or token cost allocation.
Our approach is designing a five-layer core state ID chain: agent_id → session_id → message_id → run_id → event_id. Each layer is independently addressable, and upper-layer changes do not affect lower-layer history. Any log or cost can be traced up this chain to the specific agent and configuration version.
At the data level, we use a dual aggregate root design:
- Agent Aggregate Root: Manages definition-state data—configuration, versions, permissions, release status.
- Session Aggregate Root: Manages runtime-state data—messages, steps, events, costs.
Definition state and runtime state have completely different requirements for storage, scaling, and backup strategies. Definition state has a small volume but requires high consistency, making it suitable for strongly consistent relational storage. Runtime state has a high write volume and is append-heavy, making it suitable for time-partitioned wide tables or time-series storage. The two are linked by agent_id + configuration_version_id, physically ensuring that “modifying configurations” never breaks “historical sessions”.
6. Tying the Skeleton Together
Looking back at the four requirement creeps from the beginning, see how they transform under the correct skeleton:
- Week 1 chat window: A new Web channel is added to the Access Layer; the domain model remains untouched.
- Week 3 floating context entry: The Access Layer gets a new embedded mode + context passthrough protocol; permissions still use the same system.
- Week 5 SDK and Open API: Two new implementations in the Access Layer; dependency guardrails ensure zero intrusion.
- Week 7 local IDE integration: Essentially a new channel, reusing the exact same tool registry and authentication system.
Four requirements, zero entity splits. Token costs automatically aggregate along the five-layer ID chain. There is only one permission system, and gray releases happen on a single release track.
7. Advice for Starting Teams
If you are preparing to build your own AI agent platform, consider landing it in this order:
- Draw the domain model first. Ensure the agent is the sole aggregate root, with capabilities driven by composition, not categorization.
- Implement version tracks on day one. Even if the implementation is rudimentary, the cost of retrofitting it later is extremely high.
- Delegate dependency direction to the compiler, not documentation. Add guardrails as early as possible.
- Define the state ID chain and dual aggregate root structure first. Storage choices can be swapped later, but the chain design cannot be retrofitted.
Whether your platform “grows thicker and more robust” does not depend on how many new concepts you chase, but on how early and how rigidly you establish the skeleton. Weld these four boundaries shut first, then talk about features. That is the correct way for an enterprise-level agent platform to be born.
