AI Agent Applications: Engineering Practices for Rapid Development
Building a useful AI agent prototype starts with choosing the right application type, not writing a longer prompt. This article outlines a minimal architecture, separate controls for prompts, knowledge, and tools, workflow-based execution, and practical release checks that help teams move quickly without losing control of data, permissions, or reliability.
An AI agent is not simply a longer prompt. It places a large language model inside an orchestrated application: the model handles understanding and generation, while the application maintains context, retrieves information, invokes external capabilities, and delivers results within controlled boundaries.
To build a useful prototype quickly, first choose the right application type, then establish the data, tool, and deployment paths. Building an entire frontend and backend from scratch should not be the starting point.
Understand the Four Common Application Types
The same model capabilities can create very different engineering challenges depending on how users interact with them.
Chat assistants support multi-turn conversations, such as customer support, internal question answering, and guided assistance. Their central concern is conversation state: retaining recent context, compressing it into summaries when necessary, and defining when to ask follow-up questions, decline a request, or hand off to a person.
Text generation applications handle one or a few inputs for tasks such as summarization, rewriting, translation, and report drafting. Input templates, output formats, and consistency across batches matter more than long-term conversational memory.
Task-oriented agents follow a goal–steps–result pattern. The model breaks down a task, decides whether to invoke search, calculation, or business APIs, and continues reasoning based on tool results. These applications carry the greatest risk because incorrect tool calls can modify data or expose information.
Workflows explicitly define branches, loops, human review, and API calls. Steps that can be represented by fixed nodes do not need to be decided dynamically by a model. Approvals, quality checks, and notifications with clear conditions are easier to observe and replay when implemented as workflows.
The selection rule is straightforward: use workflows or text generation when the path is fixed; use a chat assistant for open-ended conversation. Choose a task-oriented agent only when the steps cannot be fully specified in advance and access to external systems is necessary.
Why Building Everything Yourself Takes Longer
Without an application layer, even a conversational support assistant involves substantial hidden engineering:
- Repeatedly testing prompts and branching logic.
- Building a service to connect to model APIs.
- Storing sessions and chat history.
- Integrating tool descriptions, parameter validation, and response parsing into the tool-calling protocol.
- Cleaning, chunking, embedding, and retrieving knowledge-base content.
- Building a user interface and managing secrets, rate limits, authentication, and deployment.
All these tasks are legitimate, but they postpone validating an idea until after a platform has been built. Product and operations teams, including junior business staff, are best placed to define use cases and conversational behavior. Deployment and storage details should not block that work.
A faster approach is to use a configurable application framework for prompts, model selection, and publishing, while reserving custom development for business APIs and data that genuinely require it.
A Minimal Viable Architecture
A deployable agent application needs at least six layers. Missing any one of them is likely to cause problems once users begin testing it.
- Access layer: Provides a web interface, workplace entry point, or API, and identifies users.
- Model layer: Exposes a consistent chat or completion interface so models can be switched based on cost, latency, and quality, rather than hard-coding one provider’s API into business logic.
- Orchestration layer: Maintains prompt templates, variables, branches, and tool-use policies.
- Memory layer: Separates short-term conversation context from long-term user profiles and sets retention periods.
- Knowledge layer: Supports document ingestion, chunking, retrieval, and source references.
- Observability layer: Records requests, retrieved passages, tool traces, token usage, and user feedback.
Compute, object storage, vector or keyword indexes, containers, logs, and alerts can run in a self-managed environment or use general-purpose cloud services. Providers such as Baidu AI Cloud offer capabilities including model inference, object storage, logging, monitoring, and alerting; availability should be checked for the intended deployment environment.
The important principle is maintaining boundaries, not following a particular console interface: keep secrets out of prompts, apply separate access controls to source documents and vectors, and isolate production from testing.
A typical request path looks like this:
- The access layer receives the user’s question and performs authentication and sensitive-content checks.
- The orchestration layer assembles the system prompt, variables, and a summary of conversation history.
- If the question depends on internal information, retrieval runs and injects only passages that meet the relevance threshold.
- The model answers directly or invokes a registered tool.
- Tool results are validated before entering the next model turn.
- The final answer includes source references, while logs are written asynchronously for later review.
Govern Prompts, Knowledge, and Tools Separately
Prompts: Define Behavior, Not the Entire Knowledge Base
Prompts should establish the role, objective, and output format. Do not pack an entire policy manual into a prompt.
Represent changing information as variables, such as the channel, user identity, current date, and available tools. Keep the system prompt short and stable, and place business rules in versioned templates. Define structured outputs where possible so downstream systems can validate them.
Every prompt revision should be tested against a fixed regression set. One or two responses that “feel better” are not enough.
Knowledge: Fix Source Quality Before Retrieval
Accurate retrieval cannot compensate for poor source material. Scanned documents, outdated policies, and contradictory guidance can still produce incorrect answers.
Before ingestion:
- Remove duplicates and identify effective dates and scope.
- Chunk documents by headings and paragraphs rather than mechanically splitting them into equal lengths.
- Preserve searchable source text for policy identifiers and product names.
Retrieval should allow keyword and vector search to complement each other. Exact matching works well for specialized terms and error codes; semantic matching is better suited to conversational questions.
Require answers to rely on retrieved passages and include their sources. If the passages do not provide enough information, the model should explicitly say it does not know rather than inventing a policy.
Tools: Allowlist Capabilities and Validate Calls
Every tool should clearly specify its purpose, parameters, read-only or write access, timeout, and failure message.
Query tools can execute automatically. Write operations, such as placing orders, issuing refunds, or changing permissions, require explicit confirmation or a human-review step.
Validate model-generated parameters against a schema and reject unexpected fields. Automatic tool wrapping should reduce boilerplate code, not remove the need for permission design.
Use Workflows for Deterministic Control
Agents are useful for exploration, but they should not own every control-flow decision.
A practical combination is to let a chat assistant collect information, then enter a workflow once the required information is complete. Within the workflow, model nodes handle classification, extraction, or generation. Explicit nodes handle branching, retries, human review, and external API calls.
This makes failures easier to diagnose: an empty retrieval result, incorrect classification, or API timeout can be identified directly instead of being buried in a long, opaque reasoning sequence.
For example, a customer-support flow can:
- Identify the user’s intent.
- Answer directly with citations when confidence is high and relevant knowledge-base content is found.
- Collect required fields and hand off to a person when an account change is involved.
- Ask at most one follow-up question when the intent is unclear.
Follow-up limits, handoff conditions, and restrictions on what the assistant may promise should be configuration settings, not instructions hidden in an individual conversation.
Define Ownership and Completion Criteria
During prototyping, product or operations staff can configure prompts, select models, upload a small document set, and publish an access link or API for internal testing.
A prototype is not complete merely because it can exchange a few messages. It should meet these criteria:
- Ten to thirty real questions can be tested reproducibly.
- Refusals and human handoffs behave as expected.
- Secrets and internal links are not exposed in the frontend.
- Logs show which source passages were used for each response.
During a pilot, developers can add the application-specific engineering: read-only business-system APIs, identity integration, rate limits, content-safety scanning, and data-retention policies.
Labeling incorrect answers, adding missing documents, and adjusting retrieval thresholds are often more effective than repeatedly switching models. Consider fine-tuning only after prompts, retrieval, and tools are stable and enough high-quality examples are available. Otherwise, it risks embedding poor data into model weights.
Pre-Launch Checklist
Before release, confirm that:
- Model configurations and knowledge bases are separated by environment.
- APIs have authentication, quotas, and timeouts.
- Both user input and model output pass through content-safety policies.
- Logs are sanitized and do not contain complete identification numbers or secrets.
- Prompts and workflows can be rolled back to a previous version.
- A human takeover channel is available.
- External tools use least-privilege permissions by default.
Avoid promising performance figures in advance. After launch, measure latency, success rate, and human takeover rate, then decide whether to scale capacity or change the model configuration.
Rapid agent development depends on narrowing the scope. Start with one channel, one category of questions, and one trusted document set. Use the simplest suitable form—chat, text generation, a task-oriented agent, or a workflow—to establish an end-to-end path, then add tools and branches incrementally.
This preserves the speed of business-led prototyping while keeping data security, retrieval quality, and release governance under engineering control.
