Overview
You can tune browser and desktop sandboxes for the task your agent needs to complete. Start with the defaults, then adjust the screen size, memory, disk, profile, or recording options when your workflow needs them. Pass these options directly toSmolVM.browser() or SmolVM.desktop().
Import
Common options
Runtime backend. Options are
"firecracker", "qemu", "libkrun", and "auto".Existing sandbox ID to reconnect to. Omit it to create a new sandbox.
Browser profile name. Reuse the same ID to keep browser state such as cookies and local storage across persistent browser sessions.
Keep the sandbox record after the current Python process exits. This lets another process reconnect with
session_id.Maximum session lifetime in minutes.
Guest memory in MiB.
Root filesystem size in MiB.
Maximum seconds to wait for the sandbox and display services to become ready.
Environment variables to set inside the sandbox.
Folders to share with the sandbox.
Advanced local options
Local directory for sandbox state. Omit it to use SmolVM’s default state directory.
Local directory for runtime sockets. Omit it to use SmolVM’s default socket directory.
SSH private key path used for setup and file transfer inside the sandbox.
Callback that receives progress messages while the sandbox starts.
Browser-only option
SmolVM.browser() only. Use True for CDP-only browser automation. Use False to also start viewer_url and display_url.Display and artifact options
Browser or desktop screen size. You can pass
BrowserViewport(width=1440, height=900) or {"width": 1440, "height": 900}.Screen width in pixels when
viewport is omitted.Screen height in pixels when
viewport is omitted.Record the visible session. Retrieve recordings with
collect_artifacts() before the sandbox stops.Allow Chromium downloads inside the browser sandbox.
BrowserViewport
BrowserViewport is a small helper for screen dimensions.
Screen width in pixels.
Screen height in pixels.
Examples
Larger visible browser
larger_browser.py
Persistent browser profile
browser_profile.py
profile_id again when you want Chromium to reuse saved browser state.
Full desktop with a larger screen
desktop_viewport.py
Related
- Browser and desktop sandboxes - Start browser and desktop modes
- Display sandbox object - Read returned URLs and lifecycle state
