Add `desktop` to `SmolSandbox` for `ComputerUse`

Merged
AD
11d ago
+183-13

Why

ComputerUse needs a screen. The shared X11 desktop that DockerContainer(desktop=True) and E2BSandbox(desktop=True) use runs unchanged on a smolvm microVM on your machine, so this PR adds the same desktop option to SmolSandbox.

New public surface

  • SmolSandbox.desktop and SmolSandboxBackend(desktop=...): True for 1280x800, or (width, height). The default is False.
  • SmolSandboxBackend.display.

User-visible behavior

agent = Agent('anthropic:claude-opus-5-5', capabilities=[SmolSandbox(desktop=True, allow_internet_access=True), Coder(), ComputerUse()])

The display starts on first use. run() starts it before each shell command and adds DISPLAY, so programs the agent starts from the shell open on it. Only the local target is covered.

smolvm's default image is Alpine, which has no apt-get, so a desktop VM without an image runs debian:bookworm-slim. Installing the X programs (#11040) needs allow_internet_access=True, or an image that already has them. A new desktop VM without either raises UserError when the backend is created.

There's no live viewer; the docs show how to save each screenshot to watch a run. The agent can type only ASCII, as on the other X11 desktops.

Verification

  • smol_sandbox/test_smol_desktop.py: a desktop VM runs Debian and the computer tool; a shell command finds the desktop running; a reattached VM keeps its display.

  • Live on macOS (Apple silicon), with ComputerUse and the sandbox only, no shell (2026-11-23). The task: "Open a terminal, type echo hello-desktop, press Enter, and tell me what the terminal shows." In each run the final screenshot shows the command, hello-desktop and a new prompt, and the model reported it. No tool errors.

    ModelResultRequests / computer callsTime
    anthropic:claude-sonnet-5-5pass4 / 325.7 s
    openai-responses:gpt-5.5pass4 / 328.9 s
  • Live display contract at 1024x768: passed. First use took 20.4 s, including the install.

  • Live: image='alpine:3.20' raises WorkspaceUnavailableError naming the missing programs and that there's no apt-get.

All VMs were deleted afterwards.

What changes for existing users

Nothing: desktop defaults to False.

Changes in this round

  • The check_desktop helper had one caller, so its check is now inline in __init__, with the same message as BoxLite and Render.
  • The display is built with the shared x11_display() from #11040, and DISPLAY is set in one line. The desktop size is passed inline instead of stored.
  • test_smol_desktop.py 5 passed.

Review rounds

One round with gpt-6.2-sol on this PR's own diff: clean.

Depends on

#11040.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.