GUI Agent in Practice: From Code Generation to Software Operation

    This article examines GUI Agents as an evolution beyond AI coding tools that only generate code. It breaks down the three-layer architecture of perception, decision, and execution, explains why training and evaluation must rely on real devices instead of emulators, and interprets performance differences across mobile, desktop, and browser environments. It also details safety mechanisms built around mandatory pauses for sensitive actions, a reference architecture for office automation, and a phased adoption roadmap with common pitfalls to avoid.

    1. Introduction: The Boundary of AI Coding Is Being Redefined

    Over the past two years, the core capability of intelligent coding tools has centered on “writing code”: completing functions, generating scripts, explaining errors, and refactoring modules. But when developers shift their perspective from the IDE back to real business workflows, a long-standing gap becomes clear—many enterprise automation needs do not happen in code at all, but in graphical interfaces: reporting systems with no open APIs, legacy ERPs that require manual clicking, and cross-system data transfers that depend on copy and paste. GUI Agents are the technical direction that has grown out of this gap: instead of only outputting code, the model directly “sees the screen, moves the mouse, clicks buttons, and fills out forms” to perform software operations on a person’s behalf.

    The significance of this shift is that the evaluation system for AI programming expands from “code correctness” to “task completion rate.” Correct code does not mean the business workflow runs end to end; only when the sequence of interface operations actually reaches the final state is the work considered delivered. From a general technical perspective, this article systematically breaks down the capability composition of GUI Agents, the differences in evaluation methods, the design of safety mechanisms, and the path to engineering implementation.

    2. The Capability Leap: Three Layers of Abstraction from Code Generation to Interface Operation

    The technology stack of a GUI Agent can be abstracted into three layers. Understanding these layers is a prerequisite for judging whether a solution is deployable.

    The first layer is perception. The model needs to convert screen pixels into structured semantics: control types, text labels, clickable regions, and hierarchical relationships. The common industry approach is dual-channel fusion of the accessibility tree and visual screenshots—the former provides precise structure, while the latter covers self-drawn interfaces and canvas-based controls.

    The second layer is decision-making. Given a natural language goal and the current interface state, the model outputs the next action. The action space is usually normalized into a set of primitives, illustrated below:

    1. # Simplified action primitive definitions (illustrative, not a specific product API)
    2. Action = {
    3. "click": {"x": int, "y": int},
    4. "type": {"text": str},
    5. "scroll": {"direction": str, "amount": int},
    6. "hotkey": {"keys": list},
    7. "wait": {"seconds": float},
    8. "finish": {"result": dict}
    9. }

    The third layer is execution and feedback. Actions are carried out in the real environment, and the environment returns new screenshots and state, forming a closed loop. What is most easily underestimated here is “waiting” and “retrying”: asynchronous interface loading, blocking pop-ups, and network jitter can all cause seemingly correct decisions to fail. As a result, state detection and timeout strategies often affect the success rate more than the model itself.

    3. Why Evaluation Must Depend on Real Devices: The Gap Between Emulators and Real Environments

    The most noteworthy judgment in the source material is that training and evaluation should use a large number of real devices rather than emulators. The technical reasons behind this conclusion are worth expanding on.

    First, rendering differences. Emulators typically do not reproduce real GPU drivers, font rendering, or animation frame rates, so control coordinates and hit areas exhibit systematic offsets. A 95% success rate on an emulator can drop significantly on a real device.

    Second, environmental noise. Real devices have notification banners, permission pop-ups, battery alerts, and input method candidate boxes. These are precisely the parts an Agent must learn to handle; emulator environments are too clean, so the model learns only the “ideal path.”

    Third, fragmentation. Differences in screen size, resolution, OS version, and vendor-customized interaction habits mean the model must have layout generalization ability. Only by covering sufficiently diverse real-device samples can long-tail problems be exposed.

    Therefore, evaluation design should adopt layered metrics rather than a single success rate:

    • Task completion rate: whether the target final state is reached;
    • Step efficiency: whether the completion path is redundant;
    • Recovery ability: whether the Agent can self-correct after encountering a pop-up or failure;
    • Safety compliance rate: whether sensitive actions are correctly intercepted.

    4. A Technical Interpretation of Cross-Platform Benchmark Differences

    The source material mentions performance differences between mobile and desktop/browser environments. Setting aside specific device models, this phenomenon has a general explanation.

    Mobile interfaces have low information density, clear control semantics, and few actions per screen, resulting in a short decision chain that the model converges on easily. Desktop and browser environments are the opposite: complex window hierarchies, deeply nested menus, numerous shortcut key combinations, and multiple equivalent paths for the same function cause the search space to expand combinatorially. In addition, desktop applications make heavy use of self-drawn controls with missing accessibility trees, forcing solutions to rely more on visual understanding.

    The takeaway for engineering teams is: do not use one unified model strategy across all platforms. Mobile can adopt a lightweight strategy for a quick launch, while desktop and browser environments require stronger state memory, path planning, and failure backtracking mechanisms.

    5. Safety Mechanisms: Engineering the Mandatory Pause for Sensitive Actions

    The biggest risk of a GUI Agent is not doing the wrong thing, but “doing the right thing that should not have been done”—accidentally deleting files, sending messages, submitting orders, or changing permissions. The source material emphasizes that the “mandatory pause for sensitive actions” is the first fully engineered solution, and this should be abstracted into a general design specification.

    The implementation points fall into four categories:

    1. Action classification. Divide actions into read-only, reversible writes, and irreversible writes; only the first two categories are allowed to execute automatically.
    2. Mandatory human confirmation points. Irreversible actions trigger a pause that outputs the intended operation, scope of impact, and rollback plan, then waits for explicit confirmation.
    3. Least privilege and sandboxing. The Agent runs under a restricted account in an isolated environment, with sensitive directories and external communication unreachable by default.
    4. Full audit logging. Every step retains a screenshot, the decision rationale, and a timestamp for later traceability and accountability.

    A reference policy skeleton:

    1. def guard(action, risk_level):
    2. if risk_level == "irreversible":
    3. return pause_for_human(action) # Force a pause and wait for confirmation
    4. if risk_level == "reversible":
    5. return execute_with_log(action)
    6. return execute(action) # Let read-only actions through directly

    6. A Reference Architecture for Office Automation

    If a team wants to build a cross-platform Agent foundation, it can adopt the following layered architecture, described entirely with general capability categories:

    • Access layer: a unified wrapper around the environment drivers for mobile, desktop, and browser, hiding the differences;
    • Perception layer: screenshot capture + structure parsing + control alignment;
    • Decision layer: goal decomposition, state memory, and action planning;
    • Execution layer: action primitive scheduling, timeouts, and retries;
    • Safety layer: risk classification, human confirmation, and sandbox isolation;
    • Data layer: trajectory samples stored in object storage, logs sent to a logging service, and metrics sent to monitoring and alerting.

    From an engineering standpoint, it is advisable to treat “trajectory data” as a core asset: every successful and failed execution sequence can flow back as training and regression test samples, forming a data flywheel. Regression testing is especially critical, because interface redesigns invalidate historical test cases and require continuous rebuilding.

    7. Adoption Roadmap and Common Pitfalls

    A four-phase approach is recommended. In the first phase, choose high-frequency, low-risk, rule-driven read-only scenarios to validate the perception and decision pipeline. In the second phase, introduce reversible writes and complete the audit trail. In the third phase, integrate the confirmation mechanism for irreversible actions. In the fourth phase, pursue cross-platform generalization and efficiency optimization.

    There are three common pitfalls. The first is over-pursuing full automation while ignoring the trust benefits that human confirmation brings. The second is a disconnect between the evaluation set and the real business distribution, causing the online success rate to plummet. The third is neglecting interface version management—once an application upgrades, the Agent fails across the board. The countermeasure is to incorporate version changes into the regression pipeline and keep a channel for falling back to manual operation.

    8. Conclusion

    The value of GUI Agents lies not in replacing developers in writing code, but in automating the last “manual” step of the digital world. Real-device-driven training and evaluation, cross-platform differentiated strategies, and a safety design centered on mandatory pauses form a reusable engineering path. For teams building office automation and cross-platform agent foundations, the robust order of progression is to first establish the safety boundary and evaluation system, and only then expand capabilities.