Repository navigation
Studio: computer use for local and connected models - #17666
Conversation
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
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.
…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.
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.
…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.
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.
…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.
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.
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.
…any apps read only the first
…d the tool schema offers display [skip ci]
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…rd names each shortcut and shows a call it cannot say [skip ci]
…by their Start menu names [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 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".
| 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() |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
…actions [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.why), which the card shows as its title once the call runs; a card waiting on Allow always shows the steps.How it works
screenshot,zoom,click,double_click,right_click,move,drag,scroll,type,key,wait,open_app. A call can chain more actions withthen, 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.left_click+coordinate,keypress+keys[],start_box,scroll_y, ...) are normalised before they run.Safety
Controlling the desktop is outside every sandbox Studio has, so:
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.npm run typecheck,npm run i18n:check:strict,npm test(15,881 pass),npm run build.UNSLOTH_STUDIO_COMPUTER_USE_BACKEND=virtual, which touches nothing real):Not tested here
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):
The first action of a chat asks:
An app the chat has not used asks, with Always allow:
The tool card with its steps and the screenshot the model got back:
Before / after, the composer's + menu:
Before / after, Settings > Computer use (Studio started with the drawn desktop backend so the whole page shows):