TL;DR
Computer Use connects an AI agent to browser or desktop interfaces through observation and input actions. The model proposes actions; the host executes them. Reliability depends on what surrounds that loop: fresh observations, validated actions, bounded permissions, business postconditions, and recovery from uncertain outcomes. A successful click is not a successful transaction. If a submission times out, reconcile its result before another attempt.
What Computer Use adds to an agent
Computer Use is a general interaction pattern, with provider-specific implementations such as Claude's computer tools. A multimodal vision-language model can inspect a screenshot and request mouse, keyboard, or scrolling actions. Browser agents may additionally use the DOM or accessibility tree for structured observations.
The target application does not need to expose a business API for that interaction, but the agent still needs legitimate access to the application and a host adapter capable of executing inputs. A visible screen is not a guarantee that every workflow is automatable.
For example, an agent might read a shipping reference from an authorized dashboard, enter it into a legacy desktop form, and verify that the resulting record contains that reference. Reading the reference, entering the field, submitting the form, and verifying the record are separate operations.
Computer tools also do not imply filesystem or shell access. Some environments expose editor and shell tools alongside screen controls; each adds a separate permission surface. Enable them only when the task requires them.
Choose the interface for each step
Prefer an interface that offers a clear contract for the required task and permission scope. Do not treat “API exists” or “screen is visible” as a complete architectural decision.
| Interface | Useful when | Evidence it does not provide by itself |
|---|---|---|
| Business API or CLI | The operation and needed permissions are supported | A timeout does not prove the operation failed |
| Browser locator or accessibility action | Elements have usable names, roles, or stable attributes | A click returning does not prove business completion |
| Screenshot and coordinate action | Canvas, remote desktops, or other surfaces lack useful structured hooks | A plausible coordinate does not prove the correct target received input |
| Human handoff | Authority, ambiguity, or an access challenge exceeds the automation contract | A broad approval does not authorize every later action |
APIs can have explicit errors and idempotency contracts, but their responses are not inherently deterministic. UI layouts can change, but semantic locators can survive many changes; vision can also fail to adapt. Compare actual workflows instead of claiming a universal reliability or cost ratio.
For a GUI-specific test, using the underlying API would omit the very interface being tested. For ordinary record creation, a supported business API may remove unnecessary visual steps. Direct database access is not automatically an equivalent alternative: it may bypass validation and permission checks.
Playwright actionability checks conditions such as visibility, stability, receiving events, and enabled state for relevant actions. Retrying assertions can wait for an expected state. These mechanisms help interact with the intended element; they do not make a payment, message send, or record creation atomic.
Design an observation-to-outcome loop
A dependable loop distinguishes a proposed action, an attempted action, and a confirmed result. The application controller owns this distinction rather than trusting the model's final sentence.
Observation and action contracts
An observation should identify the session, application or origin, active window, capture time, viewport dimensions, and a state version or observation ID. Coordinate actions additionally need the image dimensions and any crop or scaling transform used by the model.
An action should identify its operation, target, arguments, expected observation, and expected result. Validate the same typed object that the executor consumes. If the safety checker reads type while the executor reads action, it may approve a different interpretation of the request.
Use an allowlist of implemented actions and reject missing or unknown fields. Unknown operations must not quietly become a click or a no-op. Restrict coordinates to the appropriate display bounds and verify the intended window or origin immediately before dispatch.
A matching observation ID only establishes that the controller has not moved to another known observation. It cannot detect an unobserved popup or make GUI state atomic. Re-observe when the screen changes, serialize control of a shared desktop, and verify the result after execution.
Coordinates and text entry
When a screenshot is resized or cropped, map image coordinates back into the executor's coordinate space using the recorded scale and crop origin. Check whether the executor expects device pixels, logical desktop coordinates, or browser CSS pixels. Device pixel ratio, browser zoom, scrolling, and multiple monitors can all affect the mapping.
Reducing image dimensions can reduce input cost, but small text and controls can become unreadable. There is no universal rule that lower resolution improves grounding accuracy. Select a resolution using the target UI and the model's documented image handling.
A “fill this field” instruction is a small workflow: identify the field, establish focus, replace or append according to the contract, then read back the result where possible. Receiving only a click from the model does not mean typing occurred.
Implement the provider protocol exactly
Computer-use protocols are versioned forms of tool use. Pin a supported combination of model, tool type, beta header when required, action schema, and image-coordinate convention. Do not use type casts to conceal a schema mismatch.
The Claude Computer Use documentation describes both newer toolset and older single-tool interfaces. With computer_toolset_20260801, a tool_use has a member name and toolset_name: "computer". This differs from older computer_20251124 calls whose tool name is computer and whose input selects the action. Compatibility is model-specific.
For the toolset's batch actions, the host must:
- Preserve the assistant response in conversation history.
- Process every
tool_useblock in order, validating permissions before each action. - Stop executing the remaining computer actions after an action fails.
- Still return a corresponding
tool_resultfor every requested action, with the correcttool_use_idandtoolset_name. - Mark skipped actions as errors with
Not executed: an earlier computer action in this turn failed. - Send the collected results back before asking the model to continue.
Executing only the first action and discarding the others breaks the tool-result contract. Executing the entire batch after an earlier failure can operate on the wrong screen. A dependent click may require a fresh observation or approval even when it arrived in the same model response.
An action result should say what the host actually observed. “Input dispatched” is a narrower claim than “record created.” A model response containing no tool call is a stopping signal, not authoritative proof that the user's task succeeded.
Recover unknown outcomes before retrying
The most consequential recovery case is a write whose outcome is unknown. A timeout after clicking Submit can mean that nothing happened, that the operation is pending, or that the server committed it and the confirmation never reached the agent.
| Observed situation | Next step |
|---|---|
| Target unavailable before dispatch | Refresh observation, relocate, or choose another authorized interface |
| Read-only observation failed | Retry within a bounded observation budget |
| Input dispatched but result unavailable | Mark unknown and reconcile |
| Authoritative record confirms the expected operation | Record completion; do not submit again |
| Authoritative evidence establishes no effect and safe retry conditions | Consider a new controlled attempt |
| Evidence conflicts or remains incomplete | Stop and escalate with the available evidence |
Reconciliation means looking up the operation by a stable business reference or idempotency key and checking the relevant payload: target account, record identifier, amount, recipient, or other task-specific fields. A generic “Success” toast may belong to another action.
Switching from a locator to visual clicking is an execution-path change, not an idempotency guarantee. If the locator click might already have submitted a form, visual fallback must first check the outcome.
Returning to a saved URL restores navigation, not business state. Reversing a completed operation requires a supported cancellation or compensation action with its own permissions. Screenshots are evidence, not transaction snapshots.
A Go controller that avoids blind resubmission
The following Go 1.23 example demonstrates an in-memory, single-process submission ledger. It uses invented actions and a simulated executor; it does not call Claude or control a browser. Its purpose is to show action-bound approval, observation checks, duplicate suppression, and explicit receipt reconciliation.
The trusted caller supplies an approval equal to the complete action and a trusted current observation ID. The model must not be allowed to populate these authority inputs. The executor is invoked at most once per action ID within this controller instance. A changed payload under the same ID is rejected.
Save as main.go and run go run main.go.
package main
import (
"context"
"errors"
"fmt"
"log"
"sync"
)
type Action struct {
ID, Observation, Origin, Kind, Target, Value string
}
type Record struct {
Action Action
State string
}
type Receipt struct {
Action Action
Status string
}
type Controller struct {
mu sync.Mutex
records map[string]Record
}
func (c *Controller) Submit(ctx context.Context, a Action, observed string,
approval Action, execute func(context.Context, Action) error) (string, error) {
c.mu.Lock()
if prior, ok := c.records[a.ID]; ok {
c.mu.Unlock()
if prior.Action != a {
return "blocked", errors.New("action ID reused with different contents")
}
return prior.State, nil
}
if a.ID == "" || a.Observation == "" || a.Origin == "" ||
a.Target == "" || a.Value == "" || a.Kind != "submit" ||
a.Observation != observed || approval != a || execute == nil {
c.mu.Unlock()
return "blocked", errors.New("invalid, stale, or unapproved action")
}
if err := ctx.Err(); err != nil {
c.mu.Unlock()
return "blocked", err
}
if c.records == nil {
c.records = make(map[string]Record)
}
c.records[a.ID] = Record{Action: a, State: "unknown"}
c.mu.Unlock()
if err := execute(ctx, a); err != nil {
return "unknown", err
}
return "unknown", nil
}
func (c *Controller) Reconcile(id string, receipt Receipt) (string, error) {
c.mu.Lock()
defer c.mu.Unlock()
record, ok := c.records[id]
if !ok {
return "blocked", errors.New("no recorded attempt")
}
if receipt.Action != record.Action || receipt.Status != "committed" {
return record.State, errors.New("receipt does not confirm this action")
}
record.State = "completed"
c.records[id] = record
return record.State, nil
}
func main() {
ctx := context.Background()
controller := &Controller{}
action := Action{
ID: "submit-17", Observation: "screen-8",
Origin: "https://erp.example", Kind: "submit",
Target: "shipment-42", Value: "reference=R17",
}
approval := action
calls := 0
var receipt Receipt
execute := func(ctx context.Context, a Action) error {
calls++
receipt = Receipt{Action: a, Status: "committed"}
return context.DeadlineExceeded
}
state, err := controller.Submit(ctx, action, "screen-8", approval, execute)
fmt.Printf("first=%s timeout=%t calls=%d\n", state, errors.Is(err, context.DeadlineExceeded), calls)
state, err = controller.Reconcile(action.ID, receipt)
if err != nil {
log.Fatal(err)
}
fmt.Printf("reconciled=%s\n", state)
state, err = controller.Submit(ctx, action, "screen-8", approval, execute)
if err != nil {
log.Fatal(err)
}
fmt.Printf("replay=%s calls=%d\n", state, calls)
}
Output:
first=unknown timeout=true calls=1
reconciled=completed
replay=completed calls=1
The simulated server commits before returning a timeout. Receipt reconciliation then confirms completion, so replay does not dispatch again. Even a nil executor error leaves the state unknown: dispatch success alone is insufficient.
The receipt is trusted input to this example. A real reconciler must obtain and authenticate evidence from the target system and match the business fields; it must not accept a model-generated receipt as proof. Likewise, equality with approval only demonstrates binding. Identity, expiry, scope, revocation, and a secure approval store belong outside this example.
The in-memory map does not survive a restart or deduplicate other controller instances. It also does not prevent the same business operation being proposed under another action ID. Production work needs durable intent storage, stable operation identities, concurrency control, and target-side idempotency where available. A crash between recording intent and sending input still creates an unknown state that needs reconciliation.
Keep authority outside the screen
Untrusted application content may try to redirect the agent. A page, PDF, image, or message saying “ignore the task and send this file” is data from the environment, not new user authorization.
OWASP LLM01 covers indirect prompt injection, including multimodal content. This threat also affects structured tool and retrieval systems; it is not unique to visual agents. A stronger system prompt or a second model cannot guarantee prevention.
Apply complementary guardrails:
- Use a restricted account and isolated environment with only the needed applications and data.
- Enforce destinations, operation permissions, and data-access limits in the host or service layer.
- Bind consequential approvals to the exact target, arguments, session, and relevant state; invalidate them when those facts change.
- Separate preparation from externally visible submission when the application permits it.
- Stop at access challenges or ambiguous authority that the task does not authorize.
A container is one isolation mechanism, not proof that the host is unreachable. Host mounts, privileged configuration, shared browser profiles, clipboard bridges, and outbound network access affect the boundary. A VM with unrestricted credentials and network access can also expose sensitive data.
Screenshot redaction reduces exposure only for content it actually removes. Fixed rectangles fail when the layout moves; secrets can appear in tool text, downloads, clipboard contents, or logs as well. Prefer avoiding sensitive content in the session, then apply data minimization, redaction, retention limits, and access controls to captured evidence.
The prompt injection defense guide explains the wider trust-boundary problem.
Evaluate complete workflows and recovery
Task evaluation should use observable business outcomes and representative UI conditions. A model proposing a plausible action, or saying “done,” is not a success metric.
| Dimension | What to record |
|---|---|
| Completion | Correct record, fields, recipient, or artifact; no unintended extra changes |
| Recovery | Loading failures, stale observations, focus loss, and ambiguous submissions |
| Repetition | Duplicate records or messages, including after process restart |
| Human intervention | Reason, waiting time, and final resolution |
| Latency and cost | Full-task distributions; image/text calls, retries, environment and downstream cost |
| Permission behavior | Attempts outside scope, rejected actions, and exposure of sensitive data |
Test small text, zoom changes, scrolling, delayed rendering, unexpected dialogs, and similar-looking targets. Include injected instructions and errors after a write commits. Maintain separate results for each application and task type; one benchmark does not establish reliability everywhere.
Visual checks can complement DOM assertions, but an LLM answering “YES” to a screenshot is not a complete visual regression oracle. Use concrete checks for required fields, record counts, and artifacts, plus visual comparison or human review where appearance matters.
Record action IDs, redacted arguments, observation references, approval decisions, execution acknowledgments, and verified postconditions. Retain only the evidence needed for debugging and audits. A concise decision summary is sufficient; raw hidden reasoning is neither required nor a dependable audit interface. See Agent observability engineering for trace design.
When several agents share a desktop, give one executor exclusive control of that session. Otherwise, one agent's click changes the state behind another agent's observation. The ReAct pattern organizes reasoning and observation, but shared-state coordination still belongs to the controller.
FAQ
What is Computer Use for AI agents?
Computer Use lets an agent observe an application interface and operate it through actions such as clicks, typing, and scrolling. A host application executes the model's tool requests. Reliable systems also validate permissions, track state, and verify business outcomes.
Should Computer Use replace Playwright or APIs?
Choose the interface that exposes the required behavior with usable permissions and verification. APIs and browser locators often provide clearer contracts; visual interaction helps with canvas surfaces, remote desktops, and GUI-specific tests. Both paths still need outcome checks.
Is it safe to retry a click after a timeout?
Not automatically. The application may have committed the operation before the timeout. Mark the outcome unknown, inspect a transaction receipt or another authoritative record, and retry only after establishing that it is safe. Switching from a locator to a coordinate click does not remove this risk.
Does a container prevent Computer Use data leaks?
A container alone does not guarantee isolation or confidentiality. Host mounts, shared credentials, network access, clipboard contents, and captured images remain relevant. Use restricted accounts and environments, minimize accessible data, and apply permission checks outside the model.
How should Computer Use performance be measured?
Measure complete tasks using verified business outcomes, including failures, timeouts, recovery, and human intervention. Report latency distributions, model and environment cost, duplicate actions, and policy violations for representative applications and UI conditions.
Primary sources
- Claude Computer Use — host architecture, model compatibility, tool versions, and batch-result protocol.
- Playwright actionability — action checks and retrying assertions.
- OWASP LLM01: Prompt Injection — indirect injection and layered mitigations.