Add `LocalDesktop`: a screen on this Linux machine for computer use
Draft
AD
11d ago+15661+15661+01234567890123456789012345678901234567890123456789-236-236-012345678901234567890123456789
Adds LocalDesktop, a LocalWorkspace with a screen, so ComputerUse runs on this Linux machine without Docker or a cloud sandbox.
agent = Agent(model, capabilities=[LocalDesktop('.'), Coder(), ComputerUse()])
What changes for users:
- By default the screen is a private, invisible Xvfb with fluxbox, started on first use, at
size=(1280x800 by default). Only the agent's commands can connect to it. - Later and concurrent runs of the same
LocalDesktopshare that screen and see the windows earlier runs left. It stops when the program exits; if only the window manager exits, it starts again and the windows stay. - Commands run on the screen too, so an app the agent starts through
Coderorworkspace.runopens there. real_screen=Truedrives the X session you're logged in to, on bothLocalDesktopandLocalDesktopBackend. Modifier keys you hold are left alone.- Refused with a
WorkspaceUnavailableErrorat the first display call (commands still run): non-Linux, a Wayland session, noDISPLAYforreal_screen, missing programs (the message names theaptpackages). LocalDesktopBackendandVirtualScreenare public forworkspace=use. Backends given noscreenshare one private 1280x800 screen in the process, so building one per run starts one screen; passscreen=VirtualScreen(size)for one of its own andawait screen.stop()to stop it.
Shared code (_x11.py, used by the Docker and E2B desktops):
X11Computerno longer setsDISPLAY; the backend's commands carry it (Docker and E2B already did).X11Computer(release_modifiers=False)skips releasing stuck modifiers before each action, for a screen a person is using.
Decisions:
- One private screen per capability instance, not per run (documented, with "give each concurrent user its own
LocalDesktop"). - One spelling for the real screen,
real_screen=True, matching howDockerSandboxand its backend sharedesktop=;screen=takes only aVirtualScreen, and passing both is refused. - Linux X11 only. Wayland (portal and libei, with a consent dialog) and macOS (ScreenCaptureKit and Quartz events) are follow-ups that don't change this API.
- Screen processes are plain
Popens undersetpriv --pdeathsig, started from one long-lived thread, so the screen survives eachrun_syncevent loop and stops with the program.
Tested:
- Unit tests with fake X programs on
PATH(screen tests skip off Linux; run in a Debian container: 71 passed), including three backends given no screen starting one Xvfb (fails without the fix). - Ubuntu 24.04 container with real Xvfb, fluxbox and xdotool: workspace conformance suite against
LocalDesktopBackend; checks by effect in a real app on the private screen and on a stand-in logged-in session (unicode typing, click to focus, drag, double-click selection, scroll, pointer position, two screens, restart after the X server is killed, across event loops, Wayland refused). - End to end with
ComputerUse: Claude Sonnet 5.5, GPT-5.5 and Gemini 3.8 Flash each typed a command whose output had to reach a file.
Depends on: #11211 (pydantic_ai_harness._x11.X11Computer and the moved tests/harness/test_x11.py), so #11006, #11037 and #11040 too. Does not need #11210, #11038 or #11039. Merge order: last on the desktop track.
What to look at:
local_desktop/_backend.py:VirtualScreenstart, stop and restart; the shared default screen; every command starts the private screen (a screen that can't start costs up to 10 s per command, then the command runs without it).real_screenvs the private default, and thescreen=parameter on the backend._x11.py:DISPLAYnow comes from each backend's command env.
š¤ Generated with Claude Code