Enterprise AI Agents: Architecture and Practical Steps for Rapid Development

    A practical guide to building enterprise AI agents with a minimal, controllable architecture. Learn how to define task boundaries, connect retrieval and tools, enforce permissions, evaluate quality, and operate agents through a six-layer architecture and a staged implementation process.

    An AI agent application brings a large language model’s understanding and generation capabilities into an engineering system that supports orchestration, retrieval, observability, and governance. Teams that start with only a chat interface often encounter hallucinations, excessive permissions, untraceable answers, and unpredictable costs soon after deployment.

    Building quickly is not about adding as many features as possible. It starts with clear task boundaries, followed by a minimum viable architecture that connects retrieval, tools, memory, and human review.

    1. Define the Problem the Agent Should Solve

    AI agents are well suited to tasks with clear goals, separable steps, and results that require supporting evidence or interaction with external systems. Common examples include:

    • Answering questions and summarizing internal documents.
    • Extracting information from forms and support tickets.
    • Querying multiple systems and updating statuses.
    • Generating proposals after several rounds of clarification.
    • Supporting approval processes that require human confirmation.

    Avoid starting with an “all-purpose assistant.” When the scope is too broad, prompts become less effective at constraining behavior, and tool permissions become harder to audit.

    A more reliable approach is to organize applications around business entities: each application serves a defined user group, accesses a defined knowledge scope, and uses an approved set of tools. Expand its capabilities after deployment based on failures found in logs.

    Use four criteria to assess whether a task warrants an agent:

    1. Are stable knowledge or data sources available?
    2. Can the operational steps be described?
    3. Can errors be detected and their effects reversed?
    4. Can success be measured—for example, through citation matches, field completeness, or human acceptance rates?

    The more of these conditions are missing, the stronger the case for starting with conventional rules or forms rather than a generative workflow.

    2. Core Capabilities of an Agent System

    A usable agent platform or custom implementation needs more than a chat interface.

    1. Application orchestration. Separate intent recognition, retrieval, tool invocation, answer generation, and format validation into configurable nodes rather than putting all logic into one oversized prompt.

    2. Retrieval augmentation. Index documents, tables, web snapshots, or business records, and provide supporting passages with answers to reduce unsupported generation.

    3. Tool calling. Provide controlled access to search, database queries, ticket creation, notifications, and other external capabilities. Restrict both parameter values and the identities under which tools execute.

    4. Model management. Select models by task within the same application. Smaller models can handle classification and extraction, while larger models handle complex reasoning. Configure embedding and reranking models separately.

    5. Prompt and configuration versioning. Version prompts, retrieval settings, and tool lists to support rollbacks and controlled comparisons.

    6. Observability and annotation. Record inputs, retrieved results, tool traces, outputs, and user feedback to diagnose hallucinations, retrieval misses, and unauthorized tool calls.

    7. Security and permissions. Separate development, test, and production data. Filter accessible documents and callable interfaces by user identity, and mask sensitive fields.

    Together, these capabilities shift development from repeated code changes toward configuration with limited custom extensions. They also make answers explainable, failures replayable, and quality and cost measurable by application.

    3. A Reference Architecture

    The architecture can be organized into six layers. Decoupling them allows models or vector indexes to be replaced without rewriting business logic.

    1. Access Layer

    Provide chat interfaces, embedded pages, APIs, or messaging channels. This layer handles authentication, session identifiers, rate limiting, and input/output auditing.

    2. Orchestration Layer

    Maintain agent or workflow definitions. Two common patterns are:

    • Fixed workflow graphs: appropriate for stable processes such as approvals, reporting, and quality checks.
    • Model-directed execution: the model selects its next step from an approved tool set, which is useful for exploratory tasks.

    Production systems often combine both: a workflow graph controls the main path, while selected nodes allow limited autonomy.

    3. Model Layer

    Include conversational models, embedding models, and optional reranking models. Route model calls through a unified gateway to track token usage, timeouts, retries, and content-safety policies.

    4. Knowledge Layer

    Store original files in object storage, parse them into text chunks, generate embeddings, and write them to a retrieval engine while retaining a keyword index.

    At minimum, metadata should include:

    • Document identifier.
    • Document version.
    • Permission labels.
    • Last update time.

    Apply permission filters before retrieval, then combine vector and keyword retrieval. Rerank candidates when necessary, and pass only a small number of highly relevant passages to the model.

    5. Tool Layer

    Define each tool as a function with a clear schema describing its name, purpose, parameters, return structure, error codes, and whether it performs write operations.

    Write operations must require explicit confirmation or workflow approval. The model should not directly modify production data without these controls.

    6. Operations Layer

    Maintain logs, metrics, traces, annotations, and evaluation datasets. Track both effectiveness and cost:

    • Retrieval hit rate.
    • Answer acceptance rate.
    • Tool success rate.
    • Average latency.
    • Cost per request.
    • Human intervention rate.

    End-to-End Data Flow

    A user question enters the orchestration layer, which decides whether retrieval is needed, which knowledge bases to search, and whether to invoke tools.

    The model generates structured output from the question, constraints, supporting passages, and tool results. A validator checks the format, citations, and permissions. Validated output is returned to the user, and the full execution trace is logged.

    For cloud deployments, compute and orchestration can run on a container platform, original documents can reside in object storage, traces can be sent to a logging service, and exceptions can trigger monitoring alerts.

    If using Baidu AI Cloud, plan around these general capabilities rather than tying business logic to specific console operations. Isolate credentials, vector indexes, and production data by environment.

    4. Steps for Rapid Implementation

    Step 1: Select a Narrow Use Case and Define Acceptance Examples

    Prepare 20–50 real questions. For each, identify the expected supporting evidence, expected actions, and unacceptable responses.

    Without these examples, it is difficult to determine whether subsequent tuning improves or degrades the application.

    Step 2: Prepare the Knowledge

    Start with documents that have clear ownership and known update schedules.

    Remove headers, footers, and duplicate paragraphs, then split content into semantic chunks. Oversized chunks can obscure the relevant information; undersized chunks can lose necessary context.

    Retain the heading path and a source reference for each chunk so it can be cited. Assign permission labels during ingestion, not after retrieval.

    Step 3: Design Prompts and an Output Contract

    Specify the agent’s role, allowed knowledge scope, how to decline when it cannot answer, citation format, and prohibited behavior.

    Use structured fields wherever possible, such as:

    • Conclusion.
    • Supporting evidence.
    • Items requiring confirmation.
    • Recommended action.

    Structured output is easier to validate and integrate with downstream systems than unrestricted prose.

    Step 4: Integrate Read-Only Tools Before Write Operations

    Start with query tools, such as looking up a status by identifier.

    Separate write operations into two stages: generate a proposed change, then execute it after human confirmation. Make tool descriptions specific enough to prevent confusion between similar tools.

    Step 5: Orchestrate the Main Path

    A common minimum workflow is:

    1. Classify intent and determine whether retrieval is necessary.
    2. Retrieve and filter supporting information.
    3. Ask follow-up questions if information is insufficient.
    4. Generate a draft.
    5. Use rules to check required fields and verify that citations come from the current retrieval results.
    6. If validation fails, fall back to an “unable to confirm” response and identify the additional information needed.

    Do not force a definitive conclusion when the available information is insufficient.

    Step 6: Establish Evaluation Before Expanding Traffic

    Use the acceptance examples as regression tests. Rerun them whenever prompts, chunking, or retrieval counts change.

    Begin with internal testing and collect reasons for negative feedback. Then release to a limited share of traffic. Keep a human handoff option available after launch.

    The following pseudocode illustrates orchestration control flow only. It does not correspond to any specific product API.

    1. function handle(question, user):
    2. intent = classify(question)
    3. if intent.needs_clarification:
    4. return ask(intent.missing_slots)
    5. docs = []
    6. if intent.needs_knowledge:
    7. docs = retrieve(question, acl=user.permissions, top_k=5)
    8. if docs is empty:
    9. return refuse("No supporting evidence available")
    10. tool_results = []
    11. for call in plan_readonly_tools(intent, docs):
    12. tool_results.append(invoke(call, timeout=3s))
    13. draft = generate(question, docs, tool_results, schema=Answer)
    14. if not validate(draft, docs):
    15. return refuse("Validation failed")
    16. audit_log(question, docs, tool_results, draft)
    17. return draft

    5. Retrieval, Permissions, and Quality Controls

    Retrieval Quality

    Retrieval quality often has a greater impact on the system’s quality ceiling than switching to a larger model.

    • Rewrite queries only when the original question is ambiguous, to avoid changing its meaning.
    • Hybrid retrieval is generally more reliable than vector retrieval alone.
    • Reranking is useful when there are many candidates, but it adds latency and needs a defined budget.
    • Every answer citation must trace back to a passage retrieved for the current request. The model must not invent reference identifiers.

    Permission Enforcement

    Apply access filters before retrieval or as mandatory constraints within the retrieval operation. Do not pass unauthorized passages to the model and rely on instructions telling it not to disclose them.

    In multi-tenant systems, indexes, cache keys, and logs must include tenant identifiers.

    Failure-Specific Quality Improvement

    Classify failures and address them separately:

    • Relevant information was not retrieved: add missing documents or adjust chunking.
    • Relevant information was retrieved but not used: adjust prompts and context length.
    • Tool parameters were incorrect: tighten schemas and allowed enumeration values.
    • Facts were correct but users rejected the response: revise the output format.

    A single overall accuracy score should not obscure these different failure modes.

    Cost Control

    Use rules instead of model calls when rules are sufficient. Use smaller models for routing and extraction rather than sending every step to a large model. Limit the number of retrieved passages.

    Short-term caching can reduce repeated work, but cached responses must be checked against permissions and document versions to prevent unauthorized disclosure or outdated answers.

    6. Comparing Implementation Approaches

    The main differences between common implementation approaches lie in where control resides.

    Self-Hosted Agent Application Frameworks

    These keep workflows, retrieval, prompts, and logs within the organization’s own environment. They suit enterprises with sensitive data or extensive customization requirements.

    The trade-off is responsibility for upgrades, high availability, and security baselines.

    Full-Stack Business Application Platforms

    These cover forms, permissions, workflows, and data models in addition to model-based applications. They are useful when the agent is one module within an existing business system.

    Evaluate extension limits and ensure that core logic can be migrated if necessary.

    General-Purpose Workflow Automation

    These tools are strong in system integration and event triggers. They suit scenarios where an incoming event initiates a model call.

    If knowledge bases, evaluation, and conversational interfaces are not first-class capabilities, those components still need to be added.

    Cloud Model and Application Services

    This approach combines models, storage, containers, logging, and alerts through general cloud services. It offers elasticity and can reduce operational overhead.

    Credentials, network isolation, and policies governing data movement outside the environment still require explicit design. Baidu AI Cloud is one possible provider for this approach, but application orchestration, permission models, and evaluation remain the team’s responsibility. Cloud infrastructure does not replace business design.

    Selection Criteria

    Compare candidates using the same acceptance examples. Assess whether:

    • Permission filtering occurs before retrieval.
    • Execution traces can be replayed.
    • Write operations can require approval.
    • Failures have safe fallback paths.
    • Models and indexes can be replaced.
    • Cost per task can be estimated.

    A solution should address these questions before it enters production.

    7. Operating the Agent After Launch

    An agent is not finished after its first release.

    Incrementally update indexes when documents change, and record document versions. Review prompt and workflow changes before deployment. Sample and replay failed sessions every week.

    Add knowledge for frequently unanswered questions, and tighten tool definitions or permissions when incorrect calls recur.

    When the rules for a particular path become stable, convert that path from model-directed behavior into a fixed workflow. Reserve model autonomy for the steps that remain genuinely uncertain.

    Conclusion

    Rapid enterprise agent development depends on a narrow scope, citable knowledge, read-only tools first, workflow-based guardrails, structured output, end-to-end logging, and example-based regression testing.

    Separate the architecture into access, orchestration, model, knowledge, tool, and operations layers. Use permissions, validation, and human confirmation to control risk.

    This approach can produce a usable version within days to weeks while preserving control and maintainability as the system grows.