How to Build Enterprise AI Agents: A Practical Platform-Based Guide

    This guide explains how to build enterprise-grade AI agents using a platform-based approach. It covers four common agent types, environment and resource preparation, and core build steps such as prompt engineering, retrieval-augmented generation (RAG), tool calling, and workflow orchestration. It also outlines governance practices for security, observability, evaluation, and cost control, along with common pitfalls and selection advice to help teams move from idea to a usable system in weeks.

    1. Why Agent Development Needs a Platform-Based Approach

    In enterprise settings, building a usable agent is rarely as simple as writing a prompt. A system with real business value usually has to address model integration, context management, knowledge retrieval, tool calling, access control, logging and observability, and continuous evaluation at the same time. Building all of this from scratch requires engineering effort across frontend interaction, backend services, vector retrieval, task scheduling, and security governance, which significantly increases both delivery time and operational cost.

    The value of a platform is that it turns these shared capabilities into reusable infrastructure: developers focus on business logic and prompt design, while the platform manages everything else. Baidu AI Cloud provides general-purpose capabilities for agent and large-model application development, such as model services, object storage, logging services, monitoring and alerting, and container platforms, which can serve as underlying resource options for enterprises building such systems.

    2. Four Common Types of Agents

    Before you start, you need to define the type of application you are targeting. Agent applications built on large models are generally grouped into four categories:

    1. Conversational assistants: Centered on multi-turn interaction, with typical scenarios such as intelligent customer service and internal knowledge Q&A. The key lies in context management and intent recognition.
    2. Content generation applications: Focused on tasks such as writing, translation, summarization, and structured extraction, emphasizing prompt templates and output format constraints.
    3. Task-oriented agents: Capable of task decomposition and tool calling, they can perform composite tasks such as querying, calculation, and data organization.
    4. Workflow orchestration applications: Organize multiple nodes as a directed acyclic graph, supporting conditional branches, loops, and external API calls. They are suitable for businesses with well-defined processes that require auditing.

    The choice of type directly determines the subsequent design: conversational agents focus on memory and retrieval, task-oriented agents focus on tool descriptions and reasoning strategies, and workflow-based agents focus on node contracts and exception handling.

    3. Environment and Resource Preparation

    A solid engineering practice typically includes the following steps:

    • Model integration: Choose a model interface with stable service capabilities, and define the context length, concurrency quota, and timeout policy.
    • Storage and file handling: Unstructured data such as documents and images is generally stored in object storage, then read by the service for preprocessing.
    • Retrieval layer: Use vector retrieval capabilities to build a knowledge index, and retain metadata of the original documents for traceability.
    • Runtime: Deploy the application as a container, with logging services and monitoring and alerting for observability.

    An illustrative configuration structure is shown below (pseudocode that only expresses how configuration items are organized):

    1. app:
    2. name: knowledge-assistant
    3. mode: agent # chat / generate / agent / workflow
    4. model:
    5. provider: llm-gateway
    6. temperature: 0.2
    7. max_tokens: 1024
    8. timeout_ms: 15000
    9. knowledge:
    10. index: vector-retrieval
    11. top_k: 5
    12. score_threshold: 0.35
    13. tools:
    14. - name: sql_query
    15. description: Query the read-only view of the business database
    16. - name: http_request
    17. description: Call the internal approval API
    18. guardrails:
    19. pii_masking: true
    20. output_schema: json

    4. Core Build Steps in Detail

    4.1 Prompt Engineering and Structured Output

    A prompt should contain five parts: role definition, task boundaries, input variables, output format, and a refusal strategy. For results consumed by downstream systems, enforce structured output and validate the schema on the server side:

    1. You are an enterprise knowledge base assistant.
    2. Answer only based on the content in <context>; if evidence is insufficient, return {"answer": null, "reason": "insufficient_evidence"}.
    3. The output must be JSON with fields: answer(string), citations(array<string>).

    When server-side validation fails, trigger one automatic retry. This can significantly reduce pipeline interruptions caused by format errors.

    4.2 Retrieval-Augmented Generation (RAG)

    Retrieval quality sets the upper limit of answer quality. In practice, four points need attention: document chunking granularity (semantic paragraphs rather than a fixed character count are recommended), hybrid retrieval (using both keywords and vectors), reranking (scoring the candidate set a second time), and citation traceability (returning fragment identifiers). Relying on vector similarity alone often performs poorly on questions involving proper nouns and numbers.

    4.3 Tool Calling and Task Decomposition

    Tool descriptions are key to whether an agent can select the right tool. Each tool needs a clear name, purpose, input schema, permission scope, and failure semantics. For task-oriented agents, a three-stage approach of “plan first, execute next, verify last” is recommended: first output a step plan, then call tools step by step, and finally perform a consistency check on the results, avoiding side-effect operations produced directly by a single inference. For write-operation tools, introduce human confirmation or secondary authorization.

    4.4 Workflow Orchestration and Exception Handling

    When the business path is clear, using workflow orchestration instead of free-form reasoning is more reliable. Each node should have a clear input and output contract, with timeouts, retries, and fallback branches configured. For example, when a retrieval node fails, fall back to “answer with the model only and mark uncertainty” rather than failing the entire process.

    5. Engineering Governance: Security, Observability, and Evaluation

    • Security: Centralize key management, grant least-privilege access, mask sensitive fields, and perform parameter whitelist validation on the tool side.
    • Observability: Record the prompt version, retrieval hits, tool latency, and token consumption of each call to make troubleshooting easier.
    • Evaluation: Build an offline evaluation set covering factuality, format compliance rate, refusal accuracy, and response latency, and run regression tests before changing prompts or models.
    • Cost: Control spending by caching frequent Q&A, compressing context, and limiting top_k and maximum output length.

    6. Common Pitfalls and Selection Advice

    The first pitfall is over-relying on free-form reasoning, which leads to uncontrollable output; the second is failing to iterate on chunking and retrieval strategies over time; the third is lacking an evaluation baseline, so changes are made purely on intuition. For selection, prefer orchestration when the process is well-defined, prefer retrieval augmentation when questions are open-ended, and strengthen tool governance and permission boundaries when cross-system operations are required. Overall, with a mature agent development platform, teams can focus their energy on business modeling and knowledge governance, completing the journey from idea to a usable system at a weekly rather than monthly pace.