Taming Automation Agents in 7 Days: A Visual Recognition Pitfall Guide

    This article shares a seven-day experiment in automating a repetitive chart-analysis workflow with an AI agent, focusing on the pitfalls encountered and the practical fixes. It breaks the pipeline into seven stages and addresses three core problems: unstable browser login and page interaction, the cost and accuracy trade-offs of using general-purpose vision models for chart digitization, and the loop of repeated corrections that never becomes durable knowledge. The article explains why rule-based local image parsing outperforms generic vision APIs on highly structured charts, and how to convert "teaching the model" into fixed engineering assets through externalized rules, upfront validation, regression cases, and version control. A reusable deployment checklist and a concluding principle—stability comes from determinism, not model size—are included.

    1. Background: Half a Day Lost to Repetitive Work

    Anyone doing data trend analysis knows the routine: log into a designated site at a fixed time each day, mechanically capture more than three hundred trend charts, then read each one, annotate the values, apply an algorithm dictionary to compute results, and consolidate everything into a table. There is little creativity in this work, yet it drains attention completely. Half a day disappears into the screen, and even getting up for a glass of water has to be squeezed in.

    During a holiday, the author built a “hotspot radar + AI coding tool” setup on an old laptop and confirmed that letting an agent do the work was feasible. The next thought followed naturally: if it can find hotspots, why can’t it take over screenshot analysis? Over the following seven days, the author iterated repeatedly on this pipeline, switched between several general-purpose large models, and finally got the whole flow running end to end. This article does not oversell the results; it only reviews the pitfalls and the solutions.

    2. Pipeline Breakdown: Seven Steps and Their Weak Points

    The target flow breaks down into seven steps: log in → precise search → capture the root screenshot → capture the boot-number screenshot → map to a numeric matrix → output results using the algorithm dictionary → aggregate statistics.

    The defining trait of this pipeline is tight coupling: the output of each step is the input of the next, so any jitter in one link gets amplified downstream. The engineering focus, therefore, is not “make the model smarter” but turning every step into a deterministic stage that can be validated, retried, and rolled back.

    3. Pitfall 1: Unstable Simulated Login and Page Interaction

    The earliest failures were concentrated at the page-operation layer. Slight offsets in locating the search box shifted the entire set of search results; CAPTCHAs, ad overlays, and asynchronous loading left the script spinning in place. The more typical problem was “ineffective correction”: after repeatedly instructing the model to close overlays, it still clicked the wrong button, sometimes even closing the entire tab.

    There are two root causes. First, the page was treated as a static document when it is actually a dynamic environment with asynchronous behavior and random elements. Second, experience was stored in the conversation, while conversational context gets compressed and forgotten.

    What works:

    • Replace fixed delays with explicit waits for the target element to become visible and clickable;
    • Prefer semantically stable attributes for selectors, and avoid relying on long auto-generated paths;
    • Handle overlays as a separate strategy: try to close them first; if that fails, log it and move on, and never close the main page by mistake;
    • Persist the session and cookies locally to reduce repeated logins;
    • On failure, take a screenshot and write a log to preserve a traceable scene.

    Illustrative logic:

    1. def safe_click(page, selector, timeout=8000):
    2. try:
    3. page.wait_for_selector(selector, state="visible", timeout=timeout)
    4. page.click(selector)
    5. return True
    6. except Exception as e:
    7. log_failure(page, selector, e) # screenshot + log
    8. return False

    4. Pitfall 2: Vision Recognition Hits Cost and Accuracy at Once

    Converting screenshots into numbers is the core stage and the easiest place to take a wrong turn. The common mistake is putting blind faith in general-purpose vision model APIs: low-tier models misjudge even colors, mid-tier models hallucinate noticeably, reading 5 as 3 or red as blue; high-tier models improve accuracy, but the per-image cost multiplied by three hundred images, and then by once per day, quickly sends monthly spending out of control.

    The more important judgment is that this task does not require “understanding image semantics” at all. Trend charts are rendered with fixed color schemes, fixed legends, and fixed axis rules, which makes them highly structured graphics. For highly structured input, rule-based parsing beats general-purpose recognition across the board on accuracy, latency, and cost.

    The final approach was therefore changed to local processing: use an image-processing library for color-space conversion and threshold segmentation, locate curves by legend color values, scan along pixel columns to obtain trajectory points, and then linearly map them to a numeric matrix based on the axis ticks. The whole process runs offline with zero call fees, and accuracy under a fixed template can stay stably close to perfect.

    1. # Pseudocode: extract curves by legend color and map to values
    2. mask = color_threshold(img, legend_rgb, tol=30)
    3. points = scan_columns(mask) # take the centroid per column
    4. values = map_to_axis(points, y_ticks) # pixels -> values

    Two safeguards are also needed in engineering: fall back to a manual review queue when parsing fails (missing curves, abnormal point counts), and adapt to template changes through configuration rather than code changes.

    5. Pitfall 3: Correction Loops and the “Triangle Trap”

    The most exhausting step is training the tool itself. Feeding errors back to it does converge in the short term, but the same problems resurface after a while, forming a loop of “make a mistake → correct → remember → repeat,” the so-called “triangle trap.” The essence is that knowledge lives only in session memory and never settles into an engineering asset.

    The fix is to turn “teaching” into “hardening”:

    1. Externalize rules: put locating methods, color tolerances, and anomaly thresholds into config files or dictionary tables that the model can only read, not modify;
    2. Move validation upfront: every step’s output must pass assertions and unit tests before it can proceed;
    3. Add regression cases: turn every real failure into a case included in the pre-run self-check;
    4. Narrow responsibilities: let the model handle orchestration and exception decisions, and leave deterministic computation to code;
    5. Keep version history: manage configs and prompts under version control so changes can be diffed and rolled back.

    6. A Reusable Deployment Checklist

    • Environment isolation: run on old hardware or in containers to avoid polluting the main machine;
    • Idempotency and checkpoints: persist each step’s output to disk and support resuming from any step;
    • Cost guardrails: any call-based approach must have budgets and quotas, with automatic fallback to local rules when exceeded;
    • Observability: structured logs + failure screenshots + a key-metrics dashboard, making it easy to tell whether the page changed or the algorithm is wrong;
    • Human-machine boundary: route low-confidence results to a manual queue and never let the model “guess.”

    7. Conclusion

    The core conclusion of the seven days comes down to one sentence: the stability of automation comes from determinism, not from model parameter count. Hand the volatile interactions, the computable parsing, and the forgettable experience to wait strategies, local algorithms, and configuration assets respectively, and the agent truly turns from an “intern who needs to be coaxed” into a reliable executor. If you are already using Baidu AI Cloud capabilities, it is worth following the same three principles—externalize rules, validate upfront, cap costs—before gradually expanding the scope of automation.