AI Computer Use: How GUI Agents Work, How to Evaluate Them, and How to Put Them into Practice
Computer use, also known as GUI agents, lets an AI model operate a computer like a person: it looks at the screen, moves the mouse, clicks, and types instead of relying on hardcoded, purpose-built APIs. This article explains how this capability works as a continuous observe-decide-act loop over a structured action space. It covers how to set up an isolated sandbox, three dimensions for evaluating effectiveness (task completion rate, number of steps, and robustness), and a cost characteristic that is easy to overlook: billing is per step rather than per task, and each step sends a new screenshot. It also outlines key security risks, such as prompt injection, and practical engineering recommendations. Readers will learn when computer use works well, how to measure it, and how to approach safe deployment in production.
Introduction: From Talking to Doing
Over the past two years, the core value of large language models has been understanding and generation. They can read documents, write code, and summarize content. But actually completing an entire task for someone, such as booking a flight in a browser or exporting a report from an enterprise system, takes far more than conversation. This has made a new capability direction clear: rather than relying on hardcoded, purpose-built APIs, a model should be able to operate a computer the way a human does, by looking at the screen, moving the mouse, and typing on the keyboard.
The industry commonly calls this capability “computer use” or a “GUI agent”. It is fundamentally different from traditional automation scripts and RPA (robotic process automation). RPA requires someone to record and hardcode every step’s coordinates and flow, and it breaks as soon as the interface changes. Computer use relies on the model’s real-time perception and reasoning, so it can adapt to some degree when interfaces change. Understanding this distinction is a prerequisite for assessing the capability’s value and limitations.
1. How It Works: The Observe–Decide–Act Loop
Computer use is essentially an extension of the tool-calling approach. Traditional tool calling targets abstract APIs or functions, such as “check the weather” or “send an email”. Computer use instead abstracts the entire operating system desktop into a toolset: what the model perceives is the overall screen environment, and what it invokes are atomic operation-level capabilities.
At runtime, it follows a repeating three-stage loop:
- Observation: the system captures a screenshot of the current screen and passes it to the model along with the user’s task goal. Screen pixels are the model’s only window onto the world.
- Reasoning and planning: based on the current screenshot, the task goal, and the history of prior actions, the model reasons about what to do next and outputs a structured action.
- Action: the runtime parses the action and performs the corresponding mouse or keyboard operation on the real desktop. It then returns to step 1 and takes a new screenshot.
The action space typically covers several categories of atomic operations:
screenshot: capture the current screenmouse_move/left_click/double_click/right_click: move the mouse and perform clickstype: enter text at the cursor positionkey: press key combinations such as Enter, select all, or copyscroll: scroll the page
The loop can be described in pseudocode roughly as follows:
goal = "Search for today's news in the browser's search box and open the first result"history = []while not task_finished(goal, history):# 1. Observation: take a screenshot of the current desktopobservation = capture_screen()# 2. Reasoning & Planning: the model uses the goal, the screenshot,# and the history to decide the next actionaction = model.predict(observation=observation,goal=goal,history=history,available_actions=ACTION_SPACE, # explicitly constrain the available actions)# 3. Action: carry out the action on the real desktopexecute(action) # e.g., left_click(x=512, y=340)history.append(action)# Termination: the model judges the goal is achieved,# or the maximum number of steps is reached
There are two important engineering points here. First, actions must be structured and validated. The runtime should check the coordinates and parameters produced by the model for validity to avoid out-of-bounds movements or erroneous operations. Second, you must set a maximum step count (Max Steps) and a termination condition. Otherwise, the model may repeatedly test the waters even on simple tasks, which wastes cost and makes it hard to converge.
2. Environment Setup and Sandbox Isolation
Letting a model operate a developer’s real machine is extremely dangerous. It could delete files by mistake, leak private data, or even be tricked by a malicious web page into destructive operations. For this reason, the common industry practice is to run the model inside an isolated container or virtual machine sandbox.
A typical experimental deployment usually includes the following elements:
- An isolated operating system environment: for safety, early approaches were mostly built on a Linux desktop. A container image packages the graphical interface and commonly used software so the host machine is never directly exposed.
- Multiple ways to observe the run: several access channels are typically provided. These include a combined web interface with chat and a desktop view, a standalone desktop view page, and a channel that connects via a remote desktop protocol such as VNC or RDP. This lets developers see both “what the model is thinking” and “what is happening on the desktop”.
- Credential injection and port mapping: injecting the model service’s access key as an environment variable into the container and mapping the interface port lets you interact and debug from a browser.
Because the technology is still experimental, security isolation is not optional. It is a prerequisite that must come before validating functionality. Any attempt to put it into practice should by default run in a disposable sandbox that can be torn down quickly.
3. Evaluating Effectiveness
To evaluate how well computer use performs in practice, it helps to look at three angles rather than just “can it get the job done”:
- Task completion rate: the proportion of a predefined set of representative tasks (such as information retrieval, form filling, and file organization) that the model can complete end to end. Real-world interfaces vary enormously, so completion rates often drop significantly as task complexity increases.
- Number of interaction steps and efficiency: how many steps it takes to complete the same task. What a human can do in a few steps may take the model many attempts because it struggles to locate the right elements. More steps mean higher latency and higher cost.
- Robustness and fault tolerance: whether the model can correct itself when unexpected things happen, such as a pop-up blocking the view, slow loading, or a redesigned page. This is what separates “works in a demo” from “ready for production”, and it is currently a weak spot in most solutions.
It is important to be objective: this capability performs impressively on tasks with clear boundaries and a stable interface. However, it still tends to miss steps or get stuck in loops in scenarios that require long chains of reasoning, coordination across multiple applications, or high sensitivity to timing.
4. Evaluating Cost
Computer use has a cost characteristic that is easy to overlook: it is billed per step, not per task. Every atomic action corresponds to a complete model call, and each call has to carry the latest screenshot.
This leads to two cost-amplifying effects:
- High visual input token cost: a screen image is encoded into a large number of visual tokens, and these are sent again at every step. Over long tasks, the cumulative consumption can be substantial.
- Step count and cost grow roughly linearly: the more complex the task and the more the interface navigates between screens, the more model calls are needed and the higher the overall cost.
A cost evaluation should therefore go beyond comparing per-call prices. It should measure total token consumption and total number of calls to complete a representative set of tasks and combine this with latency data before drawing conclusions about cost-effectiveness for the business. On the engineering side, costs can be optimized by setting sensible maximum step limits, trimming the history context, and introducing caching where appropriate.
5. Security Risks and Engineering Recommendations
Giving a model the ability to operate a computer means handing over part of your control over the system, so security deserves the same priority as functionality:
- Guard against prompt injection: the web pages and documents a model reads may contain hidden malicious instructions. At runtime, clearly distinguish between trusted instructions from the user and untrusted content returned by the environment. The latter should be treated only as observation data, never as a basis for taking action.
- Least privilege: install only the software needed to complete the task in the sandbox, and open only the network and file permissions that are necessary. This reduces the potential damage of mistakes.
- Human in the loop: require a confirmation step for high-risk actions such as deletion, payment, or sending, so that a human can review and approve them at critical points.
- Full observability and rollback: log every action and screenshot so that runs can be audited and problems reproduced after the fact, and the environment can be rebuilt quickly.
Conclusion
Computer use marks an important step in the evolution of agents from passively answering to actively taking action. Its value lies in replacing a huge number of custom, purpose-built APIs with a single general-purpose action framework. However, the technology is still in its early stages. Its effectiveness depends heavily on the stability of the task and interface, its cost scales with the number of steps, and its security risks need to be addressed through isolation and permission control as a starting point.
For developers, a pragmatic approach is to start by validating clearly scoped scenarios in an isolated sandbox, measure them with three metrics (completion rate, number of steps, and total token cost), and gradually expand the scope of use. To build such agents for production, you can combine general cloud capabilities such as container platforms, object storage, logging services, and monitoring and alerting. Together, these support isolated execution, traceability, and cost observability across the full engineering workflow. Providing this kind of general-purpose infrastructure for putting agents into practice is part of the value offered by platforms like Baidu AI Cloud.
