Building AI Agents Fast: From Prototype to Production
This article explains why building AI agents requires a platform approach rather than starting from scratch, and breaks down the core capability layers of a low-code agent platform: model management, retrieval-augmented generation, agent and tool calling, and workflow orchestration. It also covers how to choose between chat assistants, text generation, task agents, and workflow applications, followed by a five-step path to production covering requirement scoping, prompt and knowledge design, evaluation, observability and cost control, and security. The key takeaway is that the hard part of building agents has shifted from model integration to engineering organization.
1. Why Agent Development Needs a Platform
Once generative AI moved into the engineering phase, the bottleneck teams run into is no longer “can we call a large language model.” It is “how do we turn one successful conversation into a business capability that can be delivered, operated, and iterated on reliably.” Building a business-facing agent system entirely from scratch usually means taking on several kinds of work at once:
- Interaction layer: building a chat interface or embedding an entry point into an existing business system;
- Service layer: writing backend APIs for session lifecycle management, context storage, and concurrency control;
- Model integration layer: adapting to different model providers’ API protocols and handling authentication, rate limiting, timeouts, and retries;
- Tool calling layer: implementing function-calling protocols, parameter validation, result parsing, and fallback handling;
- Knowledge layer: document parsing, cleaning, chunking, vectorization, index building, and retrieval ranking;
- Operations layer: log collection, tracing, quality evaluation, and permission and key management.
This work spans frontend, backend, algorithm, and operations roles, which is why a seemingly simple “intelligent customer service” requirement often takes weeks to produce a usable version. The value of a platform approach is to consolidate these common capabilities into reusable infrastructure, so developers can focus their effort on prompt design, knowledge organization, and business process orchestration, which are the parts that actually determine results.
2. The Common Capability Model of Low-Code Agent Platforms
Mature agent development platforms in the industry may differ in implementation, but their capability boundaries can generally be abstracted into four layers.
2.1 Model Management Layer
The platform needs to hide differences between model services in API protocols, parameter semantics, and capability boundaries, and provide unified integration and switching. Three things matter in engineering terms. First, multi-model routing: simple intent recognition can go to a lightweight model while complex reasoning goes to a more capable one, based on task type. Second, adjustable parameters: temperature, max output length, stop sequences, and similar parameters should be configurable at node granularity. Third, fallback strategy: automatically switch to a backup model when the primary model is unavailable, so the business is not interrupted.
2.2 Knowledge Retrieval Layer (Retrieval-Augmented Generation)
Retrieval-augmented generation is the mainstream approach for keeping agents factual and current. The pipeline typically looks like this:
raw documents -> parsing -> cleaning and chunking -> vectorization -> index building|user question -> query rewriting -> vector retrieval + keyword retrieval -> fusion reranking -> context assembly -> model generation
Key engineering details: chunk granularity needs to match document structure, since chunks that are too long dilute semantics and chunks that are too short lose context; at the retrieval stage, running vector search and keyword search in parallel is recommended, to cover both semantic similarity and exact matching of proper nouns; adding a cross-encoder model at the reranking stage can significantly improve relevance; and finally, citation traceability must be preserved so every answer can be traced back to the original passage, which is a prerequisite for acceptability in enterprise scenarios.
2.3 Agent and Tool Layer
The core pattern for task-oriented agents is a loop of “plan, call, observe, re-plan.” Platforms typically provide a tool registration mechanism that declares a tool’s name, purpose, and parameter schema in a structured description, and the model uses that to decide on its own when to call the tool:
{"name": "query_order_status","description": "Look up shipping status by the order number provided by the user","parameters": {"type": "object","properties": {"order_id": { "type": "string", "description": "Order ID" }},"required": ["order_id"]}}
In engineering terms, tool calls must have a maximum iteration count, a timeout, and idempotency constraints. For write operations in particular, a human confirmation step should be introduced to prevent an irreversible business impact caused by a model misjudgment.
2.4 Workflow Orchestration Layer
When the process is highly deterministic, describing the execution path with a directed acyclic graph is more reliable than letting the model decide freely. Common node types include start nodes, model call nodes, knowledge retrieval nodes, conditional branch nodes, code execution nodes, API call nodes, variable assignment nodes, and end nodes. The value of orchestration is that it makes explicit which steps must be deterministic and which steps are allowed to be model-driven, balancing stability and flexibility.
3. How to Choose Among Four Application Types
| Application type | When it fits | Typical scenarios | Key design focus |
|---|---|---|---|
| Chat assistant | Multi-turn context, open-ended questions | After-sales support, internal Q&A | Context window management, intent recognition |
| Text generation | Single-turn input, structured output | Summarization, translation, first-draft copywriting | Output format constraints, template reuse |
| Task agent | Needs external tool calls, multi-step reasoning | Data analysis, information gathering and summarization | Tool description quality, loop termination conditions |
| Workflow application | Fixed process, enumerable nodes | Approval assistance, content moderation pipelines | Branch coverage, exception compensation |
The first principle of selection: if a deterministic process can solve it, do not hand it to the model to decide freely. Models are suited to semantic understanding and generation, not to enforcing business rules that require strong consistency.
4. A Practical Path to Production
Step 1: Break Down Requirements and Define Boundaries
Be explicit about what the input is, what the output is, and how failures are handled. Refining “build an intelligent customer service agent” into “answer shipping-related questions outside business hours, and when a question cannot be answered, hand off to a human with a summary of the original conversation” makes the requirement far more actionable.
Step 2: Design Prompts and Knowledge Together
A prompt should include a role definition, task description, constraints, output format, and a few examples. Avoid writing large blocks of knowledge directly into the prompt; let the retrieval layer inject it dynamically, so knowledge updates do not require prompt changes.
You are an after-sales support assistant.Answer only based on the content in <reference>; if the material does not cover it, reply "This question requires human confirmation."At the end of the answer, mark the cited passage as [Source: ID].<reference>{{retrieved_context}}</reference>
Step 3: Build the Evaluation Set First
Establish an evaluation set before optimizing quality, covering high-frequency questions, edge cases, and adversarial prompts. Metrics should include at least retrieval hit rate, answer accuracy, citation accuracy, and average response latency. Iterating without an evaluation set is essentially blind tuning.
Step 4: Observability and Cost Control
Log the full trace of every request: input, retrieved passages, model output, tool calls, and latency distribution. Combined with logging services and monitoring and alerting, this makes it possible to pinpoint quality or performance problems at a specific node. On the cost side, tracking token consumption per node helps identify redundant calls.
Step 5: Security, Compliance, and Permission Isolation
Keys should be managed centrally by a configuration center or key management service and never written into code; knowledge bases should be isolated by role at the row or document level; external APIs need authentication, rate limiting, and audit capabilities. If sensitive data is involved, masking should be completed before retrieval.
5. How This Differs From Traditional Development
In the traditional approach, model integration, vector retrieval, session storage, and UI construction are separate from each other, and a change in any one of them can trigger a cascade of rework. The platform approach standardizes these capabilities into configurable items, which brings three structural changes. First, expanded role boundaries: product and operations staff can produce usable prototypes based on prompt and workflow configuration. Second, shorter iteration cycles: quality tuning changes from “modify code and ship a release” to “change the configuration and it takes effect.” Third, reusable assets: prompts, knowledge bases, tool definitions, and workflow templates become assets the team can accumulate.
6. Common Pitfalls and How to Avoid Them
- Over-relying on model autonomy: when the process is highly deterministic, prefer orchestration to reduce uncertainty;
- Ignoring retrieval quality: the ceiling on generation quality is set by retrieval quality, so chunking and reranking strategies should be iterated on continuously;
- No fallback path: standard responses for “cannot answer” and “call failed” must be designed to prevent the model from fabricating answers;
- Evaluation lagging behind: build the evaluation set before tuning, otherwise you cannot tell whether a change is an improvement or a regression;
- Missing permission design: knowledge isolation and operation confirmation should be part of the design from the prototype stage, not patched on before launch.
7. Conclusion
The hard part of building agents has shifted from model integration to engineering organization. With platform-based model management, retrieval augmentation, tool calling, and workflow orchestration as the foundation, plus clear boundary definition, an evaluation set built up front, and solid observability design, teams can move agents from a one-off demo to a business system that can be operated sustainably. For scenarios that require private deployment, elastic compute, and full-chain observability, general cloud products from Baidu AI Cloud such as container platforms, object storage, logging services, and monitoring and alerting can provide the underlying support, helping application architecture strike a balance between security and compliance and cost control.
