AI Automation Pitfalls: A Practical Guide from Seven Days of Trial and Error

    After seven days of testing six models, I built an automated workflow for capturing and analyzing more than 300 daily trend charts. This guide covers the failures that mattered most—fragile browser interactions, unreliable visual recognition, and repeated AI mistakes—and explains how explicit error handling, local image processing, persistent rules, and automated validation made the workflow more reliable.

    1. Background: A Repetitive Task Worth Automating

    My daily work involves analyzing data trends. Every day, I had to log in to a specific website, manually capture more than 300 trend charts, review each one, annotate the data, and calculate the results.

    The work was mechanical, repetitive, and exhausting. It took roughly half my working day and left my eyes strained from staring at the screen.

    Previously, I had set up a “trend radar + AI agent” workflow on an old laptop to help identify trending topics for content planning. That experience raised a question: could an agent also take over screenshot collection and analysis?

    I spent seven days of my time off trying to make it work. I switched between six large language models, repeatedly tested and corrected the workflow, and often worked into the early morning. Eventually, the complete pipeline ran successfully.

    Here are the problems I encountered and the methods that helped resolve them.

    2. Designing the End-to-End Workflow

    The automation pipeline consisted of seven steps:

    1. Log in to the website → Run a precise search → Capture a reference screenshot
    2. → Capture the target screenshot sequence → Convert screenshots into numerical matrices
    3. → Apply algorithmic rules → Aggregate the results

    The sequence looks straightforward, but each stage introduced potential failures. The most important lessons came from browser automation, visual recognition, and keeping the AI from repeating mistakes.

    3. What Went Wrong—and How I Fixed It

    3.1 Browser Login: Even Closing a Pop-Up Became a Problem

    My first attempt was to have AI write a browser login script. Several problems appeared:

    • Incorrect element selectors: The script targeted the wrong search field, so subsequent searches were incorrect. Those errors propagated silently through the pipeline, making them difficult to trace.
    • Unexpected pop-ups: CAPTCHA prompts and advertising pop-ups caused the script to wait indefinitely, effectively freezing the workflow.
    • Misclicks: When trying to close a pop-up, the AI clicked the wrong location and sometimes closed the entire page, wasting the work already completed.

    The solution was to turn error handling from an implicit assumption into explicit rules:

    • After every page interaction, check whether a pop-up is present and handle it before continuing.
    • Verify that every critical element exists before interacting with it.
    • If element lookup fails, retry or use a fallback path.
    • Add timeouts and a circuit-breaker mechanism so that one stalled step cannot block the entire pipeline indefinitely.

    Once these defensive programming requirements were clearly stated, the login stage became significantly more stable.

    3.2 Visual Recognition: Moving from Expensive Models to Local Processing

    Converting screenshots into numerical data was the core of the workflow—and its most difficult stage.

    I tried several tiers of vision-language models, or VLMs:

    • Lower-tier free VLMs: Some could not reliably distinguish colors. Large portions of the resulting numerical matrices were wrong, making them unusable.
    • Mid-tier VLMs: Accuracy improved, but visual misinterpretations remained common. A model might read a 5 as a 3 or identify red as blue. Checking hundreds of images manually was not a practical safeguard.
    • Higher-tier VLMs: Recognition improved further, but each image cost a fraction of a yuan to process. At 300 images per day, that added up to tens of yuan daily and a substantial monthly expense.

    The key realization was that a general-purpose vision model was excessive for charts with fixed layouts and clearly defined color meanings. I was paying for broad visual capabilities when the task mainly involved interpreting structured blocks of color.

    The Local Alternative

    I had the AI write a color-based recognition script using common local image-processing libraries. Its logic was simple:

    1. # Illustrative logic: color clustering and block mapping
    2. 1. Load the screenshot and convert it to a standard color space, such as HSV.
    3. 2. Cluster colors using predefined thresholds and segment the data blocks.
    4. 3. Map each block's color to a predefined numerical lookup dictionary.
    5. 4. Output a numerical matrix corresponding to the screenshot.

    The script ran locally, required no network connection, and consumed no model tokens. In my workflow, recognition accuracy was close to 100%.

    The lesson was not that VLMs are useless. It was that rule-based algorithms can be much more cost-effective when the input structure is fixed. General-purpose vision models are better reserved for tasks that genuinely require semantic understanding.

    3.3 Correcting the AI: Breaking the Repeated-Error Loop

    I initially assumed that once I pointed out a mistake, the AI would avoid it next time. Instead, I encountered a recurring cycle:

    1. The AI makes a mistake → I correct it → It follows the correction temporarily
    2. → The same mistake returns a few days later → I correct it again

    Three issues drove this pattern:

    • Corrections existed only in the conversation context. Starting a new session meant those corrections were no longer available.
    • Instructions were scattered. The AI had no clear way to determine which rule took priority when instructions conflicted.
    • There was no enforced validation. A promise to fix an error did not mean the next output would actually be correct.

    The solution was to replace conversational corrections with persistent, enforceable constraints.

    1. Document the rules. After each correction, record the lesson in a persistent rules document and have the AI load it at the start of every task.
    2. Assign rule IDs and priorities. Number the rules and specify their priority so conflicts have a clear resolution.
    3. Require an output self-check. Before returning a result, have the AI check it against the rule list and revise anything that fails.
    4. Add code-level assertions. Validate properties such as matrix dimensions and allowed value ranges. Reject invalid results and rerun the relevant work rather than relying on the AI to notice its own mistakes.

    This shifted the AI from an assistant that repeatedly needed reminders to an executor working from a defined operating manual.

    4. Four Practical Lessons to Reuse

    1. Evaluate Cost and Benefit Before Choosing a Model Tier

    Do not default to a general-purpose model for a structured task that a rule-based algorithm can handle. Reserve large models for stages that need understanding, reasoning, or generation.

    2. Make Exception Handling Explicit

    Login flows, element lookup, and pop-up handling are fragile parts of browser automation. Clear defensive rules, timeouts, and circuit breakers are essential to keeping failures contained.

    3. Make Corrections Persistent, Not Conversational

    A correction buried in a chat is not a durable operating rule. Record corrections in a persistent document and reload them for each task to break the repeated-error cycle.

    4. Put Automated Validation Ahead of AI Self-Checks

    Critical outputs need automated assertions. Neither manual inspection nor an AI’s assurance that it followed the instructions is a reliable substitute for checking the actual result.

    Automation is not simply handing a task to an AI and waiting for it to finish. It is a systems-engineering effort built around rule design, workflow orchestration, and result validation.

    Those seven days of trial and error made that distinction clear—and produced a workflow that could finally handle the full task.