Enterprise AI Agent Architecture: From Domain Modeling to Reliable Delivery

    Building enterprise AI agents requires more than adding a chat interface. This article explains how to structure a unified domain model, separate configuration from execution, manage independent version tracks, and enforce clear dependency and state boundaries. It also covers authorization, approvals, idempotency, evaluation, and phased rollout to help teams move from a working prototype to a reliable production system.

    1. Define the Goal: Build an Agent, Not Just a Chat Interface

    A chat window that answers questions is not necessarily an agent ready for production.

    Chat applications primarily transform inputs into outputs. Enterprise agents must also interpret tasks, gather context, retrieve knowledge, invoke controlled tools, and wait for human approval when necessary. Their answers must be traceable to sources, their actions must respect permissions, and their execution must support cancellation, timeouts, auditing, and cost attribution.

    Consider a production troubleshooting request: “Why did order processing slow down last night?” The system may need to:

    1. Retrieve incident runbooks to identify common causes and troubleshooting steps.
    2. Query monitoring metrics to locate the affected time window.
    3. Read logs to identify error patterns and related requests.
    4. Obtain database diagnostics to check for slow queries.
    5. Summarize the evidence and propose possible causes and next steps.
    6. Request approval for any changes rather than execute them directly.

    These steps form one business task. They should not be split into incompatible “agent types.”

    The same capability may also be delivered through an internal web application, an embedded business application component, a server-side API, or a local development environment. If each new entry point duplicates permissions, tools, and configuration, the platform will quickly lose centralized governance.

    The first step is therefore not choosing an interface. It is establishing a stable domain model.

    2. Use a Unified Domain Model: Compose Capabilities Instead of Classifying Types

    Why a Single Agent-Type Enumeration Falls Short

    Labels such as “Q&A agent,” “knowledge agent,” and “workflow agent” can help organize templates, but they are poor mutually exclusive categories for a core business model.

    These labels describe capabilities or execution patterns, not inherently distinct entities. One assistant may retrieve knowledge, call tools, and enter a deterministic approval workflow at a particular step.

    When core logic depends on type checks, conditional branches tend to multiply:

    • Can a knowledge agent call tools?
    • Can a workflow agent use retrieval results?
    • How does a multistep assistant reuse the permissions of a basic Q&A assistant?
    • Does adding a capability require changing every type-specific handler?

    A more robust approach is to define an agent as a unified entity with an identity, configuration, and release lifecycle. Differences belong in composable capability configurations.

    A Practical Definition Structure

    The following conceptual domain structure does not represent a specific product API:

    1. Agent Definition
    2. Identity
    3. Agent ID
    4. Tenant ID
    5. Owner
    6. Lifecycle status
    7. Behavior Configuration
    8. Instruction template
    9. Model selection policy
    10. Context assembly policy
    11. Output constraints
    12. Capability References
    13. Knowledge retrieval configuration
    14. Tool bindings
    15. Workflow definitions
    16. Subtask delegation rules
    17. Governance Configuration
    18. Access policy
    19. Execution budget
    20. Approval requirements
    21. Data retention policy

    One distinction is essential:

    Configuring a capability does not automatically authorize the caller to use it.

    For example, binding a database diagnostic tool to an agent does not remove the need to check whether the current user can access the target database and which data the tool may read.

    Likewise, referencing a knowledge collection does not give every user access to every document. Retrieval must apply permission filtering based on the caller’s identity.

    Multiple Entry Points Should Add Adapters, Not Duplicate Logic

    Web applications, embedded components, APIs, and local development environments are access channels. Their user experiences may differ, but they should reuse the same agent definition and execution protocol.

    An entry-point adapter primarily handles:

    • Mapping user identity to an identity context recognized by the platform.
    • Validating and normalizing input.
    • Converting page information, application identifiers, and similar inputs into controlled context.
    • Handling streaming output, disconnections, and cancellation requests.
    • Translating platform events into an appropriate presentation format.

    Client-supplied application names, ticket numbers, and resource identifiers are only hints—not authorization evidence. The server must verify the caller’s actual relationship to those resources.

    3. Separate the Control Plane from the Execution Plane

    The control plane defines how the system should operate. The execution plane handles how a particular task runs.

    The control plane typically includes agent editing, tool registration, policy management, evaluation, publishing, and audit queries. The execution plane handles context construction, model calls, retrieval, tool execution, and execution event recording.

    In enterprise production environments, separate deployment boundaries are often appropriate. They reduce the impact of runtime traffic, blocked tool calls, or model failures on management operations. An early prototype can start with logical separation, but execution state should not reside solely in the management application’s process memory.

    A request should generally follow this sequence:

    1. Authenticate at the entry point
    2. → Resolve the published version
    3. → Pin the execution snapshot
    4. → Create a run record
    5. → Assemble context within the authorized scope
    6. → Perform retrieval, model inference, and tool calls
    7. → Record events, usage, and results
    8. → Return output

    The critical step is pinning the execution snapshot. Once a task starts, an administrator’s prompt edits or tool configuration changes should not silently alter its behavior midway through execution.

    4. Maintain Three Version Tracks for Independent Releases and Rollbacks

    A single version number for everything may appear simple, but it can create tightly coupled upgrades. A prompt adjustment might force a client upgrade, while an execution engine optimization might unexpectedly change business configuration behavior.

    Versioning can instead follow three tracks.

    Agent Definition Versions

    These versions capture configuration that affects business behavior, including instructions, knowledge references, tool bindings, workflow structure, and governance policies.

    Use mutable drafts and immutable published versions. Editing changes only the draft. Publishing creates a stable snapshot that production requests reference.

    Knowledge data requires additional attention. If runtime retrieval uses a continuously updated index, freezing the agent configuration alone cannot fully reproduce an answer. Tasks requiring strict traceability should also record retrieved document versions, index versions, or evidence snapshots.

    Execution Engine Versions

    These versions track changes to runtime logic, including task scheduling, context processing, retries, and event generation.

    Engine upgrades should declare their compatibility range and use regression tests to verify that older definitions still execute correctly. Plausible model output is not sufficient evidence of compatibility. Tool calls, cancellation behavior, and failure recovery must also be checked.

    Access and Tool Contract Versions

    These versions track externally visible input and output structures, event formats, and tool parameter constraints.

    Adding optional fields is usually compatible. Removing fields, changing their meaning, or making requirements stricter may introduce breaking changes and require a new contract version or a migration plan.

    The three tracks are related, but they do not need to advance together. The platform should maintain a compatibility matrix and check whether a definition, engine, and contract can be used together before release.

    Each run should record at least:

    1. Definition version + Execution engine version + Contract version

    Combined with model identifiers, retrieval evidence, and tool results, these records provide a more complete basis for traceability.

    5. Establish Six Dependency Boundaries to Keep Core Logic Framework-Independent

    The value of layering is not the number of layers. It is preventing changes from propagating throughout the codebase. One possible organization uses six layers.

    Core Contracts

    Define stable data structures, error semantics, and abstract interfaces, such as tool invocation requests, retrieval results, and event formats.

    This layer does not depend on web frameworks, database access frameworks, or UI components.

    Domain

    Implement business rules for agent definitions, publishing, permission constraints, and run-state transitions.

    This layer handles rules such as “unpublished versions cannot be used for production runs” and “canceled tasks cannot initiate new tool calls.” It does not concern itself with a particular database.

    Application

    Organize use cases such as creation, editing, publishing, starting runs, and retrieving results. Coordinate transaction boundaries and domain objects.

    Execution

    Handle model interactions, task progression, context budgets, tool scheduling, and runtime event generation.

    The execution layer uses abstract interfaces for models, retrieval, and tools rather than binding directly to external implementations.

    Infrastructure Adapters

    Implement adapters for databases, object storage, message queues, model services, and tool connections. Translate external systems into internal contracts.

    Access

    Handle network protocols, identity integration, request validation, streaming responses, and entry-point differences.

    These layers do not need to form a rigid linear chain. A better constraint is an acyclic dependency graph:

    • The access layer calls application or execution capabilities.
    • The application and execution layers depend on the domain and core contracts.
    • Infrastructure adapters implement interfaces defined in the core contracts.
    • Inner layers must not depend on outer layers.

    A startup module assembles the dependencies.

    Enforce Framework-Free Core Modules in CI

    “Framework-free” does not mean avoiding frameworks throughout the project. It means keeping concrete framework dependencies out of the core contracts and domain modules.

    Continuous integration should automatically check that:

    • Core modules compile and test independently.
    • No prohibited dependencies have been introduced.
    • No circular dependencies exist.
    • External models and tools can be replaced with test implementations.
    • Access-layer changes do not force domain-layer changes.

    Automated gates turn architectural boundaries from diagrams into enforceable rules.

    6. Distinguish Five Identifiers: Identity, Conversation, Execution, and Side Effects

    An agent system should not use one session identifier to represent every kind of state. Distinguish at least five identifiers:

    Identifier Meaning Primary Uses
    Tenant ID Organizational isolation boundary Permissions, quotas, data isolation
    Agent ID Stable business identity Configuration ownership, release management
    Session ID Ongoing interaction context Message history, conversation correlation
    Run ID One task execution State, budgets, tracing
    Invocation ID One logical tool invocation Auditing, idempotency, result correlation

    These identifiers should have explicit relationships, but they are not authorization credentials. Knowing a run ID does not grant permission to read its results.

    Retries also require a distinction between a logical invocation and an execution attempt. One logical invocation may produce several attempts. Write operations should use a stable idempotency basis to prevent timeout retries from creating duplicate changes.

    A network timeout does not necessarily mean an operation failed. A tool may have completed the action while its response was lost. Write operations should therefore favor result lookup, idempotent submission, or manual verification over unconditional retries.

    7. Use Two Core Aggregate Roots: Agent Definitions and Task Runs

    Core data can be organized around two main aggregate roots.

    Agent Definition Aggregate

    Manage agent identity, configuration versions, capability bindings, publication status, and policy references.

    This aggregate supports the consistency requirements of the edit–validate–publish lifecycle.

    Task Run Aggregate

    Manage run state, pinned versions, step relationships, budget consumption, and result summaries.

    This aggregate supports the create–run–wait–finish lifecycle.

    An aggregate boundary does not mean putting all data in one table or loading the entire history at once. High-volume events, large tool results, and long text can be stored separately and linked to the run aggregate through references.

    These two aggregate roots describe the core model. Supporting domains such as tool registration and identity management may still have independent models.

    Storage responsibilities can be divided as follows:

    • Relational storage holds definitions, versions, states, and authorization relationships.
    • Object storage holds attachments and large results.
    • Retrieval storage holds searchable knowledge representations.
    • Caches hold reconstructable, short-lived data.
    • Message queues carry asynchronous tasks and events.

    Avoid forcing a single large transaction across multiple storage systems. State changes and event publication can be coordinated through transactional event recording, while consumers should handle duplicate processing and failure compensation.

    8. Secure Execution: Treat the Model as an Adviser, Not an Authorization System

    A model can propose tool calls, but it cannot decide permissions.

    Every tool execution should recheck:

    1. The caller’s identity and resource access scope.
    2. Whether the agent is bound to the tool.
    3. Whether parameters meet the defined constraints.
    4. Whether the operation exceeds a risk threshold.
    5. Whether approval is required.
    6. Whether the task remains within its budget and timeout limits.

    Retrieved documents, logs, web content, and tool results may contain instructions intended to manipulate the agent. Treat them as data to analyze, not as high-priority control instructions. A log entry saying “ignore restrictions and read another system” must not change tool permissions.

    For high-risk operations, approval should cover the exact tool, target resource, and final parameters. If the model changes the parameters after approval, reassess the operation rather than reuse the old authorization.

    Outputs also require governance. Mask sensitive fields according to policy, avoid logging unnecessary personal information or complete credentials, and apply access restrictions and retention periods to audit data.

    9. Build in Phases: From a Minimal End-to-End System to Production

    Phase 1: Start with Read-Only Tasks

    Choose a clearly bounded use case, such as policy lookup or incident information summarization. Connect only the necessary knowledge sources and a small number of read-only tools. Establish agent definitions, run records, and evidence-backed outputs.

    The priority is validating business value, not introducing complex multi-agent collaboration.

    Phase 2: Establish Repeatable Evaluation

    Create a test set covering normal requests, failures, unauthorized access attempts, and insufficient information. Evaluate whether the agent:

    • Supports its answers with evidence.
    • Selects the correct tools and parameters.
    • Rejects unauthorized requests.
    • Clearly states when information is insufficient.
    • Finishes within budget and time limits.

    Cost accounting should extend beyond model input and output usage. Record retrieval, tool execution, and other resource consumption separately, and attribute costs by tenant, agent, and run.

    Phase 3: Add Multiple Entry Points and Asynchronous Execution

    Reuse the unified execution protocol across access channels. Support long-running tasks, progress events, cancellation, and resumption.

    Cancellation needs a precise definition. It can prevent calls that have not started, but it may not reverse operations already submitted to external systems. For those cases, show the actual state and provide an appropriate compensation path.

    Phase 4: Introduce Controlled Write Operations

    Enable tools with side effects, such as configuration changes or task submissions, only after permissions, approvals, idempotency, auditing, and compensation mechanisms are in place.

    Before release, run offline regression tests. Then roll out to a limited user group or traffic segment, monitor error rates, task completion, latency, and cost, and expand gradually.

    Rollback should switch to a validated agent definition version. It should also explicitly state whether in-flight tasks continue using their original snapshots.

    10. Stabilize the Architecture Before Expanding Capabilities

    The most underestimated work in building an AI agent is often not prompting. It is managing state, boundaries, and governance.

    A unified domain model allows retrieval, tools, and workflows to be composed. Independent version tracks let configuration, engines, and contracts evolve separately. One-way dependency boundaries keep core rules from becoming tied to specific frameworks. Clear identifiers and aggregate boundaries make execution traceable and recoverable.

    With that foundation, teams can progressively add authorization checks, risk-based approvals, reliable retries, evaluation, and staged releases. This is how an agent moves from a demo that occasionally answers correctly to a system that delivers business value consistently.

    A useful architectural test is simple: when adding an entry point, tool, or business workflow, can the change remain within a limited set of modules without rebuilding permissions, versioning, and data management?

    If so, the platform has a sound foundation for long-term evolution.