Computer Use / Mobile Use Agents
Letting AI operate web pages, desktop apps or phone screens directly (computer use / mobile use), often for RPA-style automation needs.
Core concepts: two technical approaches
| Screenshot + coordinates (visual approach) | DOM / accessibility tree + selectors (structural approach) | |
|---|---|---|
| Input to the model | Screenshots | Page structure (accessibility tree snapshot, trimmed DOM) |
| Actions | Click at (x, y), type, scroll | Click an element reference, fill a given input |
| Strengths | General: works on desktop software, Canvas, remote desktops | Precise, cheap (fewer text tokens), more stable |
| Weaknesses | Many tokens, slow, coordinate drift | Only works on structured UIs (web pages, apps with accessibility info) |
| Typical tools | Anthropic computer use tool | Playwright, Appium, ADB |
In practice they're often mixed: prefer the structural approach, and fall back to screenshots for Canvas or elements that can't be located.
How it works
Anthropic computer use tool (verified 2026-11)
- It is a client-executed tool: the model returns actions such as "screenshot / click at coordinates / type text / press key", your code executes them in a VM or container, and sends back a new screenshot.
- Version history:
computer_20250124→computer_20251124(requires the beta headercomputer-use-2025-11-24) → the newcomputer_toolset_20260801(goes in thetoolsarray, no beta header needed). The official docs say newer models only support the new toolset version, while the older tool versions still work on the models listed for them. - The docs stress safety measures: run in an isolated VM/container, limit network access, require human confirmation for sensitive actions, and watch out for prompt injection in page content.
Structural approach: Playwright's accessibility snapshots
locator.ariaSnapshot()returns the accessibility structure (role, name, state) of an element subtree as YAML, which is a very good input for an LLM.- Benefit: far shorter than raw HTML, and it keeps only what a user can perceive.
Mobile use
- Android: ADB (screenshots, input events) + UIAutomator's view hierarchy; cross-platform: Appium (WebDriver protocol). Again the approaches split into "screenshots" and "view tree".
In practice: one step of the structural approach
python
from playwright.async_api import async_playwright
async def observe(page) -> str:
# The "observation" shown to the model: current URL + accessibility snapshot of the main region (truncated to keep it short)
snap = await page.locator("main").aria_snapshot()
return f"URL: {page.url}\n{snap[:6000]}"
async def act(page, action: dict):
if action["type"] == "click":
await page.get_by_role(action["role"], name=action["name"]).click(timeout=5000)
elif action["type"] == "fill":
await page.get_by_label(action["label"]).fill(action["text"])Agent loop: observe → LLM decides an action → act → observe …, plus a max step count, screenshots archived on failure, and handoff to a human before high-risk actions (submit, pay, delete).
Common pitfalls
- Prompt injection: web content can "command" the agent. Treat page content as data, not instructions, and force human confirmation for high-risk actions.
- No isolated environment: running directly in your own browser risks unintended actions. Use a container or a separate browser profile.
- Observing before the page has loaded: use Playwright's auto-waiting and
expectassertions instead of fixed sleeps. - Only recording the final result: save every step's observation, action and screenshot so you can replay and debug (this is also the pipeline's "traceability" requirement).
Common interview questions
- What are the pros and cons of the screenshot approach versus the DOM / accessibility tree approach? Which did your project choose, and why?
- Who executes the computer use tool? What does the model return?
- How do you defend against prompt injection in web pages?
- How does the agent hand over to a human when an action fails? How does it continue after the human is done?
- How do you measure a browser agent's success rate?
How it relates to my projects
- Browser Automation Agent: this page is the technical foundation of that project.
To be verified / may go stale
- The computer use tool's version strings, supported models and beta headers change quickly (as of 2026-11 the docs list both
computer_20251124andcomputer_toolset_20260801). Check the official page before building. - OpenAI also offers computer use capabilities, not covered here; consult OpenAI's official docs when using them.
Sources
- Anthropic Docs: Computer use tool — tool versions, beta header, model support, safety advice
- Playwright Docs: Aria snapshots · Python version —
ariaSnapshot()/aria_snapshot() - Playwright Docs: Locators —
get_by_role,get_by_label - Appium Docs · Android Debug Bridge
