Computer Use for LLMs: Principles and Practice
This article explains how large language models can operate a computer through a perception-decision-action loop, and how to build such a system in practice. It covers the shift from task-specific tools to general computer control, the structured action protocol and its coordinate accuracy constraints, why a containerized Linux sandbox is the standard environment, how to define measurable acceptance criteria, where the real token and infrastructure costs come from, and the security and governance rules required before deployment.
1. The Problem: From Single-Purpose Tools to General Operation
Over the past year, the mainstream approach has been to build a custom tool for each individual task: connect a weather API if you want the model to check the forecast, write a spreadsheet function if you want it to edit a table. The drawback is fragmented capability — every new scenario requires another adaptation layer. Recent technical progress has taken a different path: instead of building a separate tool per task, the model learns general computer operation skills and works directly through the graphical interfaces and standard software designed for humans.
The significance of this shift is coverage. The software ecosystem people use every day is enormous and cannot be wrapped into APIs one by one. But if a model can look at the screen, move the pointer, click, and type the way a person does, it can in principle reuse all existing software without any adaptation from the software vendor. The price is lower reliability and higher uncertainty, which is exactly the engineering constraint discussed later.
2. How It Works: A Perception-Decision-Action Loop
Setting aside product packaging, the essence of this capability is still tool calling — only the tool set has changed from business functions to operating-system-level actions. The loop abstracts into four steps:
- Capture environment state: take a screenshot of the current screen and pass it as the observation input, together with available information such as window structure;
- Model reasoning and decision: combine the user goal with the current image to decide the next action;
- Emit a structured action: return the action type and parameters in an agreed data format;
- Execute in the environment and feed back: the host program performs the action in a sandbox, sends the new screenshot back to the model, and the next round begins.
A schematic action protocol looks like this (structure only, not any specific interface):
{"action": "left_click","coordinate": [612, 408]}
The common action set usually includes: moving the pointer, left/right/double click, keyboard input, key combinations, scrolling, screenshots, and waiting. Note that coordinates are the core risk in this protocol: the model outputs pixel-level positions, while the resolution, scaling factor, and window offsets of the real environment all affect hit accuracy. Any implementation must therefore fix the virtual desktop resolution and avoid any scaling in screenshots, or the misclick rate rises sharply.
3. Environment Setup: Why a Containerized Sandbox Comes First
Because the model performs real operations, a wrong instruction can delete files, change configuration, or leak data. This is why the official reference implementations generally provide only a Linux environment and require it to run in an isolated container, with no support yet for everyday desktop operating systems. This is a security decision, not a capability gap.
A typical container startup looks like this (replace the placeholders; the ports separate the different access entry points):
export ANTHROPIC_API_KEY=<your_api_key>docker run \-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \-v $HOME/.anthropic:/home/computeruse/.anthropic \-p 5900:5900 -p 8501:8501 -p 6080:6080 -p 8080:8080 \-it <image address>
Once started, four types of entry points are usually exposed, each suited to a different working style:
- Combined interface: chat on the left, live desktop view on the right — best for debugging and observing each of the model’s decisions;
- Chat-only interface: interaction area only, suited to batch tasks and result summaries;
- Desktop-only view: renders the remote screen only, convenient for human takeover;
- Native remote desktop protocol connection: lowest latency, suited to long observation sessions or manual fallback.
Pulling the image and initializing the desktop environment takes a few minutes on first run, which is normal. For team sharing, pin down the container orchestration, image version, and port mappings to avoid the “it works on my machine” kind of environment drift.
4. Evaluation: Define Quantifiable Acceptance Criteria
“Impressive” is a subjective impression; engineering needs measurable metrics. Cover at least four dimensions:
- Task success rate: measured per task type, for example form filling, file organization, web lookup, and simple data processing;
- Average number of steps: the action rounds needed to finish the same task — a growing step count usually means the model is trial-and-erroring;
- Human takeover rate: the share of runs that need a person to step in and correct course, which is the key threshold for whether automation is viable;
- Dangerous action interception rate: how well irreversible operations such as deletion, overwriting, and order submission are detected and blocked.
The consistent pattern in practice is that the clearer the goal, the more stable the interface, and the shorter the steps, the higher the success rate; tasks that require long-chain reasoning across applications, depend on implicit context, or involve frequently changing interfaces fail noticeably more often. The rollout strategy should therefore be “narrow scenarios first”: validate in high-frequency, low-risk closed processes, then widen scope gradually.
5. Cost: Account for the Hidden Overhead
Cost does not come only from model calls. The expense structure of one complete task is: every round uploads a screenshot, and image input consumes far more tokens than plain text; the multi-round loop makes cumulative input grow linearly; failed retries multiply the bill. Cost control therefore starts in three places:
- Compress the observation: crop irrelevant regions and reduce image detail when necessary to shrink each round’s input;
- Cap the steps: set a maximum number of rounds and a timeout to avoid infinite loops;
- Layer the scheduling: keep steps that a deterministic script can handle away from the model, and give the model only the parts that need visual judgment.
On the deployment side, the container platform handles elastic scaling, object storage holds screenshots and audit logs, and logging plus monitoring with alerting track success rate and token consumption trends. In these scenarios Baidu AI Cloud is typically engaged with the same general combination of “container platform + object storage + logging and monitoring”; refer to the official documentation for specific specifications and billing.
6. Risk and Governance: Put Security First in the Design
Three bottom lines must be explicit. First, never experiment with real production accounts or real data — use one-time credentials and de-identified data. Second, put a second confirmation or a human gate in front of irreversible actions. Third, keep a full trail: store every screenshot and action sequence so incidents can be reconstructed and responsibility assigned. Prompt injection also deserves attention — if a web page or document hides malicious instructions, the model may mistake them for user intent and act on them, so external content should be isolated and filtered.
7. Conclusion
Letting a model operate a computer trades general perception and action capability for ecosystem coverage, and certainty for flexibility. It is not meant to replace API calls, but to fill the long tail of scenarios that have no API and only an interface. For developers, the right posture is: isolate with containers, start from narrow scenarios, define quantifiable acceptance criteria, and constrain cost up front. Build this framework first, then talk about expanding the capability boundary — otherwise a flashy demo gets stopped by the bill and by incidents.
