Running eval tool calls in a sandbox: Inspect sandbox() with Docker or gVisor
Answer: In Inspect, model tool calls are executed within the main process, but the work tools perform, such as running shell commands, very often needs a dedicated, isolated environment. Add sandbox="docker" to a task and tools call sandbox() to reach the SandboxEnvironment for the current sample.
Details
- A tool runs commands with
await sandbox().exec([...])and checksresult.success,result.stdoutandresult.stderr. - Support for Docker sandboxes is built in; an Extension API enables the creation of additional sandbox types.
- Docker sandboxes accept standard
Dockerfileandcompose.yamlconfiguration. - Compose's default network has outbound Internet access, so include
network_mode: noneunless the evaluation requires networking.
Stronger isolation
gVisor provides a Docker runtime: after sudo runsc install and a daemon restart, containers run with docker run --runtime=runsc.
See also
- ao-sandbox-firecracker-and-gvisor
- ao-evals-inspect-scorers
- ao-evals-cli-lm-eval-and-inspect
- ao-security-e2b-cloud-sandboxes
Claims
- id: C1 claim: Tool work needs an isolated environment. source: S1 evidence: "very often needs to happen in a dedicated, isolated environment"
- id: C2 claim: Docker sandboxes are built in. source: S1 evidence: "Support for Docker sandboxes is built in"
- id: C3 claim: Use network_mode none by default. source: S1 evidence: "include
network_mode: nonein your own configuration"
- id: C4 claim: runsc runs containers under gVisor. source: S2 evidence: "docker run --runtime=runsc --rm hello-world"
Sources
- [S1] Sandboxing (Inspect docs). UKGovernmentBEIS/inspect_ai (GitHub). https://github.com/UKGovernmentBEIS/inspect_ai/blob/main/docs/sandboxing.qmd . License: MIT. Accessed 2026-11-16.
- [S2] gVisor Docker quick start. google/gvisor (GitHub). https://github.com/gvisor/gvisor/blob/master/g3doc/user_guide/quick_start/docker.md . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: UKGovernmentBEIS/inspect_ai (GitHub), Sandboxing (Inspect docs), MIT (https://raw.githubusercontent.com/UKGovernmentBEIS/inspect_ai/main/LICENSE). Copyright (c) 2024 UK AI Security Institute; google/gvisor (GitHub), gVisor Docker quick start, Apache-2.0 (https://raw.githubusercontent.com/google/gvisor/master/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: UKGovernmentBEIS/inspect_ai (GitHub), Sandboxing (Inspect docs), MIT (https://raw.githubusercontent.com/UKGovernmentBEIS/inspect_ai/main/LICENSE). Copyright (c) 2024 UK AI Security Institute; google/gvisor (GitHub), gVisor Docker quick start, Apache-2.0 (https://raw.githubusercontent.com/google/gvisor/master/LICENSE).
Cite this
iinventedlight. 2026. "Running eval tool calls in a sandbox: Inspect sandbox() with Docker or gVisor." iinventedlight Library, iil:note:c2wa2res, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-sandbox-inspect-docker-tools/. License: CC-BY-4.0.
@misc{iil_note_c2wa2res,
author = {{iinventedlight}},
title = {{Running eval tool calls in a sandbox: Inspect sandbox() with Docker or gVisor}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-sandbox-inspect-docker-tools/},
note = {Permanent ID iil:note:c2wa2res. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-sandbox-inspect-docker-tools.md.