Learning resourcesReviewed · Pydantic

BoxLite Sandbox for Pydantic AI Harness

The BoxLite Sandbox guide shows Python developers how to isolate AI agent commands in local virtual machines, but using it requires compatible virtualization and explicit cleanup of saved workspaces. It documents the Pydantic AI Harness integration, network restrictions and workspace reuse across runs.

Researched 24 Nov 2026

In short.

This BoxLite Sandbox guide helps Pydantic AI developers give agents a local virtual machine for commands and file edits, but platform support is limited and saved machines need explicit cleanup. The documented integration embeds BoxLite's runtime without a daemon or cloud sandbox account, blocks VM network access by default and preserves disks for reuse. Enabling network access without an allowed_hosts restriction can expose local services and cloud metadata endpoints. The page explains setup, lifecycle management and failure behavior in detail; installation, execution, performance and security effectiveness have not been assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete documentation page at [https://pydantic.dev/docs/ai/harness/boxlite-sandbox/index.md], including its 0.x API-change warning, installation examples, configuration, security model, platform notices, lifecycle rules, telemetry and API reference. The captured source revision is sha256:566b6bb28b10705c6f1301cbee418eeb01c4b9717412bbc78f7c88d21bb0459e. Linked pages and repositories are excluded. No code or commands were executed, and compatibility, performance and security effectiveness remain unassessed.

The overview

identity

This is the documentation guide for BoxLiteSandbox and BoxLiteSandboxBackend in Pydantic AI Harness. It explains how to supply a local BoxLite micro-VM as an agent's workspace, giving commands and file operations a separate kernel and filesystem.

BoxLiteSandbox supplies the execution environment. Coder, Shell, FileSystem or custom tools provide the operations the model can request. The guide covers their composition rather than presenting a standalone coding assistant.

assessment

The guide is useful for developers who want agent commands to execute locally with a documented isolation boundary and controllable network access. Its strongest practical detail is the treatment of persistent workspaces: how to reconnect, what survives process exit, which settings apply on reconnection and who must delete saved disks.

Based on the documented design, adoption requires responsibility for host compatibility, resource allocation and workspace lifecycle. The page provides no measurements of startup time, throughput, memory overhead or isolation effectiveness, so those qualities remain unknown.

users

The main audience is Python developers building Pydantic AI agents that run shell commands, edit files or work on repositories. It also addresses developers who need to prepare a workspace before an agent starts or resume work across application runs.

Beginners get installation and small examples, but will need to understand virtual machines, container images, API credentials and cleanup. Experienced developers get configuration, backend integration, error semantics and restrictions relevant to durable execution.

capabilities

The integration supports shell execution and file operations inside a local micro-VM, configurable OCI images, per-VM CPU and memory limits, working directories and command environment variables. Optional BoxLite settings include mounted directories, published ports, disk size, execution user and credentials added to HTTPS requests for named hosts.

Workspaces can retain files between runs through message history or a stored WorkspaceRef. Developers can seed files and install packages before handing a backend to an agent. The underlying BoxLite object also exposes operations such as copying files, snapshots and stopping a VM, although those operations are not described in detail here.

Using it

requirements

Documented hosts are macOS 14 or newer on Apple silicon, and Linux on x86_64 or aarch64 with glibc 2.28 or newer. Linux requires read and write access to /dev/kvm. The page states that BoxLite wheels cover Python through 3.14; on unsupported platforms and Python 3.15, the boxlite extra installs nothing and importing the integration raises ImportError. A minimum Python version is not stated.

The backend requires an asyncio event loop; operations under Trio raise UserError. Custom images need a POSIX /bin/sh and ordinary file utilities. Images with setsid support the documented termination of a command's child processes. Minimum host CPU, RAM and free disk requirements are unknown.

mechanism

BoxLite's Python SDK embeds the runtime in the application process. The VM starts on first workspace use; Coder's repository context can trigger that use when a run starts. Tools access it through ctx.workspace. By default, no host folders are mounted, no ports are published and no host environment variables are inherited.

A follow-up can recover the workspace from message history or an application-stored reference. Stopping the process stops the VM while preserving its disk; later use boots it again. A deleted workspace raises WorkspaceUnavailableError instead of silently creating an empty replacement.

Image, CPU, memory and network settings apply when creating a VM. Reconnecting preserves those choices, including existing network access. Working directory and environment settings apply to each command.

setup

The documented installation command is pip install "pydantic-ai-harness[coder,boxlite,anthropic]"; uv add accepts the same package specification. The boxlite extra installs the embedded runtime. Coder is needed for the examples' tools, and the provider extra should match the chosen model. The Anthropic examples require ANTHROPIC_API_KEY.

Attach BoxLiteSandbox and the desired workspace tools to an Agent. The example chooses image='python:3.12-slim'. Without an image, BoxLite defaults to Alpine Linux with BusyBox but without Python, git or ripgrep. OCI images are pulled on the host on first use; pinning an image digest makes the image choice reproducible.

Ubuntu 24.04 has a documented AppArmor interaction that can prevent startup until bubblewrap and the relevant AppArmor profile are installed. The linked troubleshooting instructions are outside this page's assessed scope.

example

The quick-start example gives an Agent BoxLiteSandbox(image='python:3.12-slim') and Coder(), then asks it to write and run a script printing the first ten prime numbers. A follow-up requests the first hundred and passes result.all_messages(); the documented behavior is to reuse the VM containing the script.

An alternative stores result.workspace.ref and supplies workspace=ref later. Passing workspace='new' requests a fresh VM even when history contains an existing reference. These are documentation examples; no execution results were observed.

Assessment & evidence

limitations

Only one process at a time can use a BoxLite home directory. A competing process receives WorkspaceUnavailableError until the first exits. Passing a backend directly also requires care: BoxLiteSandbox's settings do not apply to it, and durable execution only supports references to VMs created by BoxLiteSandbox.

Completed runs leave VM disks behind. Failed runs return no result from which to retrieve a reference, so the guide recommends preparing a backend and retaining backend.ref or arranging error-hook cleanup. Cancellation before startup completes has a documented automatic-cleanup exception.

Combined command output above 10 MiB stops the command and raises WorkspaceOutputLimitError, retaining the first 65,536 characters of each output stream. Timeout and cancellation handling kills child processes when setsid is available; without it, only the command itself is killed. Background jobs can continue after their initiating command finishes.

reasoning

The documented VM boundary offers separation from host files and processes, while the runtime retains the application's OS-user permissions. Mounted folders, published ports and supplied credentials change what an agent can access. Commands commonly run as root inside the VM, allowing them to alter its contents.

Network access is disabled by default. Setting allow_internet_access=True without allowed_hosts permits connections wherever the host can reach, including local services and cloud metadata endpoints. An explicit list of required hostnames, IP addresses or CIDR ranges is therefore an important configuration choice.

Workspace references should come from application-controlled storage. Accepted name patterns do not authenticate a VM's origin, and directly constructed backends can access boxes with mounts or ports. The authority and path_authority settings govern how participating capabilities present file text to the model; the default is 'operator', while 'none' is documented for third-party files. Resistance to malicious file instructions has not been assessed.

alternatives

Within this integration, Shell plus FileSystem provides a narrower tool composition than Coder while retaining the same VM backend. Custom tools can use ctx.workspace directly, and a prepared BoxLiteSandboxBackend allows application code to control setup before the agent starts.

The page references an E2B sandbox cleanup example but supplies no substantive comparison of execution providers. Relative cost, performance, security and operational effort are unknown, so this evidence cannot establish which backend is preferable.

evidence

The source is the complete BoxLite Sandbox documentation page at [https://pydantic.dev/docs/ai/harness/boxlite-sandbox/index.md]. It contains installation instructions, examples, configuration defaults, security boundaries, platform requirements, lifecycle behavior and an API reference.

These are documentation claims. No installation, VM startup, command execution, network restriction, cleanup behavior or security boundary was tested. Linked implementation files, SDK documentation, troubleshooting guidance and other documentation pages are outside the assessed scope.

Access & freshness

costs

The page states no prices for Pydantic AI Harness, BoxLite or model providers. A cloud sandbox account is unnecessary, but that does not establish a zero-cost workflow. Model charges, any licensing fees and total operating cost are unknown.

Local VMs consume host CPU, memory and disk, and their disks persist until deletion. CPU and memory can be capped per VM, but the integration does not limit how many VMs a process creates. The page gives no measured resource consumption or storage requirements.

rights

The page links to implementation source but does not state the software or documentation licence. Commercial-use permissions, redistribution rights, attribution duties and warranty terms are not established by this evidence.

The integration, BoxLite runtime and chosen OCI images can involve separate terms. Those terms need confirmation before reuse or redistribution; source links alone do not establish permissions.

freshness

The documentation snapshot was captured on 24 November 2026 at 01:28:47.820 UTC. The page's publication date, last modification date and exact package release are unknown.

The page warns that Pydantic AI Harness 0.x APIs may change between minor releases, with deprecation warnings and migration guidance. Its platform and API statements describe this snapshot; compatibility with a particular installed release has not been assessed.

actions

Before adoption, confirm host virtualization support and Linux /dev/kvm access where applicable. Choose an image containing the required tools, pin its digest, choose the provider dependency and configure per-VM resource limits. Enable network access only with the destinations the workload needs.

Define how trusted workspace references are stored, how application processes share BoxLite storage and how saved disks are deleted after successful and failed runs. Review file authority settings for third-party repositories and avoid supplying credentials through environment variables unless agent commands may read them.

Use a disposable workspace to verify startup, required tools, network restrictions, cancellation and cleanup on the intended host. Those checks would resolve important adoption questions; no results for them are available here.

Evidence for this report

selected-page.txtselected · checked 2026-11-24