Quick Start
1
Simple Usage
Read-only tools never require approval, so an observer agent works out of the box.
2
With Configuration
Register an approval callback, then add the control tools. Every click, type, key, and scroll passes through the callback first.
How It Works
Configuration Options
Every tool returns a string — errors are reported as messages, never raised. Tools:
Approval Callback:
set_computer_approval sets a process-wide singleton behind a lock. Call it once and every later tool call in the process uses the same gate. Pass None to revoke — control actions then default back to deny.
Common Patterns
Read-only observer — no approval callback, so the agent can look but not touch.Best Practices
Register approval before building the Agent
Register approval before building the Agent
Call
set_computer_approval(...) at process start, before you construct the Agent. Control tools default to deny — an agent that starts without a callback will silently refuse every click, type, key, and scroll.Pattern-match on the action string
Pattern-match on the action string
The callback receives a stable, human-readable action string like
click(320, 480, left) or type('hello'). Pattern-match on this — the tool name is not passed separately.Surface the non-ASCII typing message
Surface the non-ASCII typing message
Emoji, accented letters, and other non-printable characters are dropped by the backend.
computer_type reports "Typed N of M characters (non-ASCII skipped)" when this happens — surface that message to the user rather than assuming the whole string was typed.Screenshots without a path are ungated
Screenshots without a path are ungated
computer_screenshot() with no path is read-only and ungated. computer_screenshot(path="/tmp/x.png") writes to disk and goes through the approval gate as screenshot_save('/tmp/x.png') — an agent cannot overwrite arbitrary files without approval.Invalid keys and directions are rejected, not silently normalised
Invalid keys and directions are rejected, not silently normalised
computer_key("") returns "Key press failed: empty or invalid key string ''" — the backend is never called. computer_scroll(direction="sideways") returns "Scroll failed: invalid direction 'sideways' (expected 'up' or 'down')" — it does not default to "down". If your callback pattern-matches on the return string, handle these failure prefixes explicitly.Expect no-ops in headless or CI environments
Expect no-ops in headless or CI environments
A missing display returns the same
"Computer Use backend unavailable: ..." message as a missing package. On Linux pyautogui needs an X11 display; in CI containers and on headless boxes these tools no-op — don’t gate business logic on their success.Related
Approval
Broader human-in-the-loop approval patterns for gating agent tool calls.
Allowed Tools
Restrict which tools an agent is permitted to call.

