Skip to content
AgenticAIWiki
  1. Learn
  2. Part 7
  3. 37. Built-in tools
  4. 37.4

Lesson 37.4 · 4 of 5 · 3 min read · Reviewed 24 Nov 2026

Computer use

By the end, you can

  • Describe what the computer use tool does.
  • Know where to learn the details.

Computer useComputer use: Letting a model operate a computer through screenshots, mouse and keyboard actions. is a tool that lets Claude work a graphical desktop: it looks at screenshots and asks for actions such as moving the mouse, clicking, typing and pressing keys.

Like other client tools, Claude only requests actions. Your code carries them out in a machine you control, usually a virtual machine or container, and sends back a fresh screenshot.

It’s useful when there’s no API: legacy desktop apps, internal web tools, forms. It’s also slower and less reliable than an API, and it opens real safety questions, because the agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. reads whatever is on screen.

Chapter 39 covers the perception and action loop, how to make it reliable, and how to keep it safe.

Key points

  • Computer use lets Claude operate a desktop through screenshots, mouse and keyboard actions.
  • Your code runs the actions in a sandboxed machine and returns new screenshots.
  • Chapter 39 covers the loop, reliability and safety in depth.
Hands-on labRuns in the Playground

Dispatch computer use actions safely

Write the part of a computer use harness that checks each requested action and performs it on a simulated screen.

You will have: An action dispatcher that rejects bad actions, performs good ones and returns a new screen description each time.

Steps

  1. Read the simulated screen: a few named boxes with coordinates on a 1024 x 768 display.
  2. Write dispatch(action) for screenshot, left_click and type.
  3. Reject clicks outside the display and unknown action names with an error result.
  4. After every action, return a fresh description of the screen, as a real harness returns a screenshot.
  5. Replay the scripted actions and print each result.

Done when

  • The click at (2000, 50) is rejected as off-screen.
  • The click on the Name field focuses it, and typing fills it.
  • An unknown action returns an error instead of crashing.

Open in the Playground No API key needed.

Starter code (Python)
W, H = 1024, 768
screen = {"focused": None, "fields": {"name": ""},
          "boxes": {"name": (100, 100, 400, 140), "submit": (100, 200, 220, 240)}}

def describe():
    return f"focused={screen['focused']} name={screen['fields']['name']!r}"

def dispatch(action):
    kind = action.get("action")
    # TODO: screenshot -> describe()
    # TODO: left_click -> check 0 <= x < W and 0 <= y < H, then focus the box under the point
    # TODO: type -> add text to the focused field
    # TODO: anything else -> an error string
    return describe()

script = [{"action": "screenshot"}, {"action": "left_click", "coordinate": [2000, 50]},
          {"action": "left_click", "coordinate": [150, 120]}, {"action": "type", "text": "Ada Lovelace"},
          {"action": "drag_everything"}]
for a in script:
    print(a["action"], "->", dispatch(a))
Show a solution
W, H = 1024, 768
screen = {"focused": None, "fields": {"name": ""},
          "boxes": {"name": (100, 100, 400, 140), "submit": (100, 200, 220, 240)}}

def describe():
    return f"focused={screen['focused']} name={screen['fields']['name']!r}"

def box_at(x, y):
    for name, (x1, y1, x2, y2) in screen["boxes"].items():
        if x1 <= x <= x2 and y1 <= y <= y2:
            return name
    return None

def dispatch(action):
    kind = action.get("action")
    if kind == "screenshot":
        return describe()
    if kind == "left_click":
        x, y = action["coordinate"]
        if not (0 <= x < W and 0 <= y < H):
            return f"error: ({x}, {y}) is off-screen"
        screen["focused"] = box_at(x, y)
        return describe()
    if kind == "type":
        if screen["focused"] not in screen["fields"]:
            return "error: no text field is focused"
        screen["fields"][screen["focused"]] += action["text"]
        return describe()
    return f"error: unknown action {kind}"

script = [{"action": "screenshot"}, {"action": "left_click", "coordinate": [2000, 50]},
          {"action": "left_click", "coordinate": [150, 120]}, {"action": "type", "text": "Ada Lovelace"},
          {"action": "drag_everything"}]
for a in script:
    print(a["action"], "->", dispatch(a))
Quick checkWith the computer use tool, who actually clicks the mouse?
How sure are you?
Pick an answer and how sure you are