Troubleshooting

How AI Can Diagnose and Repair Automation Workflow Failures

An error message names a symptom. Give AI the workflow and execution evidence it needs to identify the root cause, propose a narrow repair, and verify the result.

By Runavelo 10 min read

The hardest automation failures are rarely explained by one error string. A message such as "element not found" identifies a symptom, but not whether the cause is a changed selector, the wrong browser tab, an unfinished page load, a disconnected extension, an overlay, an expired login, or an earlier command that produced unexpected data. Generic advice—wait longer, retry, or recapture the element—may temporarily hide the problem without fixing it.

AI becomes more useful when it can investigate the same evidence an experienced engineer would request: the complete visual workflow, the failing command, relevant parameters, recent runtime logs, the error stack, element metadata, and the state established by earlier steps. The model can then connect a failure to the structure that produced it and recommend a targeted change. The repair is not complete until the workflow is rerun through the failing scenario and its output is verified.

This article presents a practical evidence-first method for AI-assisted troubleshooting, using a multi-page browser collection workflow as the primary example.

Key takeaways

  • Treat the final exception as a starting point, not a diagnosis.
  • Give AI the smallest complete evidence set needed to reconstruct the failure.
  • Separate root cause, contributing conditions, and observed symptom.
  • Prefer a narrow workflow or locator repair over broad regeneration.
  • Verify the fix across the original failure and at least one adjacent boundary case.
  • Protect secrets and personal data when collecting diagnostic context.

Why the error message is not enough

Automation commands depend on state created by previous commands. A click needs a valid webpage object and a uniquely located element. Input needs the intended field to be present and ready. A spreadsheet write needs the expected data shape and a writable destination. When line 30 fails, the root cause may have started at line 4.

Consider several paths to the same ElementNotFound symptom:

  • the browser opened a login page instead of the expected results page;
  • the workflow retained a reference from a previous navigation;
  • a selector included a page-specific accessibility label;
  • the target appeared inside an iframe not represented in the locator;
  • a cookie banner covered the control;
  • the loop advanced before asynchronous content finished loading;
  • the previous branch left the webpage variable empty;
  • the extension or native bridge was not connected.

If an assistant sees only the last line of the stack, it cannot distinguish these cases. It may produce plausible but low-value prose. If it sees the flow and runtime evidence, it can ask which precondition failed and trace backward.

Build a diagnostic evidence package

A useful troubleshooting request should include structured context rather than a raw dump of everything the application knows.

Workflow structure

Provide the workflow and subworkflow names, parent-child nesting, line numbers, and the commands around the failure. The assistant should know whether the failed action was inside a loop, condition, retry block, or parallel branch. Include the saved command parameters and relevant input/output variable names.

Execution timeline

Provide recent log entries from before the failure through the exception. Timestamps, command line, severity, page number, record counts, and navigation markers reveal ordering. The OWASP Logging Cheat Sheet lists debugging, business-process monitoring, performance monitoring, and information about unusual conditions among important operational uses of application logs. It also recommends recording details such as time, code location, action, object, result status, reason, and extended error information. See the OWASP Logging Cheat Sheet.

Error and stack

Preserve the exception type, message, command, and stack frames that belong to the application. Do not show a generic failure to the AI while hiding the actual internal reason. At the same time, avoid exposing internal details to unrelated end users. OWASP's Error Handling Cheat Sheet distinguishes user-facing error handling from server-side diagnostic logging.

Runtime objects and element metadata

For browser failures, include the target page URL or a redacted form, tab identity, element display name, locator attributes, relationship path, and whether multiple or zero matches were found. For data failures, include types, lengths, and representative redacted values. For spreadsheet failures, include the file operation, worksheet, range, and access error.

Environment facts

Capture the browser type, extension version, relevant client version, connectivity state, and whether the expected page was active. Environment facts should be observations, not guesses. "Chrome was open" is weaker than "the extension reported version X and tab Y matched the expected URL."

Protect sensitive data while preserving evidence

Diagnostic context can contain passwords, API keys, session cookies, authorization headers, personal information, file paths, and proprietary records. More context is not always better.

Before sending evidence to any model:

  • remove passwords, tokens, cookies, and authorization headers;
  • replace personal values with stable placeholders when identity is irrelevant;
  • include only the log window needed to reconstruct the failure;
  • summarize large datasets with schema, counts, and representative samples;
  • avoid uploading screenshots that reveal unrelated applications;
  • follow the selected model provider's data-handling policy and organizational rules.

OWASP warns that logs may contain personal or sensitive information and should be protected from unauthorized access, modification, and deletion. A good AI integration should make redaction a design feature, not an afterthought.

Diagnose from symptom to root cause

A disciplined diagnosis answers four questions in order.

1. What exactly failed?

Identify the command, line, target object, attempted action, and immediate exception. For example: "Line 30, Scroll Web Element into View, found no element matching the captured Amazon Next Page Button on page two."

2. Which precondition was false?

List what the command required: the intended tab, a loaded results page, one matching element, an unobstructed target, and a connected browser integration. Test each requirement against the evidence.

3. Why was that precondition false?

Trace to the earliest evidence-backed cause. If the locator expected aria-label="Go to next page, page 2" but the current page exposed aria-label="Go to next page, page 3", the root cause is an unstable page-number-specific attribute. "Element not found" is the symptom.

MDN documents that aria-label defines a string used as an accessible name for supported elements. That makes it valuable semantic information, but not every label is stable across application state. See MDN's aria-label reference and accessible-name overview.

4. What is the smallest durable repair?

Disable the volatile attribute and retain stable identifying information, such as the semantic role, a stable class, or the relationship to the pagination container. Do not regenerate the entire workflow if one locator property is wrong. Broad changes increase the verification surface and can silently alter correct behavior.

A detailed pagination failure example

Assume a workflow collects products from page one, clicks Next, and fails while trying to find the same control on page two.

The evidence package contains:

  • a successful log entry for page one with 53 products;
  • a successful CDP click on the captured Next control;
  • a log showing collection started on page two;
  • a failure at the command that scrolls the Next control into view;
  • captured metadata requiring an exact aria-label ending in page 2;
  • the current page DOM showing the equivalent label ending in page 3.

The diagnosis should state:

  1. Navigation succeeded, so the click and page transition were not the failure.
  2. The workflow reached page two and collected records, so browser connectivity remained available.
  3. The element locator was reused after page state changed.
  4. Its exact accessible label encoded the next target page number.
  5. The resulting mismatch produced zero elements on the second iteration.

The repair changes only the captured element matching rule. It may use a stable pagination class plus role or a relationship-scoped selector. The assistant should explain why the retained attributes identify one control and why the removed property is volatile.

The W3C WebDriver specification defines a stale element reference as a reference to a node that is no longer connected to the active document. Runavelo's locator implementation is not identical to WebDriver, but the specification captures a general browser-automation reality: DOM identity and page state change after navigation. See the W3C WebDriver specification.

Distinguish common browser failure classes

Not every element failure is a selector problem. Classifying the failure prevents the assistant from applying the same fix everywhere.

Locator mismatch

Zero elements match because one or more captured properties changed. Compare current metadata with the saved locator and remove only volatile constraints.

Ambiguous locator

Multiple elements match. Narrow the search with a stable parent, role, relationship, or distinguishing property. Selecting the first match without justification can click the wrong record.

Timing failure

The correct element appears after the wait expires. Replace arbitrary sleeps with a wait for a meaningful page or element condition, then choose a timeout based on observed latency.

Obstruction or interaction state

The element exists but an overlay intercepts interaction, the control is disabled, or it is outside the expected viewport. Diagnose page state rather than weakening the selector.

Wrong context

The workflow targets the wrong tab, frame, subworkflow variable, or browser session. Verify object provenance and current URL before editing the element.

Integration failure

The browser extension or native bridge is unavailable. A locator repair cannot restore a disconnected transport. Check versions and connectivity first.

Ask AI for an evidence-backed answer

A strong troubleshooting instruction can require a consistent response format:

  1. Observed failure: command, line, and direct exception.
  2. Root cause: earliest supported cause, with evidence.
  3. Contributing conditions: timing, environment, or workflow design factors.
  4. Proposed repair: exact command, parameter, or locator change.
  5. Risk of the change: what else the repair might match or affect.
  6. Verification plan: steps and expected evidence for proving the fix.

This format discourages unsupported certainty. If evidence is missing, the assistant should say what it cannot determine and request a focused observation. NIST describes the AI Risk Management Framework as a voluntary framework for incorporating trustworthiness into AI design, development, use, and evaluation. Its materials emphasize valid and reliable behavior, accountability, transparency, explainability, testing, and documented evaluation. See the NIST AI RMF overview and AI RMF FAQ.

Apply repairs safely

An assistant capable of editing a workflow should not silently make unlimited changes. Scope the repair to the failing flow and preserve a before/after representation. Validate every enum, required parameter, variable reference, and child relationship before accepting the modified JSON.

For higher-impact actions, show the proposed change before execution. A selector update is usually lower risk than changing a file destination, deleting data, submitting a purchase, or sending a message. The approval model should match the consequence.

After a generated edit, convert the workflow through the same serialization path used by the product and regenerate executable code. Syntax validation catches malformed expressions, but it does not prove behavior. Runtime verification remains necessary.

Verification is part of the repair

A convincing explanation is not proof. Rerun the original failing scenario and continue beyond it.

For the pagination example, a useful verification sequence is:

  • page one collects the expected number of records;
  • the workflow transitions to page two;
  • the repaired locator finds the Next control on page two;
  • the workflow transitions to page three;
  • later pages continue without using a fixed page number;
  • the final page stops because no next page exists;
  • the workbook contains the expected headers and plausible row count;
  • logs show normal completion rather than a swallowed exception.

Also test the adjacent boundary: a page with the Next control disabled or absent. A selector that now matches every pagination item may make the original failure disappear while introducing an incorrect click. Verification should prove both successful continuation and correct termination.

Improve future diagnosis with better logs

If troubleshooting repeatedly requires screenshots and manual reconstruction, improve observability in the workflow itself. Useful events include:

  • workflow and subworkflow start and finish;
  • command line and command name;
  • page URL or a safe page identifier;
  • current iteration and page number;
  • number of element matches;
  • records collected per page and running total;
  • wait duration and timeout reason;
  • branch selected and stop condition;
  • output path and rows written;
  • exception type and relevant stack.

Do not log secrets or complete sensitive payloads. Prefer stable IDs, counts, types, and redacted samples. Test the logging path too: OWASP recommends verifying behavior when logging storage, permissions, connectivity, or capacity fail.

Conclusion

AI-assisted troubleshooting works best as structured investigation, not conversational guesswork. The error message identifies where the runtime stopped. The workflow shows intended logic. Parameters and objects show what the command received. Logs reconstruct the sequence. Element metadata and browser state reveal what changed. Together, that evidence allows AI to explain a root cause and propose a narrow repair.

The final standard is operational, not rhetorical: the modified workflow must rerun, pass the original failure, handle the adjacent boundary, and produce valid output. When AI can read an editable workflow and its execution evidence, it becomes a useful diagnostic partner without hiding the automation behind a black box.

References

  1. OWASP Logging Cheat Sheet
  2. OWASP Error Handling Cheat Sheet
  3. W3C WebDriver specification
  4. MDN: aria-label attribute
  5. MDN: Accessible name
  6. NIST AI Risk Management Framework
  7. NIST AI RMF FAQs
BUILD SOMETHING USEFUL

Turn a goal into an editable workflow.

Use AI to build, inspect, revise, and troubleshoot automation, then run the approved steps repeatedly.