Skip to content

Latest commit

 

History

History
95 lines (67 loc) · 3.1 KB

computer-use.md

File metadata and controls

95 lines (67 loc) · 3.1 KB

Use a computer by its screen

The problem

A barber shop books customers in an old program. It has no way in for other code. People ring to move a booking.

The first try is a macro. It repeats the same clicks every day and never looks. A new booking moves the rows. A notice covers the screen. Then the macro changes the wrong thing, or nothing.

How it works

Use a computer by its screen.

This is computer use. The model reads a screenshot and asks for one action.

  1. Code draws the screen as a picture and sends it with the job.
  2. The model asks to click a point or to type, as a tool call.
  3. A guard refuses any click on a delete button.
  4. Code does the action and takes a new picture.

For example, a notice appears. The model clicks OK, then looks again.

The flow

sequenceDiagram
    participant Code as Your code
    participant Model
    participant Program
    loop until the job is done
        Code->>Program: take a screenshot
        Code->>Model: the job and the picture
        Model-->>Code: click or type
        alt the button deletes something
            Code->>Code: refuse and say why
        else the action is safe
            Code->>Program: do it
        end
    end
Loading

Concepts

Run it

uv run lab computer-use naive
uv run lab computer-use

Add --case 2 or --case 3 to try the other cases.

Prove it

There are three calls from customers. A call counts when the asked change is saved and nothing else changed.

Version Changes made correctly Tokens used
Recorded macro 1 0
Look, then act 3 19132

Now break it. Open the pattern file and find risky. Make it always say no. Then run the test:

uv run pytest tests/promises/test_computer_use.py

The test fails, because the model can now delete a booking.

Stuck points

  • The model may click one spot again and again. Check that your screen shows a change. Our first screen had no cursor in the box, and the model got stuck there.
  • Code stops after a set number of actions. Look at the printed actions to see where it stuck.

What to watch for

The program here is drawn by code and is very plain. A real screen is busier and harder. The macro costs nothing to run. Use a real way in, such as a tool, when there is one.

This lab uses its own click and type tools. Some model makers offer a built in computer tool. This lab does not use it. Run a real one in a sealed machine.

Where to go next

Go to Generate screens from typed blocks. There the model helps build the screen.