Building Agent Automation Closed-Loops for Legacy Systems Without APIs

    Many legacy systems — internal management tools, industry-specific software, commercial suites purchased years ago, and undocumented back-office applications — can log in, fill forms, upload PDFs, and trigger approvals, yet expose almost no stable interface. This leaves developers with two options: reworking the system by adding an API layer, or fragile record-and-replay scripts. GUI-capable AI agents offer a middle path, but closing a production-grade task chain takes more than clicking. This article breaks down the four capability gaps (action, locating, knowledge, and files), explains how to choose between visual operation and structure-based locating, and shows how to start from a minimal, low-privilege, rollbackable, and result-verifiable closed-loop backed by engineering safeguards such as idempotency, exception handling, auditability, and least privilege.

    Why Legacy System Automation Has Long Been Difficult

    In many enterprise environments, there’s a class of “legacy” systems: internal management tools, industry-specific software, commercial suites purchased years ago, and old back-office applications with no external documentation. They can log in, fill out forms, upload PDFs, and trigger approvals, but they offer almost no stable, callable interface. When developers try to plug them into automation, they’re usually left with just two paths.

    The first is reworking the system — adding an API layer or middleware. This is the cleanest route, but it’s often constrained by the original vendor’s scheduling, missing source code, or the supplier no longer maintaining the product; timelines are measured in months or even quarters. The second is record and replay — scripts that record fixed click coordinates or control paths and then replay them as-is. It has a low barrier to entry but is extremely fragile: once the page version updates, an element shifts position, or a pop-up order changes, the script breaks immediately and maintenance costs spiral out of control.

    In recent years, agents capable of operating graphical interfaces have gradually matured, offering a new middle path for these scenarios: without reworking the system and without relying on fixed coordinates, the model “operates by looking at the screen.” But to truly run a production-grade workflow, being able to click is far from enough.

    Why a Complete Task Chain Is Hard to Close

    Putting legacy system automation into practice really comes down to closing a complete chain from “receiving the materials” to “filling results back into the legacy system.” Four consecutive gaps have long existed along this chain, and if any one of them breaks, the workflow can’t be delivered.

    • Action: The agent must be able to actually perform interface actions like clicking, typing, and scrolling.
    • Locating: The agent must reliably find target fields and buttons within a form, rather than relying on hard-coded coordinates.
    • Knowledge: The agent must understand business knowledge such as the team’s numbering conventions, review criteria, and field constraints.
    • Files: The agent must carry input files (such as customer-uploaded PDFs) and output files along the same chain and archive them.

    Each of these four capability types corresponds to a typical failure point. An agent that only knows how to click but not the business numbering rules fills in the wrong data; one that only knows the rules but can’t obtain the customer’s actual files can offer only “verbal suggestions”; one with all the files in place but still locating by pixel coordinates clicks the wrong spot the moment the page changes. So the real value doesn’t come from how strong any single capability is, but from whether these gaps can be closed continuously, carrying the chain all the way from material input to a deliverable result.

    The Division and Abstraction of the Four Capabilities

    Abstracting the capabilities above into general-purpose technical components makes their respective responsibilities and boundaries clearer.

    Screen Visual Operation: Aiming at the Whole Desktop

    The typical form of this capability is: the model receives a screen screenshot and then outputs mouse and keyboard actions to complete clicking, typing, scrolling, and so on. Its biggest advantage is broad coverage — anything a person can see and operate on the desktop can, in principle, be reached, regardless of whether the system has an interface. This makes it especially suitable for workflows that chain together across multiple desktop applications (for example, first exporting in one client, then processing in another tool, and finally sending the result back to the legacy system).

    On the engineering side, the efficiency of action scheduling matters. If every action requires a round trip to the model, the chain becomes very slow and costly; a more mature approach allows a single response to return multiple ordered actions, batching tightly coupled operations like “click — wait — type — submit” into one dispatch to reduce round-trip overhead.

    Page Structure Parsing: Aiming at In-Page Tasks

    When the task stays stably within the browser, there’s a more reliable path: in addition to visual information, directly read the page’s structure information (the semantics of fields, buttons, and interactive elements) to target precisely, rather than depending on fixed pixel coordinates. Structure-based locating is especially friendly to form filling, list operations, and multi-step flows, and it’s more robust when the page layout changes slightly.

    It’s worth emphasizing that structure parsing is not a “read once and done forever” solution. The page structure itself can change, and pop-ups, nested canvases, permission prompts, and dynamic loading can all interfere with locating, so production workflows still can’t skip result verification and exception branches.

    Task Knowledge Injection: Packaging Rules into the Workflow

    Whether going the visual or the structure route, the agent needs to “know what to do.” Through task knowledge / rule injection, structured knowledge — the team’s numbering rules, review standards, field mappings, and exception-handling conventions — can be delivered along with the task, keeping the model judging with a consistent standard throughout execution. This effectively makes the tacit experience scattered across documents and people’s minds explicit within the automation workflow, reducing the risk of “filling it in but filling it in wrong.”

    File Flow: Passing Input and Output Along the Chain

    Real business is almost inseparable from files. The agent needs to read user-uploaded input files (such as PDFs and spreadsheets), extract information from them to fill into the system, and at the end of the workflow archive the output files or write them back to a designated location. Passing input and output files along the same chain is the key link that allows “from receiving materials to delivering results” to close.

    Visual Operation or Structure-Based Locating: A Line for the Decision

    The choice between these two paths can be compressed into a single sentence: use visual operation when the task spans desktop applications, and prefer structure-based locating when the task stays stably within a web page.

    The following pseudocode illustrates the judgment:

    1. if the task stays entirely within a single web app:
    2. prefer structure-based locating # more robust, fewer round trips
    3. for pop-ups / nested canvases where structure fails, fall back to visual operation
    4. else: # the task spans multiple desktop apps
    5. use visual operation # coverage first
    6. when needed, supplement the same screen region with structure info for accuracy

    The two are not mutually exclusive. In practice, the more reliable combination is: use structure-based locating as the main trunk, and switch to visual operation as a fallback for the local areas where structure parsing fails, balancing robustness and coverage.

    Starting from a Minimal Closed-Loop: Low Privilege, Rollbackable, Verifiable

    Agents directly operating real business systems carry inherent risk. So the rollout strategy shouldn’t aim for full-process automation in one step, but should follow three principles, starting from flows that are low-privilege, rollbackable, and result-verifiable.

    • Start with low privilege: First use a read-only or low-impact account, choosing “even if it goes wrong, it’s not fatal” scenarios to validate the chain — such as query or draft operations — then gradually transition to write operations.
    • Design for rollback: Write operations should be undoable or redoable, for example by writing to a draft area first and submitting after manual confirmation, or by keeping a snapshot and logs before the operation, ensuring you can retreat when something goes wrong.
    • Results must be verifiable: Every automation run should have a clear success criterion. Don’t treat “the click was issued” as success; instead, base it on “whether the target field in the system was correctly written and whether the file landed,” verifying by reading back the interface or data rather than trusting the action itself.

    On this basis, production-grade workflows should also include the following engineering constraints:

    1. Idempotency and deduplication: When the same task is triggered repeatedly, it should not produce duplicate submissions, avoiding dirty data;
    2. Exception branches and human fallback: At nodes that can’t be handled automatically — structure changes, CAPTCHAs, permission prompts — the system should recognize them and hand off to a human rather than blindly retrying;
    3. Audit and traceability: Fully record every action, screenshot, input/output file, and judgment result to make post-hoc investigation and accountability easier;
    4. Least privilege and credential management: The credentials held by the automation process should follow the principle of least authorization and be properly protected to avoid becoming a new attack surface.

    Summary

    For legacy systems without interfaces, agent automation offers a viable route between “reworking the system” and “record and replay.” Its value lies not in any single capability, but in continuously closing the four capabilities — action, locating, knowledge, and files — into a complete task chain from materials to results. On the engineering side, use “whether the task spans desktop applications” as the criterion for choosing between visual operation and structure-based locating, with each serving as the other’s fallback; at the same time, insist on starting from a minimal closed-loop that is low-privilege, rollbackable, and result-verifiable, using safeguards such as idempotency, exception branches, auditing, and least authorization to keep production environments robust and controllable.