Intelligent Legacy System Automation: From Desktop Operations to Closed-Loop Execution
Legacy systems often lack stable APIs but still carry core business workflows. Traditional automation approaches either require costly system overhauls or rely on brittle scripts. This article explores how AI agents equipped with visual understanding, tool calling, and business rule execution can be used to automate legacy systems. It covers the division of labor between desktop operations and web structure positioning, integrating enterprise rules, managing file flows, and a "Plan-Execute-Verify" model to ensure safe, reliable, and closed-loop automation.
In enterprise informatization, numerous legacy systems still handle core business operations: customer data entry, order approval, financial reconciliation, invoice uploading, ticket routing, and internal approvals. While these systems are often accessible via browsers or desktop interfaces, they typically lack stable, comprehensive, and callable APIs.
Traditional automation generally follows two paths. The first is to modify the original system by adding interfaces or rebuilding business modules. However, this usually requires a long development cycle and may be constrained by vendors, legacy code, and permission structures. The second path involves using fixed scripts to simulate manual operations, such as clicking buttons via coordinates, inputting text, and uploading files. This approach yields quick results initially, but even minor changes in page layout, pop-ups, screen resolution, or permission prompts can cause the scripts to fail.
AI agents based on visual understanding and tool calling offer an alternative approach: allowing the model to observe the screen, understand the page, and execute actions like a human operator, while incorporating enterprise rules, business documents, and validation processes into a single task chain. However, this does not mean all legacy systems are suitable for direct handover to agents. A reliable approach requires defining capability boundaries and starting with low-risk, low-privilege, reversible processes where results are easy to verify.
1. What Legacy System Automation Truly Lacks Is Not Just “Clicking Ability”
Many people equate desktop automation with “letting a model replace the mouse and keyboard.” However, in real-world business scenarios, simply being able to click on a page is far from enough. A complete task includes at least five components:
- Understanding the task objective: Clarifying what materials need processing, which fields to fill out, and what business outcome to achieve.
- Locating the operation target: Finding the correct system, menu, record, field, and button.
- Following business rules: Determining data formats, approval conditions, and exception handling based on team standards.
- Managing input/output files: Reading attachments, extracting content, uploading files, and saving the final result.
- Verifying the task result: Confirming that the system successfully saved the data, key fields are correctly populated, and files were uploaded without error.
Past automation solutions often covered only part of this cycle. For instance, scripts could open a page but couldn’t understand different review rules for various customers; models could generate filling suggestions but couldn’t write results back to a backend without APIs; files were prepared, but the automation program couldn’t determine which record they should be uploaded to.
Therefore, the combined value of desktop operations, web structure positioning, rule knowledge, and file transfer lies not in the sheer number of features, but in how they collectively complete the task loop.
2. Division of Labor Between Desktop Operations and Web Structure Positioning
1. Desktop Operations for Cross-Application Workflows
Desktop operation capabilities are typically based on screen images. The agent can read the current interface and execute actions like clicking, typing, scrolling, copying, and pasting based on visual information.
These capabilities are suitable for the following scenarios:
- Switching between multiple desktop applications is required;
- The legacy system is only accessible via a visual interface;
- The page uses nested windows, remote desktops, or special controls;
- The task involves a browser, file manager, and local business software simultaneously;
- The system lacks readable page structures.
For example, an operator might need to retrieve a file from an email attachment, open a legacy backend to search for a customer record, upload the processed file to a specific location, and finally log the result locally. Such a task spans multiple applications, and web positioning alone cannot cover all steps.
However, visual operations carry inherent uncertainties. Different screen sizes, browser zoom levels, pop-up occlusions, loading delays, and theme changes can all lead to model misjudgments. Therefore, desktop operations should not be designed to “execute blindly”; they must be paired with screenshot confirmation, state assessment, and failure retries.
2. Web Structure Positioning for Stable Page Tasks
If a task always occurs within a web page and the page can provide recognizable structural information, directly reading the page structure is usually more stable than relying on pixel coordinates.
Web structure positioning helps the agent identify:
- Labels corresponding to input fields;
- Rows and columns in tables;
- Semantics and states of buttons;
- Dropdown options and their available values;
- Validation prompts on the page;
- Unique identifiers of current records.
For example, “fill the phone number into the third input box on the right side of the page” relies on visual position, whereas “update the phone number field to a specified value” relies on page semantics. The latter is less susceptible to changes in window size and page layout.
Still, structured positioning is not absolutely reliable. Some pages may use canvas rendering, nested components, dynamic loading, or access controls, leading to incomplete structural information. Pop-ups, secondary confirmations, CAPTCHAs, and session expirations can also interrupt automation. Therefore, production systems typically require structured positioning and visual judgment to complement each other.
A simple principle can be applied:
- Prioritize desktop operations for cross-desktop applications, unreadable structures, or special controls;
- Prioritize structured positioning for tasks focused on web forms, lists, and record processing;
- Retain visual or structured evidence for review before and after executing critical actions.
3. Enabling Agents to Understand Enterprise Rules
Just because a model can read a page doesn’t mean it understands the enterprise business. If an agent doesn’t know the meaning of fields, approval standards, and exception handling methods, it can easily result in “correct operation but incorrect business outcome.”
Enterprise rules typically include:
- Dependencies between fields;
- Format requirements for amounts, dates, and IDs;
- Which scenarios require manual review;
- Which fields are read-only and cannot be modified;
- Actions permitted for different roles;
- File naming and archiving conventions;
- Checklist items that must be completed before submission.
This information should not rely solely on the model’s temporary inference but should be provided to the agent as structured knowledge or explicit task instructions. For example, rules can be broken down into five sections: “Input Requirements, Processing Steps, Prohibitions, Validation Standards, Exception Branches.”
A reliable task instruction might look like this:
Task Objective: Enter pending review materials into the business system.Input Materials: Customer profile file, review checklist.Allowed Modifications: Contact person, address, attachment description.Prohibited Modifications: Customer ID, historical transaction amount.Pre-submission Checks:1. Customer ID must match system records;2. Dates must use the specified format;3. Do not submit if required attachments are missing;4. Transfer to manual review if there are discrepancies in amount fields.Completion Criteria: Successfully saved, and record the result information returned by the system.
This expression is far more reliable than “please complete the data entry,” as it explicitly defines the objectives, constraints, and acceptance criteria simultaneously.
4. File Flow as an Integral Part of the Task Loop
In real-world business, files are often the starting and ending points of a task. The agent may need to read contracts, spreadsheets, scanned documents, or proof materials, extract information from them, and upload the processed files to the legacy system.
The file chain should consider at least four issues.
1. Is the File Source Trustworthy?
It is necessary to record where the file came from, when it was received, whether it is complete, and whether it belongs to the current task. File ownership cannot be determined solely by filename, as identical filenames, duplicate uploads, and incorrect attachments can lead to crossed business orders.
2. Is the Content Parsable?
Text files are generally easy to process, but scanned documents, image-based files, and complex tables may require additional recognition and validation. Content that cannot be accurately recognized should be flagged for manual confirmation rather than being forcibly filled into the system.
3. Is the Upload Target Correct?
In legacy systems, upload portals may be located across multiple pages, and different records may have similar names. The agent should prioritize confirming using customer IDs, order numbers, or unique record identifiers to avoid selecting targets based solely on names.
4. Is the Output Traceable?
Processed files should retain version, timestamp, and source information. Upon task completion, the system should ideally log the input file, extraction results, modified fields, upload location, and final status to facilitate auditing and troubleshooting.
5. Production Deployment: The “Plan-Execute-Verify” Model
It is not recommended to let the agent operate continuously from task reception straight through to submission. A safer execution approach divides the task into three phases.
Phase 1: Plan
The agent first reads the task instructions and input materials, generates the steps to be executed, and identifies potential risks. For example:
- Whether login or account switching is required;
- Whether non-modifiable fields are involved;
- Whether materials are missing;
- Whether high-value or highly sensitive operations are involved;
- Whether manual authorization is needed.
The planning phase performs no write operations; it is solely responsible for understanding and preparation.
Phase 2: Execute
Execution should proceed in small increments. After completing each key milestone, the agent should read the page state and determine if it matches expectations. Do not assume a click was successful, and do not continue operating if the page has not finished loading.
For critical actions, a secondary confirmation mechanism can be used:
- Read the current record identifier;
- Check the fields to be modified;
- Execute the modification;
- Read the page content again;
- Confirm the modification result;
- Only then allow submission.
Phase 3: Verify
Verification should not just look at “whether the page redirected.” More reliable acceptance methods include:
- Checking for success prompts or status fields;
- Reopening the record to confirm content;
- Comparing key fields before and after submission;
- Confirming attachment names, sizes, and ownership;
- Saving screenshots, text results, or operation logs;
- Automatically transferring anomalous results to manual processing.
6. Permissions, Rollback, and Human Intervention
The agent’s permissions should follow the principle of least privilege. Initially, avoid granting high-risk capabilities such as deletion, bulk modification, payment, publishing, or permission configuration.
Permissions can be gradually expanded in the following order:
- Read-only queries;
- Draft creation;
- Single low-risk update;
- Uploading non-sensitive attachments;
- Submission after manual confirmation;
- Expanding the scope of processing after thorough validation.
For systems without true rollback capabilities, a compensation plan should be established before submission. For instance, save original fields, record changes, and prepare a manual recovery process. Rollback doesn’t necessarily mean the system has an undo button; business recovery can also be achieved through change logs and reverse operations.
Human intervention should be mandatory under the following circumstances:
- Unknown pop-ups appear on the page;
- Authentication status changes;
- Key fields cannot be uniquely matched;
- Insufficient confidence in recognition results;
- System prompts are inconsistent with expectations;
- The task involves amounts, permissions, or sensitive data;
- Continuous retries fail to recover.
7. Evaluating Process Suitability for AI Agents
Five metrics can be used for initial screening:
- Low risk: Failure does not cause irreversible loss;
- Minimal permissions: Can be restricted to a single account or single function scope;
- Verifiable results: Completion can be confirmed via page, log, or file;
- Relatively stable steps: Pages and business rules do not change frequently;
- Human takeover possible: Exceptions can be quickly paused and resumed.
Tasks with high suitability include data entry, attachment archiving, status queries, report downloads, and low-risk ticket updates. Conversely, processes involving fund transfers, bulk deletions, permission granting, and legal commitments should be approached with caution, prioritizing manual approval.
8. Conclusion: Building a Controllable Closed Loop
The absence of APIs in legacy systems does not mean automation is impossible, but the core of automation is not merely teaching an agent “how to click.” A truly valuable solution must simultaneously possess environment operation capabilities, page positioning capabilities, business rule understanding, file processing capabilities, and result verification capabilities.
From an engineering perspective, the most reliable route is: select low-risk processes first, restrict account permissions, clarify input and acceptance criteria, adopt phased execution, set up manual confirmation at key nodes, and continuously record operational evidence. Only after the process is validated in terms of stability, accuracy, and exception handling is it appropriate to gradually expand the scope.
AI agents are suited to take over describable, verifiable, and recoverable work segments, rather than unconditionally taking over an entire business system. Defining boundaries clearly is often more important than simply pursuing stronger operational capabilities.
