LLMs Controlling Computers: Mechanisms, Sandbox Deployment, and Costs
This article delves into how Large Language Models (LLMs) are being developed to directly control computers, a capability known as Computer Use. It covers the underlying perception-decision-execution loop, essential parameters and requirements for sandbox deployment, an evaluation of current performance strengths and limitations, and an analysis of the associated high costs alongside mitigation strategies.
1. Why LLMs are Starting to “Use Computers”
Over the past year, the capabilities of Large Language Models (LLMs) have expanded from text generation to code writing, function calling, and multi-step reasoning. Recently, the industry has focused on a new type of capability: allowing models to directly operate computers. This includes reading screenshots, moving the mouse, clicking buttons, typing text, switching between browsers and terminals, and ultimately completing multi-step tasks. This is commonly referred to as Computer Use.
This changes the traditional tool-based approach for AI agents. Instead of writing individual tool interfaces for the model, the new approach trains the model to use graphical interfaces originally designed for humans. This article deconstructs its working mechanisms from a technical perspective, explains the parameters required for sandbox deployment, and discusses its performance, costs, and applicable boundaries.
2. How it Works: The Perception, Decision, and Execution Loop
2.1 A Loop of Four Steps
The essence of Computer Use remains tool calling, but the target is different. Instead of well-defined APIs, the model faces an entire graphical desktop. Its workflow can be abstracted into the following loop:
- Perception: The system takes a screenshot of the virtual desktop and sends it along with the user’s instructions to a multimodal model.
- Decision: The model understands the current screen state and infers the next action, such as clicking a button at a specific coordinate or typing text into an input field.
- Execution: The runtime environment converts the model’s structured output into real mouse and keyboard events, applying them to the operating system.
- Feedback: After the action is executed, another screenshot is taken, returning to step one until the task is completed or the step limit is reached.
2.2 The Action Protocol
The actions output by the model are typically structured in JSON, which the runtime parses and executes. Here are two illustrative examples:
{"action": "left_click","coordinate": [320, 480]}
{"action": "type","text": "ls -la\n"}
Common action primitives include mouse movement, single/double click, scrolling, keyboard input, key combinations, screenshotting, and waiting. Before execution, the runtime should perform several checks: verify that the action is on a whitelist, ensure coordinates fall within the screen boundaries, and handle newlines and special characters in text explicitly. If an invalid action is encountered, it is recommended to send the error message back to the model and limit the number of retries. If the limit is exceeded, terminate the task and notify a human.
The model does not need to understand specific software APIs; it only needs to understand pixels and coordinates. Theoretically, it can generalize to any graphical interface software.
2.3 Benefits and Costs of the General Approach
Traditional agent solutions usually require writing adapters for each target system: one set of interfaces for browsers, another for office software, and yet another for terminals. This results in high adaptation costs and often leaves long-tail software unsupported. Computer Use delegates the “use of standard human-computer interfaces” to the model as a general capability, offering strong universality.
However, the trade-offs are clear. Screen understanding can be inaccurate, low action granularity leads to lengthy steps, and each step requires multimodal reasoning, driving up both cost and latency.
3. How to Build a Sandbox: Defining Isolation Boundaries
Letting a model directly operate a host machine carries high risks. A common practice is to package the graphical desktop into an isolated environment, restricting all model actions within it. Before setting it up, several categories of parameters need to be defined.
| Parameter Category | What to Define |
|---|---|
| Base Image | Linux desktop system with a GUI, recording the distribution and version |
| Dependencies | Versions of browsers, terminals, remote desktop services, and runtime |
| Port Mapping | Remote desktop and web interface ports, open only to necessary sources |
| Environment Variables | Access keys for model services, injected via env vars, not hardcoded into images or code |
| Resource Limits | CPU, memory, and disk quotas to prevent a single task from exhausting resources |
| Task Limits | Max steps, per-step timeout, and overall timeout |
| Permissions | Run as a non-root user inside the container; prohibit mounting sensitive host directories |
The specific image addresses and startup commands depend on the chosen open-source solution, so refer to the official documentation of that solution. This article does not provide unverified commands to avoid errors caused by direct copying.
Basic sandbox requirements are as follows:
- Do not place real account credentials inside the container. Use dedicated test accounts.
- Apply a whitelist to outbound network traffic, allowing access only to domains necessary for the task.
- Screenshots and operation recordings may contain sensitive information like accounts, emails, and chat logs. Desensitize them before archiving, set retention periods, and delete them upon expiration.
- Operations like deleting files, submitting forms, and sending messages should enter a manual confirmation process.
4. Performance: Strengths and Typical Weaknesses
In testing, this capability shows clear dual characteristics.
Tasks with clear workflows and standard interfaces are handled well. For example, opening a browser to search keywords and organizing results, executing a set of commands in a terminal and troubleshooting based on output, or filling out structured web forms. The model can autonomously plan steps, recover from errors, and try alternative paths when blocked.
The following types of tasks remain challenging:
- Fine-grained positioning: Accuracy drops significantly for dense small icons, pixel-level dragging, and coordinate clicking for complex drawings.
- Long-range drift: After dozens of steps, the model may forget the initial goal or fall into ineffective loops.
- Dynamic content: CAPTCHAs, pop-ups, and asynchronously loaded pages frequently interrupt the execution flow.
- Latency: Each step is a complete round-trip of screenshot, reasoning, and execution. A task that takes a human two minutes might take the model over ten minutes.
Overall, while the demo effect is impressive, there is still a noticeable gap before it is viable for unattended production environments. At the current stage, it is better suited as a semi-automated assistant with human supervision.
When evaluating, you can use the following checklist to record each trial:
- Pass criteria: Whether the final task state meets preset verifiable conditions, rather than the model simply claiming it is done.
- Step count: Actual steps versus the max step limit; exceeding the limit counts as a failure.
- Timeout circuit breaking: Whether single-step and overall timeouts are triggered and if it stops correctly upon triggering.
- Manual takeover: Whether it pauses and waits for human input as expected when encountering actions requiring confirmation.
- Error types: Tallying failure reasons such as positioning failures, long-range drift, and dynamic content blocking.
5. Why Costs are High and How to Reduce Them
Computer Use is much more expensive than plain text conversations, mainly for three reasons:
- Screenshots consume a large number of tokens. Each reasoning step includes a screenshot, and image inputs are typically billed higher than text of equivalent length.
- Context continuously accumulates. In multi-step tasks, historical screenshots and conversations are constantly concatenated, making the context increasingly long. Costs for long tasks will rise non-linearly.
- Uncontrollable step count. The more the model trials and errors, the more calls it makes, leading to greater cost fluctuations per task.
The cost of a single task depends on the model’s unit price, screenshot resolution, number of steps, and task type, making it difficult to provide a universal figure. A reliable approach is to test with your own task samples: record the number of API calls per task and the corresponding costs to establish a baseline for your specific use cases.
