Skip to content

Studio: computer use for local and connected models - #17666

Merged
danielhanchen merged 45 commits into
mainfrom
studio-computer-use
Nov 15, 2026
Merged

danielhanchen merged 45 commits into
mainfrom
studio-computer-use

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What this adds

A model you chat with can now see this computer's screen and use its mouse and keyboard in any app, the same way browser use drives the browser panel. It works with local models (GGUF, safetensors, MLX) and connected providers, because it is an ordinary function tool in Studio's tool loop: one tool named computer.

  • Settings > Computer use: a page of its own. "Control" has the owner's switch for computer use (off by default, with a confirmation), the macOS grants it needs with a button for each, and how the model names a point. "Always-allowed apps" lists the apps models may use without asking, and "Blocked apps" the ones they may never act in. "Browser use" at the end has the browser panel switch.
  • Composer: "Computer use" in the + menu and a "Computer" pill, next to Browser use. Until the switch is on, choosing the item opens the setting.
  • Tool card: each call reads as steps ("Click at (504, 346), Type "hello""), with the screenshot the model got back inside the card. A model can add a few words on what the call is for (why), which the card shows as its title once the call runs; a card waiting on Allow always shows the steps.

How it works

  • One tool, chained actions. screenshot, zoom, click, double_click, right_click, move, drag, scroll, type, key, wait, open_app. A call can chain more actions with then, which stop at the first that fails. After acting, the tool waits for the screen to settle and answers with the new screenshot, so a step costs one model round trip instead of an action and a look. When nothing changed it says so and sends no picture.
  • The server owns coordinates. A model only names a point in a picture it was sent. The screenshot is resized to at most 1008 px on a 28 px grid (under the shared 1024 px image cap, so it is never resized again) and each frame maps back to desktop points, which handles Retina and a second display. Model families trained on a 0 to 1000 grid get that rule automatically; the setting overrides it.
  • Other dialects are accepted. Calls shaped like the other common computer tool formats (left_click + coordinate, keypress + keys[], start_box, scroll_y, ...) are normalised before they run.
  • A stale target is not clicked. Before a click, the screen around the point is compared with the screenshot the model chose it in. If a dialog opened or the page moved, nothing is clicked and the model gets the current screen instead.
  • No new dependencies. Each operating system's own input and capture calls are used through ctypes (with per-monitor DPI awareness on Windows), and screenshots use the image library Studio already ships.

Safety

Controlling the desktop is outside every sandbox Studio has, so:

  • It is only offered when the server serves the machine it runs on: a loopback bind, no tunnel or LAN listener, not a hosted notebook, the installation owner, never an API key. No environment variable widens this.
  • Each chat asks before its first action, in every permission mode except Full access. The go-ahead lapses after 30 idle minutes and when the switch goes off.
  • An app the chat has not used yet asks first. "Allow" covers that app for the chat; "Always allow " adds it to the list in Settings, where it can be removed. A click is charged to the app whose window it lands in, not the one in front.
  • A blocked app (Settings > Computer use > Blocked apps) is never clicked, typed into or opened, in any chat or permission mode, Full access included. A blocked name matches whole words, so a one-word name covers a longer app name that contains it. Blocking only stops input: the app can still appear in a screenshot.
  • "Approve for me" and "Run automatically" still ask before risky steps: a terminal, password manager or system tool, opening one, or shortcuts that close or delete. The card says why, and those can never be always allowed.
  • Never done: keys that lock the screen or end the session, input into an operating system security prompt, and input into Unsloth's own window, in front or showing from behind (so a model cannot approve its own request). A browser window whose title cannot be read counts as Unsloth's.
  • The tool refuses on its own, too: a call that reaches it without the user's answer (a request that could not ask) does nothing.
  • Window titles reach the model inside an untrusted-text fence, and the tool description tells it never to follow instructions on screen.
  • Stop in the chat ends a chain between actions. So does turning the switch off, in Settings or in the composer.
  • Moving the pointer into a corner of the screen stops computer use, and the chat stays stopped: only the user lifts it, by answering the chat's next question or with "Allow again" in Settings. Without that a chat on Full access, which asks nothing, would simply carry on.
  • One chat holds the mouse and keyboard at a time.
  • A click, drag or scroll is charged to the window it actually lands in, in front or behind, on every system; a drag to both of its ends. The app in front is checked again before every key, repetition and piece of typed text.
  • The go-ahead, the allowed apps and a stop belong to one conversation, so the chats of a project each ask for themselves.
  • Switching computer use off, in Settings or the composer, ends input where it is (between keys, mid-text, before a pending click) and holds until it is switched back on.
  • An app is known by one name whether it is opened or acted in: the Start menu's name on Windows, the launcher's on Linux, with the file name or window class kept as its id.
  • An approval card never says less than the call does: when the steps do not put all of a call into words, the call is shown as sent beneath them.

Verified

  • studio/backend/tests/test_computer_use.py (181 tests): the dialects, key spellings, frame mapping, the picture reaching the model at the frame's size, whole calls against a drawn desktop, every refusal above, the approval gate in each mode, tool selection, and the routes.
  • studio/backend/tests/test_computer_use_live.py: the macOS backend's read-only calls and its refusals without grants ran here. The Linux tests start a private virtual display and the Windows tests run on CI runners; neither could run on this Mac.
  • Frontend: npm run typecheck, npm run i18n:check:strict, npm test (15,881 pass), npm run build.
  • In a running Studio, against a drawn desktop (UNSLOTH_STUDIO_COMPUTER_USE_BACKEND=virtual, which touches nothing real):
    • a connected provider (a scripted chat completions endpoint): the first call asked, the first click asked about the app with "Always allow ", the next steps ran, a quit shortcut asked with its reason, the screenshots reached the provider, and the app then showed in Settings and could be removed;
    • a small local vision model (GGUF, Q4_K_M): it clicked the field, typed, pressed the button and read the result off the screen in 19 s, on the 0 to 1000 rule.

Not tested here

  • The 24 non-English translations of the new strings have not had a native review.
  • Real mouse, keyboard and screen capture on macOS: this host's session has neither the Screen Recording nor the Accessibility grant.
  • The Windows and Linux backends beyond what their CI tests will cover. Wayland sessions are reported as unsupported rather than attempted.
  • The safetensors and MLX loops (no PyTorch on this host); they share the tool path with the GGUF loop.
  • The Desktop app build, including the new "Computer use" row in its Go > Settings menu.

Cross-platform check and screenshots

A scripted fake model now drives the real desktop through Studio's own tool loop (test_a_scripted_model_types_into_a_real_window): it takes a screenshot, finds a Tk window's field and button by colour in the picture it got back, clicks the field, types, and clicks the button; the window records what arrived. It passed on real runners: Linux x64 and ARM64 (Xvfb), Windows x64, and macOS 15 and 26. The test fails on CI instead of skipping, and with typing turned into a no-op it fails as it should.

Computer use in a chat (a scripted provider on Studio's drawn test desktop, so nothing real is touched):

Computer use in a chat

The first action of a chat asks:

First action asks

An app the chat has not used asks, with Always allow:

New app asks

The tool card with its steps and the screenshot the model got back:

Tool card

Before / after, the composer's + menu:

+ menu before and after

Before / after, Settings > Computer use (Studio started with the drawn desktop backend so the whole page shows):

Settings before and after

A model you chat with can see this computer's screen and use its mouse and
keyboard in any app, through one function tool named `computer` in the chat
tool loop. Local models (GGUF, safetensors, MLX) and connected providers get
it the same way.

How it works
- Actions: screenshot, zoom, click, double_click, right_click, move, drag,
  scroll, type, key, wait, open_app. A call can chain more with `then`; the
  chain stops at the first action that fails.
- After acting, the tool waits for the screen to settle and answers with the
  new screenshot, so a step is one model round trip. An action that changed
  nothing says so and sends no picture.
- The server owns coordinates. Screenshots are sent at most 1008 px wide on a
  28 px grid, under the shared image cap, and each frame maps picture points
  back to desktop points (Retina, second display). Models trained on a 0 to
  1000 grid get that rule by model name; a
  setting overrides it.
- Calls shaped like other computer tools
  are normalised before they run.
- Before a click, the screen around the point is compared with the
  screenshot it was chosen in. If it moved, nothing is clicked and the model
  gets the current screen.
- No new dependencies: each operating system's own input and capture calls
  through ctypes, and the image library Studio already ships.

Safety
- Only offered when the server serves the machine it runs on (loopback bind,
  no tunnel or LAN listener), to the installation owner, in the
  UI. Settings > Security has the owner's switch, off by default.
- Every chat asks before its first action. After that "Approve for me" and
  "Run automatically" still ask before risky steps: a terminal, password
  manager or system tool in front, and shortcuts that close or delete.
- Never: keys that lock the screen or end the session, input into an
  operating system security prompt, or input into Unsloth's own window, in
  front or showing from behind.
- The tool refuses a call that reached it without the user's answer, so a
  request that could not ask does nothing.
- Stop ends a chain between actions; the pointer in a screen corner stops
  computer use and withdraws the chat's go-ahead.

UI
- "Computer use" in the composer's + menu with a pill, beside Browser use.
- Tool cards read as steps and hold the screenshot the model got back.
- The approval card says why a call asks and has no "Always allow".
Computer use gets its own page in Settings, after Browser, and leaves the
Security page.

Control
- Any app: the owner's switch for computer use, with its confirmation.
- Browser: the browser panel switch, the same setting as in Settings > Browser.
- The macOS grants (screen, mouse and keyboard), each with an Allow button
  or "Allowed".
- How the model points.

Always-allowed apps
- An app a chat has not used yet now asks first. Allow covers that app for
  the chat; "Always allow <app>" on the card adds it to this list, where it
  can be removed.
- A click is charged to the app whose window it lands in, not the one in
  front, and keys to the app in front after the clicks before them.
- Terminals, password managers and system tools still ask every time and
  cannot be added. The tool refuses an app it was not asked about, so a
  request that could not ask does nothing there.
- Ask mode asks every call anyway, so its card has no Always allow.

The page is owner-only, is listed in the command palette and the desktop
Go > Settings menu, and is covered by the settings tab smoke lists.
…tings page

The settings page drops its card and icon tiles for the plain section and
row layout the other pages use, with icons only on the two main switches as
in Settings > Browser. Computer use takes the mouse pointer icon in the
composer menu and pill, tool cards and Settings.
… on each call

Blocked apps (Settings > Computer use): apps no model may click, type in or
open, in any chat or permission mode. A blocked name matches whole words, and
blocking an app takes it off the always-allowed list.

Moving the pointer into a corner now leaves the chat stopped until the user
lifts it, by answering the chat's next question or with Allow again in
Settings. Before, a chat on Full access was simply allowed again by its next
call. Turning the switch off, in Settings or the composer, also ends the
actions that are running.

A call can carry a few words on what it is for (why). The tool card shows
them as its title once the call runs; a card waiting on Allow still shows the
steps.
…puter use

The switch reads "Apps on this computer", its description drops to two lines, and the pointer icon is drawn with every corner rounded wherever computer use shows.
…what it is

The icon is the cursor browser use moves over a page. The switch is titled "Computer use" and its description sets "mouse and keyboard" in bold.
Same cursor shape with its rounded tips, as a 1.5 stroke with no fill, so it sits with the other settings icons.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T16:09:53.646755Z a8e4bf9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The icon is the icon set's own cursor. The composer menu always reads "Computer use"; until the switch is on, choosing it still opens the setting.
Control now holds only the computer use switch and the rows that depend on it. The Browser switch moves to a Browser use section at the end of the page.
…rd, and the app a name opens

On X11 a click is now charged to the topmost window under the point, in front or behind, so a blocked app or Unsloth's own window showing from behind is not reached through the app in front.

The app in front is checked again before every chord and repetition of a key action, so a chord that switches apps does not carry the rest into a blocked app, Unsloth's window or a security prompt.

open_app applies the policy to the application its name resolves to before anything starts, so part of a name cannot open a blocked app.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

A drop is input to the window it lands in, so the destination passes the same blocked-app and approval checks as the start, when the call runs and when its approval is prepared.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…rns that still have the tool

A call queued behind another chat is refused if computer use was switched off while it waited.

Switching it off, in Settings or the composer, now leaves the account's chats stopped until it is switched back on, so a running turn on Full access, which keeps the tool it started with, cannot simply be allowed again by its next call.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

A long text is typed 40 characters at a time, and before each piece and before the Enter that follows it the stop, the switch, the corner gesture and the app in front are checked again.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ter lands on it

The refusal was only made for a prompt in front. It now also covers the window a click, drag or scroll actually lands in.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The frontend re-attached a saved result's pictures only for view_image and MCP tools, so on the next turn a computer result went back to the model as text that spoke of a screenshot it no longer had.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…he screen on

A chain that zoomed and then acted, or asked for a screenshot, answered with the crop from before. It now answers with the screen as it is.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The pointer was masked out of the comparison with a square that could hide a small control changing under it, so a ticked checkbox read as nothing changed. Screens are now compared before the pointer is drawn on, and the pointer is drawn the same way on every system.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The approval was prepared for the app in front while the run checked the window under the pointer, so a scroll over an app not yet allowed was refused every time without ever asking.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 91d4b4945c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…rd names each shortcut and shows a call it cannot say

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93596c362e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/state/computer_use.py Outdated
Comment on lines +149 to +151
def revoke_account(account_id: str) -> int:
"""Every chat of this account asks again and stays stopped: a running turn keeps its tool."""
halt_running()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope revocation's halt signal to the requesting account

On a multi-account installation, a managed user can interrupt the owner's running computer actions by calling /api/computer-use/revoke: that route requires authentication but not OwnerOnly, and this unconditional call increments the global halt counter before filtering sessions by account. _Run._stopped() checks that counter for every account, so even revoking an account with zero computer-use sessions stops the owner's execution. Scope the halt signal by account, or restrict the endpoint to the owner who is permitted to use computer control.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a8e4bf9: the halt counter is per account, so /revoke (and the Settings switch) end only the calling account's running chains; a test checks another account's revoke leaves a running chain alone while the own account's still stops it.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a8e4bf9f2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants