What this guide can confirm, and what to check yourself
The premise of this article is that Google's Computer Use tool has reached general availability. I could not read the Gemini API changelog or the computer-use documentation page when writing, so I have not confirmed the GA date, which models support the tool, how many tokens a screenshot costs, whether the API caps steps for you, or what safety fields come back with an action. Those are left out on purpose. Verify them on Google's own pages, then plug the real numbers into the arithmetic below.
What I did read is Google Cloud's Agent Platform pricing page. For the Computer Use Tool it says pricing is based on the total number of input tokens sent to the model and the output tokens generated, at the token prices of the model used, and that function declarations are included in the input token count.1 That is enough to build a cost model, because it means a computer-use run is a sequence of ordinary model requests. The rest of this guide is engineering practice you apply around them: cost shape, loop bounds, approval gates, and sandbox and egress rules.
How a computer-use step is billed
A browser-driving agent works in a loop. The harness takes a screenshot, sends it with the goal, the tool declarations and the history to the model, receives an action such as click, type or scroll, executes it in the browser, and repeats. Each turn is one request, and each request carries everything the model needs to see.
Three things make this expensive in a way that ordinary tool calling is not:
- Screenshots are input tokens. Every turn adds at least one image. How many tokens an image costs depends on the model and its settings; Google's page lists different per-image figures for different image models, and 258 tokens per image for the Live API, so do not borrow a number from another product.1 Measure it on your model.
- History is re-sent. If you keep every screenshot, turn n carries n images. Input per turn grows linearly, so total input per run grows roughly with the square of the step count.
- Function declarations count every time. Tool schemas are re-billed as input on each turn.1
There is also a threshold effect. The pricing page's Gemini 3 footnote says that when input context is longer than 200K tokens, all tokens, input and output, are charged at long-context rates.1 An agent that never discards screenshots can drift across that line in a long run and reprice the whole request, not only the excess. Check whether the model you pick has such a tier.
Worked example: trimming history
Two caveats apply before you copy the trimming idea. First, the model may do worse when it cannot see earlier screens, so run the same task set with both policies and compare success rate, not only price; cost per successful task is the figure to track. Second, the pricing page lists cached-input rates well below standard input for the models it covers (for Argon, $0.20 against $4.00 per 1M tokens from December 1).1 Whether a computer-use loop gets cached-input pricing on its repeated prefix is something to measure on your own usage records, not to assume.
Also keep an eye on the time-limited rates. The page lists Gemini 4 Argon at $2.00 and $10.00 through November 30, 2026, with the $4.00 and $20.00 rates starting December 1, and notes the earlier rates are promotional.1 A forecast built this week will be wrong in a month if it uses the current rate.
Bound the loop on four axes
An agent that does not know it is stuck will keep paying for screenshots. Bound every run, and make the bound a hard stop in your harness rather than an instruction in the prompt. The general method is in bounding AI agent loops; the computer-use specifics are these.
| Bound | What it stops | Typical failure it catches |
|---|---|---|
| Max steps | Unbounded turns | A popup the agent cannot dismiss |
| Wall-clock deadline | Slow pages, waits | A page that never finishes loading |
| Token budget per run | Context growth | Untrimmed screenshots crossing a price tier |
| Spend ceiling per run and per day | Runaway cost across many runs | A bug that starts 10,000 runs |
| No-progress check | Repeating the same action | Clicking a disabled button forever |
The no-progress check is the one teams miss. Hash each screenshot after downscaling, and keep the last few action and hash pairs. If the same action produces the same hash three times, stop and hand the run to a person or fail it.
import time, hashlib
from collections import deque
MAX_STEPS = 40
DEADLINE_S = 300
MAX_INPUT_TOKENS = 600_000 # per run, measured from usage metadata
def run(goal, browser, model):
start, used = time.monotonic(), 0
recent = deque(maxlen=3)
for step in range(MAX_STEPS):
if time.monotonic() - start > DEADLINE_S:
return stop("deadline", step)
shot = browser.screenshot()
resp = model.next_action(goal, shot, history=trim(browser.history))
used += resp.usage.input_tokens
if used > MAX_INPUT_TOKENS:
return stop("token_budget", step)
action = resp.action
if action.kind == "done":
return finish(action)
key = (action.signature(), hashlib.sha1(shot.small()).hexdigest())
recent.append(key)
if len(recent) == 3 and len(set(recent)) == 1:
return stop("no_progress", step)
decision = gate(action, browser.current_url) # see next section
if decision != "allow":
return pause_for_approval(action, decision)
browser.execute(action)
return stop("max_steps", MAX_STEPS)Retries need the same discipline. A step that fails and is retried re-sends the full context, so count retries against the step and token budgets. The pricing page says non-200 responses are not charged,1 which helps with errors but not with your own re-sends after a timeout that did produce a billable response. If a provider failure forces a change of model mid-run, read failover mid agent run first: browser state lives in your sandbox, not in the model, so a resumed run must re-observe the page rather than trust old coordinates.
Put approvals outside the model
A model that can click can also click "Confirm purchase". Do not rely on the prompt to prevent that. Put a gate in the harness that classifies each proposed action before it executes, using what you know and the model does not: the current URL, the element under the cursor, and the account in use.
A workable first policy has three outcomes:
- Allow reads and navigation inside approved domains: scrolling, clicking links, filling search boxes.
- Hold for a person anything that changes state outside the sandbox: submitting a form that sends or pays, deleting, changing permissions, uploading or downloading files, and typing into a field that looks like a password or card number.
- Deny actions that leave the allowed domain list, open a new window to an unlisted host, or run a downloaded file.
Show the approver the screenshot, the proposed action and the target element, and record who approved it. If the vendor returns a safety signal with an action, treat it as one more input to the gate, not a replacement. I could not read what Google returns here, so check its documentation, and design the gate so it works if no such signal exists.
Keep approval cheap to wait on. A paused run holds a browser container, so store the state, release the container, and resume by re-observing the page after approval, with a time limit on how long an approval can sit.
Sandbox the browser and deny egress by default
The screenshot is an input channel an attacker controls. Any page the agent visits can show text meant to redirect it, which is the prompt injection problem in a visual form; defense in depth covers the general case. You cannot filter what a screenshot says, so assume that a hostile page will sometimes steer the model, and limit what a steered model can reach.
Run each task in a disposable environment:
- One browser per run, in a container or microVM with a fresh profile, destroyed at the end. No shared cookies, no saved logins from real users.
- No host mounts, non-root user, read-only root filesystem where the browser allows it, and CPU, memory and process limits.
- Scoped credentials: if the agent must sign in somewhere, give it a dedicated account with the least rights that complete the task, injected at run time and short-lived where the target supports it. Never put your provider API key inside the sandbox; the harness outside it calls the model.
- Deny-by-default egress through a proxy: allow only the domains the task needs, resolve DNS through the same proxy, and block private ranges and the cloud metadata address so a steered browser cannot reach internal services or instance credentials.
- Downloads and uploads off unless the task requires them, and scanned when it does.
Egress control also protects your model spend. If the sandbox can only talk to the proxy, the only path to a provider is the harness, which is where your budgets live; blocking direct AI provider calls describes the network rules.
Record each run so cost and behavior can be audited
Give every run an id and log, per step: the action, the target URL, the gate decision, the input and output token counts from the response, and the model that answered. Then a bill that rose can be traced to a run, and a run to a step. Tracing an agent run covers joining these across model calls.
If your model calls go through a gateway, the gateway can contribute the cost side. INFRO records each request's model, latency, token counts and estimated provider cost, queryable by project and key, and can refuse requests once a budget cap on a key, project or organization is reached, using your own provider connections and with 0% markup on model spend.2 Per-request traces and a model allowlist per project are also available. Two limits matter here: INFRO does not run your browser or enforce your sandbox's network rules, and I have not confirmed that Gemini's Computer Use tool is carried through any particular endpoint, so check the INFRO docs (opens in a new tab) for the request shape you plan to use before you route an agent through it. The step, time and approval bounds above stay in your harness regardless.
Pre-launch checklist
- GA status, supported models and screenshot token cost confirmed on Google's own pages for the model you will use.
- Token cost per step measured from response usage metadata on 20 or more real tasks, with and without history trimming.
- Max steps, wall-clock deadline, per-run token budget and no-progress check enforced in the harness.
- Per-run and per-day spend ceilings set outside the harness, so a bug that starts many runs still stops.
- Action gate in place with allow, hold and deny outcomes; approvals logged with approver and screenshot.
- One disposable browser per run, no host mounts, scoped credentials, no provider keys inside.
- Egress proxy with a domain allowlist, DNS through the proxy, private ranges and metadata address blocked.
- Screenshot retention and access decided and documented.
- Cost forecast uses the rates that apply on the day the traffic runs, including the dated changes on the pricing page.1
