Browser and computer-use agent: acting through a screen like a person

A browser agent looks at a web page, picks one click or keystroke, and repeats until the task is done. Use it when the job lives in a website that has no usable API.

Browser agent in 60 seconds

  • What: an agent that operates a real browser or desktop by seeing the screen and choosing clicks, typing, and scrolling.
  • Loop: observe the page, choose one action, act, observe the new page, and repeat until the goal is met or a budget runs out.
  • Best for: tasks inside websites and legacy tools that have no API, such as filling forms, checking portals, or collecting data from many pages.
  • Weak spots: it is slow, it can misread pages, and it can click the wrong thing, so risky steps need a person to confirm.
  • Evidence: WebArena (Zhou et al., 2023) offers a realistic, self-hostable web environment for testing agents on everyday web tasks.

Where this type fits

In the hub, the browser agent belongs to the family of agents defined by the kind you build, alongside the tool-using, coding, voice, and long-running agents. It is not a new way of deciding. Inside, it usually runs the same observe, think, act cycle as a ReAct agent. What sets it apart is its tool: a whole browser, and the fact that its observations are pages designed for human eyes.

The problem it solves

A great deal of useful work sits behind web interfaces. A supplier portal where you download invoices, a government form, an old admin console, a travel site with no public interface. Ordinary automation scripts can handle these, but they are brittle. They are written against fixed button positions or element names, and they break the day the page layout changes. Someone then has to repair the script.

Without a browser agent you have two poor choices. You can ask a person to do the clicking, which is slow and dull. Or you can write and maintain a script per site, which costs engineering time for every portal and every redesign. Neither scales to a long tail of small, changing sites.

A browser agent reads the page the way a person does. It sees a button labelled 'Download invoice' wherever it sits, and it decides what to do from the goal. That makes it more tolerant of layout changes. The price is that every step needs a model call, so it is slower and costlier than a script, and it can make mistakes that a fixed script would not. The aim is to use it where flexibility matters more than speed.

How it works

  • Goal: the user states the task in plain words, such as 'download last month's invoice from the supplier portal'.
  • See the page: the agent captures a screenshot, a simplified version of the page structure (the DOM, the tree of elements), or both. Structure is cheaper and more exact. Screenshots help when text alone hides the layout.
  • Choose an action: the model picks one step from a small fixed menu, such as click, type, scroll, select, go back, or finish. It names the target and any text to type.
  • Act: the harness (the code around the model) performs the action in the browser. The model never touches the browser directly.
  • Observe again: the new page becomes the next observation and the loop repeats. The loop ends when the model reports the goal is done, when a step or time limit is hit, or when it needs a person.
  • Confirm risky steps: before a payment, a deletion, or an account change, the harness pauses and asks the user to approve.
The browser agent loops through seeing, choosing, and acting, with a confirmation gate for risky steps.

The diagram shows a loop with one gate. The loop is the heart of it: every action changes the page, so the agent must look again before choosing the next step. It cannot plan a whole session blind, because the page it expects may not appear. A pop-up, a login wall, or a slow load all change what comes next.

The warning box is a separate control and it sits outside the model. The harness checks each proposed action against a list of risky kinds. If it matches, the run stops and a person decides. This matters because the model can be wrong, and because a web page can contain text that tries to steer the model. Keeping the gate in code means no page text can switch it off.

A worked example

Acme Corp wants last month's invoice from a supplier portal called Northwind Supplies, which has no API. The goal is: 'Download the March 2026 invoice and tell me the total.'

  • Step 1. The agent observes the portal home page. The structure shows a login form already filled by a saved session, and a menu with 'Orders', 'Invoices', and 'Support'. It chooses click on 'Invoices'.
  • Step 2. The new page lists invoices in a table. Rows show 'INV-0412, 31 Mar 2026, 1,284.50' and 'INV-0398, 28 Feb 2026, 1,102.00'. The model picks the March row and chooses click on its 'View' link.
  • Step 3. A detail page appears with a 'Download PDF' button and a total of 1,284.50. The model chooses click on 'Download PDF'.
  • Step 4. A cookie banner now covers the button, so the click has no effect. The next observation shows the banner. The agent chooses click on 'Accept necessary only', then clicks 'Download PDF' again.
  • Step 5. The file arrives in the download folder. The agent chooses finish and answers: 'Downloaded INV-0412. The total is 1,284.50.'

Five actions, one recovery from a surprise, and no risky step, so no confirmation was needed. Had the goal been 'pay the invoice', the click on 'Pay now' would have matched the risky list and paused for approval.

One action the model might return at step 4 (illustrative) (json)
{
  "thought": "A cookie banner covers the download button. Dismiss it first.",
  "action": "click",
  "target": "button 'Accept necessary only'",
  "text": null
}

Building it

The sketch below shows the harness. The browser, llm, and ask_user objects are placeholders, not real libraries. The structure is what matters: hard limits, a site allow-list, a risky-action gate, and a short history so the prompt stays small.

Browser agent harness with limits and a confirmation gate (illustrative) (python)
import time

MAX_STEPS = 25          # stop runaway loops
MAX_SECONDS = 300       # stop slow or stuck sessions
ALLOWED_HOSTS = {'portal.northwind.example', 'help.northwind.example'}
RISKY = {'pay', 'delete', 'change_email', 'submit_order'}

# Placeholders: browser, llm, and ask_user stand in for your own components.
def run(goal, browser, llm, ask_user):
    history = []                       # short log of past actions
    started = time.time()
    for step in range(MAX_STEPS):
        if time.time() - started > MAX_SECONDS:
            return {'status': 'timeout', 'steps': history}

        page = browser.observe()       # simplified DOM, plus a screenshot if needed
        if page.host not in ALLOWED_HOSTS:
            # Why: a link or redirect must not take the agent to unknown sites.
            browser.back()
            history.append('left allowed sites, went back')
            continue

        # Only the last few actions go in: long histories cost tokens and add noise.
        action = llm.generate(goal=goal, page=page.summary, recent=history[-5:])

        if action['name'] == 'finish':
            return {'status': 'done', 'answer': action['text'], 'steps': history}

        if action['name'] in RISKY or page.looks_like_checkout:
            # Why: the gate is code, so page text cannot talk the model past it.
            if not ask_user('Allow ' + action['name'] + ' on ' + page.host + '?'):
                return {'status': 'declined', 'steps': history}

        try:
            browser.perform(action)    # click, type, scroll, select
            history.append(action['name'] + ' ' + str(action.get('target')))
        except Exception as err:       # element missing, page changed
            history.append('failed: ' + str(err)[:80])

    return {'status': 'step_limit', 'steps': history}

Design decisions

  • Observation format: default to simplified page structure with a screenshot only when needed. Structure is cheaper, faster, and exact about element names. Screenshots cost more tokens but cope with canvas elements and odd layouts.
  • Isolation: run each session in a throw-away browser profile or container. A fresh profile limits what a mistake or a malicious page can reach. Never reuse your own logged-in browser.
  • Credentials: give the agent the narrowest account that can do the job, and inject sessions from a vault rather than putting passwords in the prompt. Prefer read-only accounts for read-only tasks.
  • Allow-list: limit the hosts it may visit. Default to a short list and add sites deliberately. This blocks wandering and reduces the reach of hostile pages.
  • Confirmation gate: put it in code, keyed on action type and page context, and require approval for payments, deletions, sending messages, and account changes. Default to asking when unsure.
  • Failure handling: cap steps and seconds, save a trace of every observation and action, and return a clear status. A human should be able to replay what happened.
  • Latency and cost: each step is a model call, so expect seconds per step. Use a smaller model for easy pages and keep the history short. Run many sessions in parallel rather than making one faster.

Measuring it

  • Task success rate: the share of tasks where the end state is correct, checked by a script that inspects the final page or file. Build a fixed set of tasks on a test copy of each site, in the spirit of WebArena.
  • Steps per task: the mean and the 90th percentile of actions taken on successful runs. A rising number often means the model is wandering or hitting a new pop-up.
  • Wrong-action rate: the share of actions that a reviewer marks as clearly mistaken, sampled from traces. This is the early warning before a failed task.
  • Gate precision and recall: of the risky actions, how many were caught, and how many confirmations were needless. Recall matters most here.
  • Cost and time per task: tokens in and out per step, multiplied by steps, plus wall-clock seconds. Compare with the cost of a person doing the same job.
  • Recovery rate: after a surprise such as a banner or a timeout, how often the agent reaches the goal anyway.

When to use it, and when not to

SituationUse this type?Why
A supplier portal with no API and a monthly downloadYesThe task is repetitive, low risk, and a script would break on each redesign.
A site with a stable public APINoCall the API through a tool. It is faster, cheaper, and more reliable.
Collecting prices from many different shop pagesYesPage layouts differ, so a reading agent beats one script per site.
Paying invoices or changing bank detailsOnly with approvalMistakes are costly, so every such step needs a person to confirm.
Tasks needing speed, such as real-time tradingNoEach step takes seconds, and the loop cannot match script speed.
Testing your own web app's screensSometimesIt finds odd flows, but a fixed test suite is cheaper for regression checks.

Trade-offs

DimensionEffectWhat to do about it
QualityHandles changing layouts but may misread a page or click the wrong item.Keep tasks narrow, check the end state with a script, and review samples of traces.
LatencySeconds per step, so a task may take minutes.Run tasks in the background and in parallel, and tell users to expect a wait.
CostA model call for every action, often with a large page as input.Use simplified structure, short histories, and a smaller model where pages are easy.
ComplexityYou must run browsers, sessions, sandboxes, and trace storage.Start with one site and one task type before widening.
Failure modesLoops, pop-ups, login walls, hostile page text, and wrong clicks.Use step limits, an allow-list, a code-level gate, and a clear stop status.

A tool-using agent calls well-defined functions with checked arguments. When an API exists, that is almost always better: it is quicker, cheaper, and easier to test. The browser agent is the fallback for places where no such function exists, so it can be thought of as a tool-using agent whose single tool is a screen.

A ReAct agent is the decision pattern most browser agents use inside. ReAct describes how to think and act in turns. The browser agent adds the hard parts around it: perception of pages, sandboxing, and the confirmation gate. For safety design, read guardrails and safety.

What this means for your role

Common mistakes

Further reading

A browser agent earns its place when no API exists and the task repeats. Keep it fenced in by limits, an allow-list, and a human gate, and measure it on a fixed task set.

Search topics

↑↓ to move · Enter to open · Esc to close