AI Agent Development: Workflow Design and Production Deployment

    This article explains how to build AI agents as auditable, goal-constrained workflows rather than chat interfaces. It covers the distinction between conversational apps, workflows, and agents; deployment baselines; model gateways; five application patterns; prompt and node design; external tool contracts; knowledge base and multimodal handling; e-commerce and internal-assistant scenarios; and release, observability, and capability expansion. Readers get practical checks for permissions, idempotency, evaluation, fallback paths, and traceability when moving agent demos into production.

    An agent is not a “chat interface.” It is an application that, under goal constraints, can perceive input, call tools, maintain state, and produce executable results. Enterprises usually do not want a polished reply; they want fewer detours in handling work such as checking orders, verifying inventory, drafting tickets, and writing conclusions back to business systems. Visual workflows break these steps into orchestration nodes so prompts, retrieval, branches, and external calls can be reviewed and replayed. The following describes a general approach in the order from concept to launch.

    1. Separate Conversational Apps, Workflows, and Agents

    Ordinary conversational applications mainly generate a single turn or use a short context. They fit copywriting, summaries, and Q&A. A workflow explicitly defines how data flows: input validation, retrieval, model inference, conditional branches, human confirmation, and result write-back. An agent adds the ability to choose the next step to complete a goal, but those choices must remain within allowlisted tools and permission boundaries, not unlimited freedom.

    To decide whether an agent is appropriate, look at three things. First, is the task multi-step and dependent on intermediate results—for example, identifying intent, checking knowledge, and then deciding whether to answer directly or hand off to a human? Second, must it integrate with external systems, and do failed calls require compensation? Third, is the business cost of a wrong answer high? When the cost is high, key nodes should use deterministic logic, and only language understanding and wording should be left to the model.

    Compared with “one large prompt that does everything,” the value of a workflow is locatability. If a single case gets a wrong answer, you can see whether retrieval missed, a parameter was extracted incorrectly, or a downstream API timed out. This is more effective for later optimization than repeatedly editing a very long prompt.

    2. Runtime Environment and Deployment Baseline

    Local or intranet deployment is suitable for verifying that data does not leave the domain, debugging nodes, and preparing samples. Production is more concerned with elasticity, secrets, logs, and release cadence. Whether deployed in a self-built data center or on a cloud, it is advisable to fix the same baseline:

    • Separate configuration from secrets. Model endpoints, tokens, and callback URLs should go through secret management and not be written into workflow definitions.
    • Keep the orchestration service stateless so it can scale horizontally. Put conversation state, files, and vector indexes in separate storage.
    • Use unified authentication at the entry point and grant least privilege by application and by tool.
    • Retain input summaries, node latency, model identifiers, and tool return codes for each run to support tracing. Mask sensitive fields before writing logs.

    If a public cloud hosts the inference gateway, object storage, logging, and monitoring alerts, these capabilities should sit within the same network boundary and account permission system. For example, Baidu AI Cloud can be used to run orchestration services on a container platform, store source documents and multimodal files in object storage, and observe timeouts and error rates through logging and monitoring alerts. This discussion relies only on generic cloud capability categories, not on proprietary console button names from any one provider.

    The deployment checklist can be short: health checks, hot configuration reload, model timeout and retry caps, vector store capacity, and an emergency switch to disable external tools. An agent without an emergency switch is not suitable for direct exposure to customers.

    3. Model Access and Five Application Patterns

    Production rarely binds to a single model. Route by task: use small models for low-latency classification, stronger models for long-document reasoning, dedicated embedding models for vectors, and multimodal models for speech or images. The access layer should be unified as a model gateway that hides vendor differences and standardizes timeouts, rate limiting, content-safety switches, and billing dimensions (per token or per call, subject to the actual contract; no unit price is assumed here). When the primary model is unavailable, fall back to a backup model or rule-based reply and mark the fallback to avoid silent quality degradation.

    On this basis, common applications can be grouped into five patterns, which makes it easier to choose an architecture rather than pile on features:

    1. Conversational: multi-turn clarification, suitable for inquiries. Limit turns and topic drift.
    2. Generative: produce copy or report descriptions from templates. Emphasize format constraints and factual sources.
    3. Knowledge Q&A: retrieve before generating; answers must trace back to snippets.
    4. Workflow: explicit branches, loops, and human nodes, suitable for approvals and batch processing.
    5. Agentic: plan steps within an authorized tool set, suitable for cross-system handling, but every step must be auditable.

    A selection rule: when the path is fixed, use a workflow; when the path varies with the question and tools are controllable, use an agent. Do not wrap deterministic APIs in free planning just to look intelligent.

    4. Prompts, Nodes, and External Communication

    Prompts handle role, task, output format, and refusal conditions. They do not store business data. A practical structure is usually: a one-sentence role, input field descriptions, allowed information sources, output schema (structured fields are better than long prose), and how to respond on failure. Style optimization is secondary; first ensure stable fields so downstream nodes can parse them. A few positive and negative examples can constrain format, but examples must not leak real customer data.

    Nodes can be divided by responsibility rather than by icons in a UI:

    • Input node: validate required fields, length, and enum values.
    • Retrieval node: fetch snippets by knowledge base, filter conditions, and count.
    • Reasoning node: consume only validated context.
    • Branch node: route by rules or classification results.
    • Tool node: call query, write, or notification operations.
    • Human node: pause for confirmation in low-confidence, high-value, or compliance scenarios.

    For external system communication, prefer existing integration methods: synchronous APIs for queries, message queues for writes that can be delayed, and callbacks for long-running task completion notifications. Tool descriptions should specify parameters, idempotency keys, and error semantics. The following is an illustrative structure only, not syntax specific to any platform:

    1. tool: query_order
    2. input:
    3. order_id: string
    4. channel: enum[web, app, store]
    5. timeout_ms: 2000
    6. retry: { max: 1, when: [timeout] }
    7. on_error: handoff_human
    8. idempotency_key: order_id

    Write tools must be idempotent. A retry caused by network jitter must not execute the same refund twice. Keep user-facing text separate from system-facing structured results: users see explanations, while systems receive only status codes and ticket numbers.

    5. Knowledge Bases and Multimodal Inputs

    Knowledge base quality sets the upper bound for Q&A. Documents should be governed before ingestion: remove headers, footers, and outdated versions; preserve heading hierarchy; and chunk by semantics rather than cutting at a fixed character count. Each chunk should carry source, update time, and permission labels. During retrieval, filter by permission first, then run vector recall, supplement with keyword search when necessary, and finally pass a small number of snippets to the model. Cite snippet IDs in answers so humans can spot-check them.

    Update strategy must be explicit. Policy documents should use version replacement, while product parameters may allow incremental updates. Deleted or retired knowledge should be removed from the index immediately so the model does not “remember” old prices. Build evaluation sets from rewritten real tickets, with metrics that at least include hit rate, whether refusals are reasonable, and whether the system fabricates numbers not found through retrieval.

    Multimodal handling is not about throwing images into a model all at once. A common path is: run layout recognition and text extraction on images or scans, structure tables separately, and then retrieve them together with text knowledge; for speech, transcribe first, mark low-confidence words, and echo critical numbers for confirmation. Store files in object storage and pass only references and timestamps through the workflow. This controls context length and makes it easier to audit what the model saw at the time.

    6. Applying the Workflow in Two Industry Scenarios

    E-commerce customer service does not need to become “handles everything” in one step. It can be divided into three layers. The first layer identifies intent: logistics, invoices, returns and exchanges, or product inquiries. The second layer performs read-only queries against orders and the knowledge base; high-confidence cases receive direct replies with policy sources. The third layer involves refunds, address changes, and reshipments; it generates a todo and enters human review or a rules engine, with the business system executing the action. The agent does not directly change fund status. During peak periods, rate-limit tool calls; when queues back up, shorten generation length and prioritize returning query results.

    Enterprise internal assistants emphasize identity and tenant isolation. A user question is first mapped to the knowledge space visible to that user and the APIs they can call—for example, checking calendars, creating approval drafts, or summarizing today’s todos. The assistant can generate drafts, but submission goes through the existing approval flow. Bots or messaging entry points are only channels; the core remains the same workflow, avoiding a separate prompt for each channel. Notification outputs should be opt-out capable and traceable, avoiding useless messages flooding group chats.

    The shared principle in both scenarios is: the model handles understanding and drafting; business systems handle bookkeeping and state changes; low confidence, unauthorized access, amount thresholds, or compliance thresholds trigger human review.

    7. Release, Observability, and Capability Expansion

    Release should not have only one “production” environment. At minimum, separate draft, staging, and production. Staging should replay historical tickets with masked data, compare node hit rates and tool error rates, and then proceed to canary release. Canary rollout can be by channel, user percentage, or question type. Every change should record prompt version, workflow version, and model version, and roll back all three together.

    Observability metrics should be few and hard: end-to-end latency, tool failure rate, human handoff rate, user follow-up rate, and sampled factual error rate. A rising follow-up rate often indicates regression in retrieval or clarification strategy, not simply that “the model got worse.” Alerts should go to the on-call channel and include the node trace of one failed run.

    For capability expansion, adopt an open context and tool protocol approach: describe external capabilities as discoverable tools, assemble them by permission in the orchestration layer, and avoid hard-coding every API into one application. The protocol or gateway should pass only necessary context, not forward the entire conversation history indiscriminately. New tools should first undergo contract testing in staging: missing parameters, timeouts, duplicate submissions, and unauthorized access. After passing, they can be added to the agent’s optional tool set.

    8. Commonly Missed Points in Production

    First, launching without an evaluation set means every later prompt change is based on intuition. Second, treating the knowledge base as a dumping ground, with outdated and official documents mixed together. Third, tools without idempotency or permissions, so a mistaken agent call directly changes production data. Fourth, optimizing only first response and not failure paths, so users who hit a timeout see only a vague “try again later.” Fixing these four points will make the system more stable than switching to a stronger model.

    From definition, deployment, and the five application patterns to prompts, nodes, knowledge bases, multimodal inputs, and channel release, the main line of agent development remains: clear goals, visible steps, controllable tools, and traceable results. Iterating along this line is how teams turn a demo into a sustainable business capability.