Skip to main content

inspect-groundbox-sandbox

Groundbox sandboxes for Inspect AI: sandbox="groundbox" gives every sample its own Linux VM (a Firecracker microVM with dedicated cores), started in about a second. It is an Inspect sandbox extension, built like the Daytona, E2B and Modal sandboxes in inspect_sandboxes.

Install

pip install inspect-groundbox-sandbox
export GROUNDBOX_API_KEY=gbx_...   # https://app.groundbox.dev/keys

Installing the package registers the groundbox sandbox with Inspect through Inspect's extension entry point; there is nothing to import.

Use it

from inspect_ai import Task, task
from inspect_ai.agent import react
from inspect_ai.dataset import Sample
from inspect_ai.scorer import includes
from inspect_ai.tool import bash, python


@task
def ctf() -> Task:
    return Task(
        dataset=[Sample(input="Find the flag in /challenge.", target="flag{...}")],
        solver=react(tools=[bash(timeout=180), python(timeout=180)]),
        scorer=includes(),
        sandbox="groundbox",
    )
inspect eval ctf.py --model anthropic/claude-sonnet-4-5

With no config, a sample runs on Groundbox's own image: Ubuntu 24.04 with Docker, Node, Python, Go, Rust and Java, where commands run as runner (who has sudo) in /home/runner.

Configure it

Pass a GroundboxSandboxEnvironmentConfig (or a dict of its fields), a Dockerfile or a compose file:

from inspect_groundbox_sandbox import GroundboxSandboxEnvironmentConfig

sandbox=("groundbox", GroundboxSandboxEnvironmentConfig(
    image="python:3.12-slim",      # any public image, or one in your Groundbox registry
    cpus=4, memory_gb=8,
    allow_hosts=["pypi.org", "files.pythonhosted.org"],   # [] blocks all egress
    timeout_minutes=120,
))

sandbox=("groundbox", "Dockerfile")      # built once into a Groundbox template
sandbox=("groundbox", "compose.yaml")    # one service; see below
Field What it does
image Start from a Docker image. Commands run as root.
template Start from a Groundbox template (name, name:version or tpl_...).
dockerfile A Dockerfile, built once into a template named by its content.
snapshot_id Start from a kept Groundbox snapshot (memory, disk and processes).
cpus, memory_gb, disk_gb Size: 1 to 16 vCPUs, up to 4 GB per vCPU. Default 2 vCPU, 4 GB, 20 GB.
timeout_minutes How long a sandbox may live. Default 60.
flex Half price; starts when a machine has spare room, so it may queue.
env Environment variables for every command.
allow_hosts, deny_hosts Egress allowlist or deny list (names, *.wildcards, IPv4, CIDR).
secrets, env_from_secrets Groundbox team secrets as environment variables.
user, working_dir Who exec() runs as, and where, when the call does not say.
ports Ports connection() gives an HTTPS preview URL (paid plan).
metadata Extra metadata pairs on each sandbox.

Compose files

A compose file with one service maps onto one sandbox:

  • image starts from that image; build builds the Dockerfile into a template.
  • environment, user, working_dir, cpus / mem_limit / deploy.resources carry over.
  • network_mode: none becomes allow_hosts: []: no egress, and no DNS.
  • ports become previews in connection().
  • An x-groundbox: block (top level or on the service) takes any config field above and wins.
services:
  default:
    build: .
    network_mode: none
x-groundbox:
  cpus: 4
  timeout_minutes: 120

How it behaves

  • exec() runs through Groundbox's exec API: argv with no shell, stdin, env, cwd, timeout. A timeout raises TimeoutError and kills the command and its children.
  • exec(user=...) and the files' user= switch users with runuser, sudo or su, each launched by absolute path. Sandboxes from Groundbox's image use sudo; Debian or Ubuntu images use runuser; Alpine uses su. An image with none of them can only run as its default user (SandboxUserUnsupportedError otherwise).
  • read_file() and write_file() act as the default user (or the one given), so file permissions hold and new files belong to that user. Files above 1 MB move through Groundbox's files API, in 16 MB parts.
  • A Dockerfile's final USER and WORKDIR are applied, as Docker would (Groundbox itself runs template commands as root in /root).
  • connection() gives groundbox sandbox shell <id> (the CLI).
  • Each sandbox carries metadata created_by=inspect-ai, inspect_run_id, task and name. task_cleanup deletes this run's sandboxes, including any whose create answer was lost.
  • A team at its sandbox limit (429) waits and retries, up to INSPECT_GROUNDBOX_START_TIMEOUT seconds (default 1800). Use --max-sandboxes to stay under your team's limit.
  • Inspect's injected sandbox tools (used by bash_session, text_editor and exec_remote) install and run; the live tests check exec_remote on Groundbox's image.

Cleanup by hand:

inspect sandbox cleanup groundbox            # every live sandbox Inspect made
inspect sandbox cleanup groundbox sbx_...    # one

inspect eval --no-sandbox-cleanup keeps them and prints their ids; open one with groundbox sandbox shell sbx_....

Limits

  • Multi-service compose is not supported yet. A compose file must have one service. (Daytona, E2B and Modal run several services with Docker inside one sandbox; Groundbox's image has Docker, so this can come later.)
  • Dockerfiles build with no build context: COPY and ADD of local files fail. Push the image to a registry and use image, or write the files with Sample.files.
  • A single exec() runs for at most 60 minutes.
  • Groundbox keeps the last 4 MB of each output stream of a command; the beginning of longer output is dropped (Inspect allows this; write large output to a file and read_file() it).
  • For image, the image's own USER and WORKDIR are not applied (commands run as root in /root); set user and working_dir.
  • Private images on other registries are not supported; push them to the Groundbox registry.
  • Templates, previews, stop/start and volumes are on the paid plan. The free trial runs 2 sandboxes at a time, for up to 60 minutes each.
  • A team keeps up to 20 templates; each distinct Dockerfile (and size) makes one named inspect-<hash>. Delete old ones with groundbox templates rm.

Settings

Variable Default
GROUNDBOX_API_KEY Required.
GROUNDBOX_API_URL https://api.groundbox.dev/v1
INSPECT_GROUNDBOX_START_TIMEOUT 1800 Seconds a sample waits for its sandbox to start.
INSPECT_GROUNDBOX_THREADS 256 Worker threads for Groundbox calls (the SDK is synchronous).

Tests

pip install -e ".[dev]"
pytest                                   # unit tests, with a fake client
GROUNDBOX_API_KEY=gbx_... pytest -m live # Inspect's sandbox conformance checks and evals, on real sandboxes

tests/test_live_self_check.py runs Inspect's own portable sandbox checks (inspect_ai.util._sandbox.self_check) on Groundbox's image and on python:3.12-slim. examples/hello_groundbox.py has two evals that need no LLM key:

inspect eval examples/hello_groundbox.py --model mockllm/model

License

MIT. See LICENSE.

Metadata

Release files for inspect-groundbox-sandbox 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inspect-groundbox-sandbox 0.1.0
File Size Uploaded Provenance Actions
inspect_groundbox_sandbox-0.1.0.tar.gz 27.4 kB Without provenance Details for inspect_groundbox_sandbox-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inspect-groundbox-sandbox 0.1.0
File Interpreter ABI Platform Actions
inspect_groundbox_sandbox-0.1.0-py3-none-any.whl Python 3 none any Details for inspect_groundbox_sandbox-0.1.0-py3-none-any.whl

Total release size: 49.4 kB

Release files / inspect_groundbox_sandbox-0.1.0.tar.gz

Download URL inspect_groundbox_sandbox-0.1.0.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
52a84dbe67f9c3145019cd7cefc0facd14b32cfff6f872381888b03fde48a318
BLAKE2b-256 checksum
How to use checksums
50d31d3d93a9a9e86dcbda2e4ea13e4f8136ca81bdf3e29cb8552b9031c78590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / inspect_groundbox_sandbox-0.1.0-py3-none-any.whl

Download URL inspect_groundbox_sandbox-0.1.0-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b57af5a7b39fb5e06db750d9e357e792c574ef2ddca84c670b87a018c06c893a
BLAKE2b-256 checksum
How to use checksums
a672ccebc6f7db4f4b84c7a62c0fae4b703c0ef06b3ec330f2562f7b4b661ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for inspect-groundbox-sandbox 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page