In short.
This guide explains Linux sandboxing for developers running Pydantic AI agent commands, but its protections do not fully isolate a deliberately harmful agent from the host account. BubblewrapSandbox wraps a workspace locally or over SSH, making host files read-only while leaving the working directory writable, providing private temporary storage and disabling network access by default. File tools use the same sandbox. The documented limits include readable credentials, shared processes, persistent background jobs and files that may execute outside the sandbox later. Nothing was executed; enforcement, compatibility and performance were not 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/bubblewrap-sandbox/index.md], including its installation instructions, examples, security explanations, telemetry, API reference and 0.x version-policy notice. Linked pages, repository files, the external diagram image, license texts and provider documentation are excluded. No separate library files were supplied. Nothing was executed; installation success, sandbox enforcement, platform compatibility, performance, cleanup and example outcomes remain unverified.
The overview
Identity
The resource is the Bubblewrap Sandbox documentation page for Pydantic AI Harness at [https://pydantic.dev/docs/ai/harness/bubblewrap-sandbox/index.md]. It explains a Python integration that runs workspace commands through the Linux bubblewrap executable, bwrap.
BubblewrapSandbox wraps an agent workspace capability. BubblewrapWorkspace exposes the underlying workspace wrapper for direct use. Both run the sandbox on the wrapped workspace's host, including a remote SSH host.
Assessment
The guide is useful for developers who want agent commands and file tools to write within a project directory while keeping the surrounding host filesystem read-only. Its practical value is the combination of setup instructions, API parameters and unusually explicit explanations of what remains accessible.
The documented protection is limited: commands retain access to readable host files and the host user's processes. Suitability therefore depends on the account, working directory and trust placed in the agent. The page supplies no independent security evaluation, benchmark or execution results.
Users
The main audience is Python developers integrating Pydantic AI agents with shell, coding or filesystem tools on a Linux workstation or SSH-accessible development host. Beginners need familiarity with package installation, project directories and, for remote use, SSH.
Experienced developers can use the lower-level workspace interface and custom mount arguments. Teams expecting protection from a hostile agent must account for the documented file-reading and process-control limits; the page recommends a separate host user or a cloud sandbox for agents they do not trust.
Capabilities
By default, commands receive a read-only view of host files, a writable working directory, private /tmp storage, an empty /run and no network access. File operations such as write_text also run through the sandbox, including those exposed by Coder and FileSystem tools.
The network parameter enables host networking. Extra bwrap_args can expose additional writable directories or hide paths. BubblewrapWorkspace also supports direct command execution without an agent.
BubblewrapSandbox emits no telemetry spans of its own. The documentation says existing instrumentation records the wrapped workspace's provider and identifier, with sandboxed commands inside their tool-call spans.
Using it
Requirements
The sandbox host must run Linux, have bwrap installed and permit user namespaces. Otherwise commands raise WorkspaceUnavailableError. The documented seccomp filter supports x86_64 and aarch64; a 32-bit program is stopped when it makes a system call.
The wrapped backend must run commands without a controlling terminal. The page says the Local, SSH, E2B and Modal backends satisfy this requirement; custom backends must satisfy it too.
Socket-dependent workloads need special attention. Local test servers cannot operate under the default socket restrictions. The page also identifies Python multiprocessing's forkserver mode as incompatible with those restrictions, while spawn and fork can work without enabling networking. Minimum supported Python and package versions are not specified here.
Mechanism
The wrapped workspace launches bwrap on its own host. Filesystem mounts restrict writes, while the sandbox receives its own user namespace and no capabilities. Without networking, a seccomp filter blocks socket connections, listening and acceptance, including Unix sockets and loopback, and also blocks ptrace and io_uring. Stream socket pairs remain available.
Setting network=True shares the host network, including loopback services and listening ports, restores relevant DNS configuration under /run and removes the seccomp filter entirely. Extra bwrap_args follow the defaults and can override protections.
File methods execute as sandboxed shell commands, so the documented write boundary also applies when a symlink changes after a path check. A read-only wrapped workspace instead reads files directly from the host because it runs no commands. The wrapper retains the underlying workspace reference and backend; its durable policy includes network and bwrap_args.
Setup
The documented installation commands are pip install "pydantic-ai-harness[coder,anthropic]" or uv add "pydantic-ai-harness[coder,anthropic]". The coder extra supports the examples' Coder tools; the sandbox itself does not require it. The anthropic extra serves the example model provider and can be replaced with the relevant provider extra.
Install the Linux bubblewrap package on the host where commands will run. Wrap SSHWorkspace with BubblewrapSandbox for remote execution, or LocalWorkspace for local execution, and use a project directory as working_dir.
Before adapting the setup, decide whether networking is necessary and whether sensitive directories should be hidden with bwrap_args. The page documents those options but provides no installation or configuration verification results.
Example
The agent example connects to dev@build-box with /srv/app as its working directory, wraps SSHWorkspace in BubblewrapSandbox, adds Coder and asks the agent to run the test suite and fix the first failure. It illustrates the intended integration; it does not demonstrate that tests passed or a repair succeeded.
The direct-use example constructs BubblewrapWorkspace around Workspace(SSHWorkspaceBackend('dev@build-box')) and awaits workspace.run(['make', 'test']), returning a CommandResult. That example omits an explicit project directory, so the page's separate recommendation to choose a project working directory matters when adapting it. Neither example was executed for this report.
Assessment & evidence
Limitations
Commands can read files accessible to the host account, potentially including credentials, and expose their contents to the model. They can see host processes and command lines and signal the user's other processes. Per-call environment values appear in bwrap command-line arguments while the command runs.
Files written inside the project, including Git hooks, Makefiles and .envrc files, may execute without sandbox restrictions when used outside it later. If the working directory includes the home directory, some SSH and command-login startup files receive read-only mounts, but interactive-login files and other user configuration can remain writable. Those mounts can also be overridden by bwrap_args.
Background jobs may outlive tool calls and agent runs. Timeout cleanup depends on the backend: SSH cleanup is best effort when the host is unreachable, E2B and Modal descendant cleanup depends on setsid, and jobs detached into their own session can survive on every backend. The workspace settings and host bwrap executable remain trusted.
Reasoning
The documented design supports restricting where agent tools write, while applying the same restrictions to command and file interfaces. That makes it relevant to project maintenance tasks where accidental writes outside the project are a concern.
The shared account and process access imply a narrower security boundary than a separate execution environment. Enabling networking broadens access further and removes the syscall filter. These suitability conclusions follow from the documented design; actual enforcement and resistance to attack were not assessed.
Alternatives
For an agent the developer does not trust, the page recommends assigning it its own host user or using a cloud sandbox such as E2B. It provides no comparative evidence about their security guarantees, setup effort or prices.
LocalWorkspace and SSHWorkspace offer different locations for the same Bubblewrap wrapper. BubblewrapWorkspace offers direct workspace access instead of the agent capability interface. The linked alternatives' documentation and implementations were not assessed.
Evidence
The evidence is the complete first-party documentation page at [https://pydantic.dev/docs/ai/harness/bubblewrap-sandbox/index.md], captured on 2026-11-15 at 11:27:30.274 UTC. It includes installation instructions, usage examples, security limitations, telemetry behavior and API reference material.
The captured source revision is sha256:1104aa396b503d30e5979b2d8c5a19bc0f3c8ab6e29b1ed188c6d335fe83c91f. This identifies the document snapshot, not a software release. Linked repository contents, external documentation and the diagram image itself were not inspected. No software was installed, executed or tested.
Access & freshness
Costs
The page provides no prices for the integration, model calls, hosting or cloud alternatives. It supplies no measurements of CPU, memory, startup overhead or operating cost.
The examples use a host and a model provider, whose charges, if any, are unspecified. Total cost is unknown; the absence of pricing on this page does not establish that the setup is free.
Rights
The page links to source code at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/bubblewrap_sandbox/], but the supplied evidence contains no license text.
License terms for the documentation, examples, harness package and bubblewrap cannot be established from this page. Permissions for redistribution or adaptation remain unknown.
Freshness
The capture establishes what the page contained on 2026-11-15. It supplies no publication date, last-update date or exact package version, so release recency and compatibility with a particular installation are unknown.
The page warns that Pydantic AI Harness APIs may change between minor releases while on 0.x, with deprecation warnings and migration guidance accompanying changes. The linked version policy and release notes are outside the supplied evidence.
Actions
Confirm Linux, bwrap availability, user-namespace support and a backend without a controlling terminal. Choose an explicit project working directory and identify readable credentials or configuration that should be hidden.
Check whether the intended tests need sockets or multiprocessing forkserver before choosing network=True, since that setting shares host networking and removes the seccomp filter. Decide how background jobs will be stopped and how generated project files will be reviewed before later execution outside the sandbox.
Before deployment, verify package-version compatibility and applicable licenses, and validate filesystem, network and cleanup behavior in the intended environment. Those checks remain unperformed; their outcomes and operating costs are unknown.
