Quicksand (GitHub Repo)

TLDR AI Tools

Summary

微软开源 Quicksand,一个用于启动、控制和快照 QEMU 虚拟机的异步 Python API,专注于为 AI 智能体提供沙箱环境,无需 root 权限或 Docker 即可运行。

Quicksand is an async Python API for launching, controlling, and snapshotting QEMU virtual machines with a particular focus on sandboxing AI agents. It provides pre-built Linux VMs for Ubuntu and Alpine distros. Quicksand supports x86_64 and ARM64 across macOS, Linux, and Windows. The sandboxes do not need root privileges or Docker.
Original Article
View Cached Full Text

Cached at: 10/09/26, 06:22 PM

microsoft/quicksand

Source: https://github.com/microsoft/quicksand

Quicksand

PyPI Changelog Docs License: MIT

Quicksand

Quicksand is an async Python API to launch, control, and snapshot QEMU virtual machines with a particular focus on sandboxing AI agents. Quicksand provides pre-built Linux VMs for Ubuntu and Alpine distros and supports x86_64 and ARM64 across macOS, Linux, and Windows. Running sandboxes needs no root privileges or Docker; install the QEMU and image extras for a bundled runtime on supported platforms.

Installation

pip install 'quick-sandbox[qemu,alpine]'

Or install the core package and add QEMU/images separately:

pip install quick-sandbox
quicksand install qemu alpine

Usage

Hello, World!

import asyncio
from quicksand import Sandbox

async def main():
    async with Sandbox(image="ubuntu") as sb:
        result = await sb.execute("echo 'Hello from the sandbox!'")
        print(result.stdout)

asyncio.run(main())

Run commands

result = await sb.execute("apt update && apt install -y python3")
print(result.stdout, result.exit_code)

Mount host directories

Share host directories into the VM at boot or on the fly.

# At boot
async with Sandbox(
    image="ubuntu",
    mounts=[Mount("./workspace", "/mnt/workspace")],
) as sb:
    ...

# Or dynamically on a running sandbox
handle = await sb.mount("/tmp/data", "/mnt/data")
await sb.execute("ls /mnt/data")
await sb.unmount(handle)

Configure networking

Sandboxes are network-isolated by default. Opt in to internet access and port forwarding with NetworkMode.FULL.

async with Sandbox(
    image="ubuntu",
    network_mode=NetworkMode.FULL,
    port_forwards=[PortForward(host=8080, guest=80)],
) as sb:
    ...

Multiple Linux users

Give multiple agents independent Linux user accounts in a single sandbox VM.

async with Sandbox(image="ubuntu") as sb:
    alice = await sb.create_user("alice")
    bob = await sb.create_user("bob")

    await alice.execute("cat > hello.txt", stdin="Hello from Alice!\n")
    await bob.execute("cat > hello.txt", stdin="Hello from Bob!\n")

    for user in (alice, bob):
        result = await user.execute("whoami && pwd && cat hello.txt")
        print(result.stdout)
        await sb.delete_user(user.name)

Save and load

Save the VM’s disk state to a directory. Load it later, even on a different machine.

await sb.execute("pip install numpy pandas")
await sb.save("my-env")  # VM keeps running

# Load later
async with Sandbox(image="my-env") as sb:
    await sb.execute("python3 -c 'import numpy; print(numpy.__version__)'")

Checkpoint and revert

Capture the full VM state and roll back if something goes wrong.

await sb.checkpoint("before-experiment")
await sb.execute("apt install -y something-risky")
await sb.revert("before-experiment")  # the VM snaps back to the checkpoint

Control a desktop

Desktop images provide a full Xfce4 graphical environment with a browser. Install one with quicksand install ubuntu-desktop or quicksand install alpine-desktop.

async with Sandbox(image="ubuntu-desktop", enable_display=True) as sb:
    await sb.screenshot("screen.png")
    await sb.type_text("hello world")
    await sb.press_key(Key.RET)
    await sb.mouse_move(500, 300)
    await sb.mouse_click("left")

Configuration

Here are all of the Sandbox configuration options:

Sandbox(
    # Image or save name to boot
    image="ubuntu",
    # Guest RAM (default: "512M")
    memory="2G",
    # Virtual CPU cores (default: 1)
    cpus=4,
    # Host directories shared into the VM at boot
    mounts=[Mount("/host", "/guest")],
    # NONE, MOUNTS_ONLY (default), or FULL internet access
    network_mode=NetworkMode.FULL,
    # Forward host TCP ports into the guest
    port_forwards=[PortForward(host=8080, guest=80)],
    # Expand the guest filesystem on boot
    disk_size="10G",
    # Attach virtual GPU, keyboard, and mouse for screenshot/type_text/mouse control
    enable_display=True,
    # Auto-save VM state on stop
    save="my-save-name",
)

Available images

ImageTypeWheel sizeInstall commandWhat is it
ubuntuBase~309-357 MBquicksand install ubuntuUbuntu 24.04 headless
alpineBase~82-85 MBquicksand install alpineAlpine 3.23 headless (faster boot)
ubuntu-desktopOverlay (ubuntu)~273-281 MBquicksand install ubuntu-desktopUbuntu 24.04 + Xfce4 + Firefox
alpine-desktopOverlay (alpine)~346-363 MBquicksand install alpine-desktopAlpine 3.23 + Xfce4 + Chromium
quicksand-agentOverlay (ubuntu)~306-335 MBquicksand install quicksand-agentUbuntu + Python 3.12, uv, build-essential, requests, pyyaml, ddgs, markitdown
quicksand-cuaOverlay (quicksand-agent)~489-500 MBquicksand install quicksand-cuaAgent Sandbox + Xvfb, x11vnc, noVNC, Playwright, Chromium

Sizes are approximate full image-wheel downloads for the September 14, 2026 releases and vary by architecture. Overlay sizes exclude their base images.

Building from source

git clone https://github.com/microsoft/quicksand.git
cd quicksand
uv sync
uv run uvr build --all-packages

Documentation

TopicGuideUnder the Hood
InstallationInstalling packagesQEMU binaries, kernels, qcow2 disks
Sandbox LifecycleCreating and configuring sandboxes-m, -smp, -accel, machine types
Running Commandsexecute(), streaming, exit codesKernel boot, agent tokens, hostfwd
File ExchangeMounts, hot-mounts, getting data in/outCIFS via guestfwd, 9p via -fsdev
Save and RollbackCheckpoints, reverts, persistent savesqcow2 overlays, savevm, blockdev-snapshot-sync
Desktop ControlScreenshots, keyboard, mouseVNC, GPU, USB tablet, QMP input injection
Network and IsolationNetwork modes, port forwardingSLIRP NAT, restrict=on, guestfwd
PerformanceWhat makes it fastio_uring, IOThreads, TCG vs KVM

Contributing

GuideWhen to use
Creating ImagesBuild a new base or overlay image package
Extending the SandboxAdd a method, OS, architecture, or QEMU flag
TestingRun or write tests
ReleasingCut a release

Full guides: User Guide | Under the Hood | Contributor Guide

Similar Articles

@nash_su: Last night I was chatting with @i5ting about how a sandbox is an indispensable part of any agent, and today Tencent open-sourced Cube Sandbox: 1. Blazing-fast boot (<60 ms) thanks to snapshot cloning and warm resource pools 2. Hardware-grade security via KVM micro-VMs + eBPF network isolation, battle-tested on Tencent Cloud 3. Ultra-high density—runs in <5 MB RAM, thousands per node 4. E2B-compatible

X AI KOLs Timeline

Tencent open-sources Cube Sandbox, a KVM-based micro-VM for agents that boots in <60 ms, runs in <5 MB RAM, and is E2B-compatible.

TencentCloud/CubeSandbox

GitHub Trending (daily)

TencentCloud's CubeSandbox is an open-source, high-performance secure sandbox service for AI agents, built on RustVMM and KVM, offering hardware-level isolation, sub-60ms startup, and compatibility with the E2B SDK.

@NFTCPS: App Sandbox is quite something — free and open-source, runs Win11, Ubuntu, macOS VMs on Windows 11 Home without needing Hyper-V, with GPU acceleration. The coolest part is it has a headless API plus Python S…

X AI KOLs Timeline

App Sandbox is a free and open-source virtual machine management tool that supports running Windows, Ubuntu, and macOS virtual machines on Windows 11 Home without Hyper-V. It features GPU acceleration and a headless API/Python SDK for programmable batch VM management, making it suitable for automation scenarios like AI agents.