AI Agent Workflow in Practice: Build Six AI Applications from Scratch
This article shows how to build six practical AI agent applications using visual workflows. It explains the four core node types, then walks through content production with text and image models, invoice verification with multimodal models, a fine-tuning data loop, trend aggregation for topic selection, digital human video generation, and shared engineering practices for reliability.
1. Why Build Agents with Visual Workflows
As generative AI adoption accelerates, the core challenge for developers has shifted from “can we call a model” to “how do we orchestrate model capabilities reliably and maintainably.” Traditional hard-coding mixes prompts, model calls, and business logic in the same place. Any requirement change forces broad code edits, and regression testing becomes expensive.
Visual workflows address this by abstracting application logic into a directed graph: nodes carry atomic capabilities, edges carry data flow, and a runtime engine handles scheduling and state passing. Business stakeholders can participate in flow design, developers focus only on what happens inside each node, and testing or canary releases can be split at node granularity.
A mature workflow typically contains four node types:
- Start nodes define input variables and validation rules.
- Model nodes handle prompt rendering and inference.
- Logic nodes handle conditional branching, loops, and variable aggregation.
- Tool nodes connect to external capabilities such as retrieval, storage, and notifications.
Understanding the responsibility boundaries of these four node types is the foundation for every case that follows.
2. Case 1: A Content Pipeline Combining a Text Model and a Text-to-Image Model
The first scenario solves the “matching text and images” problem. The flow works as follows: the start node receives a topic and style parameters; a text node generates structured copy containing a title, summary, and body paragraphs; the flow then splits into parallel branches, where one text node compresses the summary while a text-to-image node extracts key imagery from the copy into a visual description and generates an illustration; finally, an aggregation node merges the text and image URLs into a unified result.
Three engineering points matter here. First, the text-to-image prompt should not use the user’s raw text directly; the text node should rewrite it into visual language to avoid garbled text appearing in the image. Second, image generation takes far longer than text, so configure timeouts and retries, and handle degradation in the aggregation node by returning a placeholder image on failure. Third, write all generated results to object storage and pass only access URLs, avoiding repeated copying of large objects in workflow memory.
3. Case 2: Invoice Comparison with a Multimodal Model
The second scenario is a high-frequency need in financial shared services: determining whether two invoices refer to the same business transaction. Early solutions relied on traditional OCR, which has limited robustness against layout variation, seal occlusion, and skewed photos. A multimodal model can output structured fields directly, but digits and amounts on the invoice may still be misread.
A dual-channel verification structure is therefore recommended. The main channel uses a multimodal model to extract fields and output a fixed set of key-value pairs. The auxiliary channel uses rule nodes to check amount summation, consistency between tax and pre-tax amounts, and date format validity. The two results are compared in a conditional branch; on mismatch, the flow enters a manual review node with a difference summary attached. At the prompt level, require the model to output only the agreed fields and fill missing ones with “not recognized,” which significantly reduces the fault tolerance burden on downstream parsing.
Start -> Multimodal extraction -> Rule validation -> Conditional branch|- Match -> Output result|- Mismatch -> Review ticket -> Output result
4. Case 3: An Iterative Loop Built from Fine-Tuning Data
The ceiling on fine-tuning results is set by data quality, not training tricks. A workflow can standardize corpus production: input raw business documents, pass them through a cleaning node that strips headers, footers, and duplicate paragraphs, then have a text model generate candidate samples in a three-part “instruction-input-expected output” format. A second model node then scores quality and deduplicates, filtering out samples with vague answers or mismatched instructions and outputs. Finally, split the training and validation sets at a fixed ratio and write them to storage for later training.
Key practices include defining explicit scoring dimensions for each sample category, such as instruction completeness, answer verifiability, and reasonable length; keeping a manual spot-check step whose sampling ratio adjusts dynamically with automation confidence; and recording random seeds and prompt versions during generation so the corpus is reproducible. This loop decouples data iteration from model iteration, letting the team evolve them independently.
5. Case 4: Trend Aggregation and Topic Selection Support
The first bottleneck for content operations is topic selection. Use a “scheduled trigger + iteration loop + aggregation” structure: a trigger node starts the flow on a schedule; an iteration node walks through a configured list of information sources, calling crawl and parse tools one by one to extract titles, sources, publish times, and body summaries; inside the loop, deduplicate and score relevance, keeping only items above a threshold. After the loop, an aggregation node uses a text model to generate a topic list and angle suggestions based on the audience profile.
Compliance and stability points: collect only publicly accessible content and respect each source’s access rules while controlling request frequency; truncate body text to avoid exceeding the model context; and persist raw results of each run to the database so topic decisions can be traced. To extend this, add a three-stage “generate outline - generate first draft - rewrite style” chain after aggregation, forming a complete pipeline from topic selection to finished draft.
6. Case 5: Generating Digital Human Presenter Videos
The digital human scenario extends text capability into video. The recommended flow is: a text node generates the script and rewrites it in a conversational tone; a speech node synthesizes audio and returns duration and phoneme timestamps; a driving node generates lip and expression parameters from those timestamps; a render node composites the visuals and overlays subtitles; finally, a transcoding step outputs multiple quality levels. Make script review a mandatory manual node to keep factual errors out of rendering, because reworking video costs far more than reworking text.
Two deployment forms are possible. Cloud hosting suits teams with volatile traffic that need to launch quickly. On-premises deployment suits scenarios with data residency requirements, delivered through a container platform and paired with logging and monitoring with alerting for runtime observability. Both forms share the same workflow definition and differ only in how model and rendering resources are connected.
7. Common Engineering Practices and Takeaways
Five general rules emerge across the cases: validate inputs explicitly and return readable errors; constrain model output to a structured format; apply timeouts, retries, and degradation to slow nodes; persist all intermediate artifacts to storage instead of memory; and keep human intervention and audit records at key decision points. On a cloud platform such as Baidu AI Cloud, these capabilities can be combined, for example using object storage for artifacts, a message queue to smooth traffic spikes, a container platform for rendering tasks, and logging and monitoring to track node latency and failure rates.
After mastering these six scenarios, what developers really gain is not a set of fixed flows but a transferable methodology: decompose the business into atomic capabilities, choose node types to orchestrate them, and then use observability and degradation strategies to ensure stability. On that basis, most enterprise-grade agent requirements can be delivered quickly and under control.
