Skip to content
mentoor

Topic 1 of 5 · 4 min read

How screen-reading agents take actions

Goal: Explain the screenshot-and-act loop of a computer-use agent and choose between a vision-based agent and a DOM-based browser tool for a task.

A computer-use agent works in a loop: it looks at a screenshot, picks one action, your code performs it, and the new screenshot goes back to the model. The model never touches the machine itself. It only asks for actions, and your program carries them out.

Check yourself · 1 of 3

In a computer-use loop, what actually performs the click on the screen?

Choose one answer

Why it matters

Many tasks have no API: an old admin panel, a supplier portal, a desktop app. A screen-reading agent can use them the way a person does. You also need to know what it actually sees, because that decides where it breaks.

How the loop works

  1. You send the task and a screenshot of the screen.
  2. The model replies with one action, such as a click at a pixel position, typing text, pressing a key or scrolling.
  3. Your harness runs that action on a virtual machine or a browser.
  4. You take a new screenshot and send it back as the result.
  5. The loop ends when the model says it is done, or when you hit a step limit you set.

Claude, OpenAI and Gemini each ship a computer-use tool built on this loop. The action names differ, the shape does not.

Pixels or page structure

A vision agent sees only pixels. It must guess that the grey rectangle at x=412, y=300 is the Save button. It works on any app, including ones with no accessible markup, but it is sensitive to screen size, zoom and layout changes.

A DOM-based browser tool, such as the Playwright MCP server, gives the model the page's accessibility tree: a text list of buttons, fields and links with names. The model picks "the button called Save", not a coordinate. This is faster, cheaper per step, and steadier, but it only works inside a browser page.

Rule of thumb: use the DOM tool when the target is a web page, and a vision agent when the target is a desktop app, a remote desktop, a canvas or anything without readable structure.

Before and after

A weak setup for filling a web form:

# Vision agent on a 4K screen, coordinates guessed from a scaled screenshot
action = {"type": "left_click", "coordinate": [1230, 905]}

The screenshot was downscaled before it was sent, so the click lands beside the button. A better setup fixes the screen size and passes the same size to the tool:

tool = {
    "type": "computer_20250124",
    "name": "computer",
    "display_width_px": 1280,
    "display_height_px": 800,
}

For a web-only task, skipping pixels altogether is better still: let the agent click the element named "Save" through a browser tool.

What goes wrong

  • Scaling mismatch. The screen the model sees and the screen your code clicks on differ in size, so every click is off.
  • One action per turn, slowly. Each step costs a screenshot and a model call, so long tasks are slow and add up in cost.
  • Wrong tool for the target. Using a vision agent on a plain web form adds guessing for no benefit.

Examples

One turn of the loop

{"role": "assistant", "content": [{"type": "tool_use", "name": "computer", "input": {"action": "type", "text": "invoice 4471"}}]}

The model asked to type into whatever field has focus. Your harness types it, takes a screenshot and returns it as the tool result. If focus was on the wrong field, the model only finds out from the next screenshot.

Choosing the tool

Task Better choice
Fill a supplier web form DOM-based browser tool
Export a report from a desktop accounting app Vision agent
Test a canvas drawing app Vision agent

The split is whether the target exposes readable structure.

Key points

  • A computer-use agent only requests actions; your own code performs them and returns a fresh screenshot.
  • The loop is screenshot, decide one action, act, screenshot again, until the task ends or a step limit is reached.
  • A vision agent sees pixels and works on any app but breaks when size, zoom or layout changes.
  • A DOM-based browser tool reads the page's accessibility tree, so it is steadier on web pages but cannot drive desktop apps.
  • The display size you tell the tool must match the screenshots you send, or every click lands off target.

Common mistakes

  • Sending screenshots at one resolution while telling the tool a different display size.
  • Using a vision agent for a plain web page that a browser tool could drive by element name.
  • Setting no step limit, so a confused agent keeps clicking until the budget is gone.

Check yourself · 2 of 3

Your agent must fill a form on a normal web page. Which tool usually gives the steadiest result?

Choose one answer

Check yourself · 3 of 3

Clicks keep landing a little to the side of the right button. What is the most likely cause?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic