Skip to content

Index

diapason.sandbox

Container sandbox for isolated agent execution.

AllowedRoot dataclass

An allowed mount root with optional read-only constraint.

ContainerRunner

Manages Docker container lifecycle for sandboxed execution.

Parameters

image: Docker image to run. Defaults to diapason-sandbox:latest. timeout: Maximum execution time in seconds. mount_allowlist_path: Path to a JSON mount-allowlist file. max_concurrent: Maximum number of concurrent containers. runtime: Container runtime binary name (docker or podman).

cleanup_orphans()

Remove orphaned sandbox containers.

run(input_data, *, workspace='', mounts=None, secrets=None, env=None)

Spawn a container, send input, parse output.

Parameters

input_data: JSON-serializable payload sent to the container's stdin. workspace: Working directory inside the container. mounts: Host paths to bind-mount (read-only). secrets: Key-value pairs injected into input (not env vars). env: Environment variables for the container.

Returns

dict Parsed JSON output from the container.

stop(container_name)

Force-stop a running container.

MountAllowlist dataclass

Allowlist for container mounts.

SandboxedAgent

Bases: BaseAgent

Transparent wrapper that runs any BaseAgent in a container.

Follows the GuardrailsEngine wrapper pattern — the wrapped agent's configuration is serialized and sent to the container.

run(input, context=None, **kwargs)

Delegate execution to the container runner.

validate_mount(mount_path, allowlist)

Validate a single mount path against the allowlist.

Returns True if the mount is allowed, False otherwise.

validate_mounts(mounts, allowlist)

Validate a list of mount paths. Returns only valid mounts.

Raises :class:ValueError for any blocked mount.