Install the extension
0.2.0 requires Python 3.10 or newer, Harnest >=0.14,<0.15, and docker>=7.1,<8. The host must provide a reachable Docker daemon.
Declare a Docker sandbox
Createsandbox/python.py. The exported variable must match the filename:
sandbox/python.py
"python" to each consuming agent’s sandboxes=[...] grant. Call it from an authored tool through context.sandboxes["python"]. Exactly one of image or docker_path is required; prefer an immutable image digest in deployments.
Choose a reuse scope
Retained scopes reuse the container and its
/tmp scratch files while that identity remains cached, but not live processes or durable storage. Every successful call stops remaining processes. max_scopes defaults to 8 and evicts the least recently used retained container before admitting another identity.
Set network authority
The extension supportsSandboxNetworkPolicy.none() and SandboxNetworkPolicy.unrestricted(block_private_networks=False). No-network mode is the default. Exact host or port allowlists, and unrestricted networking with private-network blocking, fail closed because this provider does not yet enforce those controls at Docker’s network boundary.
Network policy is provider-enforced authority. Validating a URL in an Agent Tool does not replace it. Use another sandbox provider when a workload requires exact destination enforcement.
Understand deadlines and cleanup
The all-in deadline covers queue admission, image and container startup, and execution. SDK transport timeouts for image preparation and container creation are constrained by the remaining deadline; a host watchdog and control checks bound execution. Output is bounded while streaming; timeout, cancellation, overflow, and failed startup poison the container instead of returning it to a reuse pool. Cleanup receives a separate bounded five-second window. The provider retains ownership and blocks replacement when termination is uncertain. Startup errors identify the failed phase without exposing raw SDK details. Managed containers carrydev.harnest.* labels for operator inventory.
Security boundary
Docker daemon access is highly privileged. Protect its socket or remote API, restrict who can configure this extension, and use trusted digest-pinned images. Containers run as a non-root user with a read-only root filesystem, dropped capabilities,no-new-privileges, bounded /tmp, and no host mounts. Docker still shares the host kernel; choose a stronger provider for higher-risk isolation.
The extension does not transfer input or output files. Use stdout or a provider with an explicit file contract. See Sandboxing for agent grants, authored-tool usage, custom providers, and failure handling.