AI Automation: 7 Days, 3 Fatal Pitfalls, and How to Fix Them

    A practical breakdown of what actually goes wrong when you chain AI coding tools into a deterministic automation pipeline. You will learn why serial multi-step workflows collapse, how to replace model-based interaction handling with an explicit state machine, why general-purpose vision models fail on chart-to-number extraction, and how to turn conversational corrections into durable engineering assets with scheduling, observability, and cost control.

    Introduction: When Manual Labor Starts Eating Your Core Energy

    In data trend analysis, competitor monitoring, or content operations, one category of task is the most draining: logging into several websites at fixed times every day, running searches, taking screenshots, reading each trend chart one by one, labeling values, applying algorithm dictionaries, and finally compiling everything into a table. The technical barrier is low, but the attention cost is enormous. A skilled analyst may need half a day to collect and read more than three hundred trend charts, ending up with sore eyes, a foggy brain, and no time even to drink water.

    My previous approach was a “hot topic radar + AI coding assistant” combination built to solve hot-topic discovery for content planning. Since both browser interaction and information processing can be taken over by automation, the “screenshot - read - calculate - aggregate” chain should in theory also be handed to an automated workflow. So I took an old laptop and spent seven days iterating with an AI coding tool, cycling through six different model configurations, until the full pipeline finally ran end to end.

    This article does not retell a success story. Instead, it abstracts the most valuable failure lessons from those seven days: the real difficulty in automation is not “getting AI to write code,” but making uncertain model output fit stably into an engineering pipeline that demands determinism.

    1. Decompose the Workflow First: Where the Fragility of a Seven-Step Chain Comes From

    The automation chain I designed has seven stages: log into the target site → run a precise search → capture a screenshot of the root node → capture screenshots of comparison items → map images into a numeric matrix → output results according to an algorithm dictionary → aggregate statistics.

    The structural problem with this chain is that it is a serial system, so the overall success rate equals the product of the success rates of each stage. Assume 95% accuracy per step: after seven multiplications, the result is under 70%. At 90% per step, only 48% remains. In other words, a single “good enough” point gets amplified into “unusable” across a long chain. The engineering focus, therefore, is not making one stage spectacular, but pushing the failure rate of every stage extremely low and designing fallbacks for failure.

    2. Pitfall 1: Handing Interaction Tolerance to the Model Guarantees Repeated Login Failures

    At first I had the AI coding tool generate simulated login scripts directly, and new failures appeared almost every day: the search box resolved to the wrong node and returned results that did not match expectations; the site threw up a CAPTCHA or an operations popup, and the script waited in place until timeout. I repeatedly described “please close the popup first,” taught it more than fifty times, and it still clicked the wrong close button, sometimes closing the entire page.

    The root cause is clear: models are good at generating code but bad at handling unenumerated UI states at runtime. Relying on natural-language reminders for tolerance logic applies probabilistic reasoning where determinism is required.

    The reliable approach is to abstract interaction into an explicit state machine and to strip selectors and waiting strategies out of model output, managing them through fixed configuration:

    1. # Illustration: drive page interaction with a state machine; selectors and timeouts live in central config
    2. CONFIG = {
    3. "login": {"user": "#username", "pwd": "#password", "submit": "button.login"},
    4. "popup": {"close": ".dialog .close", "timeout_ms": 1500},
    5. "search": {"input": "#q", "submit": ".search-btn"},
    6. }
    7. def dismiss_popups(page, cfg=CONFIG["popup"]):
    8. """Close overlay layers in a loop with a bounded number of attempts to avoid an infinite loop"""
    9. for _ in range(3):
    10. btn = page.query_selector(cfg["close"])
    11. if not btn or not btn.is_visible():
    12. return True
    13. btn.click()
    14. page.wait_for_timeout(cfg["timeout_ms"])
    15. return False

    Three supporting practices: first, locate all elements with stable semantic selectors and avoid depending on volatile coordinates or text; second, set explicit waits and timeouts at every step, and forbid infinite polling; third, capture a screenshot on failure to preserve the scene, turning “let the AI guess the cause” into “let a human look at the evidence,” which improves diagnosis speed by an order of magnitude.

    3. Pitfall 2: Trusting a General-Purpose Vision Model Makes Both Cost and Accuracy Spiral Out of Control

    The most central and most expensive stage is restoring screenshots into a numeric matrix. I initially relied entirely on general-purpose vision-language model APIs: starting from a model within the free tier, it misjudged even basic colors and the matrix was almost entirely wrong; switching to a mid-tier model improved things slightly, but obvious visual hallucinations remained, frequently reading “5” as “3” and “red” as “blue”; moving up to a high-capability model raised accuracy, but the per-image cost was counted in cents, and three hundred images a day meant tens of yuan, with a monthly cost that was completely unacceptable.

    Two widely misunderstood conclusions need correcting here. First, a general-purpose vision model is a probabilistic generation model whose output is not guaranteed to be reproducible: the same image can yield different answers on two calls, while a data pipeline requires idempotence. Second, cost grows linearly with call volume while accuracy gains are marginally diminishing, so buying precision by stacking model capability does not hold up commercially.

    The right approach is dimensionality reduction on the task: reading a trend chart is essentially a deterministic geometry problem of “known legend color values + known axis range + pixel positioning” and requires no semantic understanding. Using a local image processing library for color segmentation and coordinate conversion produces stable results offline at zero call cost:

    1. # Illustration: extract bar heights/point positions from a color mask, then map linearly to values
    2. import cv2, numpy as np
    3. def extract_values(img_path, color_bgr, axis_y0, axis_y1, v_min, v_max, cols):
    4. img = cv2.imread(img_path)
    5. hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    6. mask = cv2.inRange(hsv, color_bgr[0], color_bgr[1]) # preset lower/upper hue bounds
    7. vals = []
    8. for i in range(cols):
    9. x0, x1 = int(i * img.shape[1] / cols), int((i + 1) * img.shape[1] / cols)
    10. ys = np.where(mask[:, x0:x1].any(axis=1))[0]
    11. if ys.size == 0:
    12. vals.append(None); continue # mark missing explicitly instead of filling 0
    13. y = ys.min() if axis_y0 < axis_y1 else ys.max()
    14. vals.append(round(v_min + (y - axis_y0) / (axis_y1 - axis_y0) * (v_max - v_min), 2))
    15. return vals

    Only when the chart’s shape genuinely cannot be parsed by rules should a vision model be introduced as a fallback, and its output must be constrained to structured data (such as strict JSON) with a second validation pass: automatically trigger re-capture or human review when values are out of range, the missing ratio is abnormal, or the jump between adjacent points exceeds a threshold. The role of the hybrid strategy must be clear: rules own the main path and the cost, the model owns the long tail and the fallback.

    4. Pitfall 3: Treating Correction as Training Traps You in a Loop of Repeated Mistakes

    The third and most mentally exhausting step was correcting the AI coding tool’s mistakes. My expectation was “tell it what went wrong and it will not do it again.” In reality: it errs → I correct it → it briefly remembers → it errs again two days later → I correct it again, recurring endlessly. This is usually summarized as context degradation: in a long conversation, early constraints get diluted and the model reverts to the common patterns in its training distribution.

    The way out is to upgrade “conversational memory” into “engineering assets,” so constraints exist independently of the session:

    • Create a project-level rules file that hard-codes the tech stack versions, directory structure, prohibited items, and naming conventions, loaded automatically for every task.
    • Accumulate reusable modules: solidify login, popup handling, screenshots, and parsing into tested functions, so new requirements only involve orchestration rather than rewriting the foundation.
    • Prepare a fixed sample set and assertions for each parser, and run regression first after any change, judging correctness by tests rather than memory.
    • Keep task decomposition small and verifiable, delivering one runnable piece at a time and avoiding large-scale refactors that introduce uncontrollable changes.
    • Keep a change trail recording failure symptoms, root causes, and fixes, forming a searchable problem library for the team.

    5. Engineering Wrap-Up: Scheduling, Observability, and Cost Control

    Getting the pipeline to run is only the starting point; only long-term unattended operation counts as delivery. Three things should be added: for scheduling, trigger with scheduled jobs and build in idempotence plus a retry limit to avoid duplicate writes; for observability, write per-step duration, success rate, and failure screenshots into a unified logging service, with monitoring and alerts that notify on consecutive failures; for data landing, use a layered approach of “raw screenshots into object storage, structured results into a database” to guarantee traceability and recomputability.

    On cost control, keep the vast majority of calls in local computation and use cloud capabilities only when necessary; heavy work can be run elastically on a container platform so that old hardware does not become the bottleneck. After this rework, processing three hundred images that previously took half a day was compressed to minutes, with marginal cost close to zero.

    Conclusion

    The biggest takeaway from these seven days was not a particular technique but a shift in perception: an AI coding tool is an efficient code producer, not a runtime guardian. Anything that demands determinism, reproducibility, and low cost should be handled by rules and local algorithms; only what is ambiguous, long-tail, and requires semantic understanding should be handed to a model, and it must be backed by validation and fallbacks. Draw that boundary clearly, and automation becomes genuinely stable.