feat: add pluggable SandboxProvider for agent execution isolation
Summary
The toolkit has no execution isolation / sandboxing runtime. Consumers (like ai-native-team daemon) must build their own Docker sandboxing from scratch (~400 lines) with security hardening (no-new-privileges, cap-drop ALL, network isolation, CPU/memory limits).
Proposal
Add a pluggable SandboxProvider interface:
- SandboxProvider ABC with run(agent_id, task, config) -> SandboxResult
- DockerSandboxProvider — ephemeral containers with security defaults
- ProcessSandboxProvider — subprocess isolation (lighter weight)
- Default security posture: deny-by-default network, drop all capabilities, read-only filesystem
- Configurable: CPU/memory limits, timeout, allowed network endpoints
- SandboxResult: stdout, stderr, exit_code, duration, cost, container_id
Why This Matters
Every toolkit consumer deploying agents in production needs execution isolation. Without a standard, each consumer reimplements Docker sandboxing with varying security quality. A toolkit-native sandbox ensures consistent security posture across all deployments.
Real-World Evidence
ai-native-team daemon sandbox.py implements: ephemeral Ubuntu containers, gh CLI auth injection, /workspace mount, orphan cleanup, timeout handling, JSON result parsing. All of this should be reusable.
sandlock (github.com/multikernel/sandlock) could fit as a provider here -- it sits between DockerSandboxProvider and ProcessSandboxProvider in the isolation spectrum:
| ProcessSandbox | sandlock | DockerSandbox | |
|---|---|---|---|
| Filesystem isolation | None | Landlock (kernel-enforced) | Overlay + namespaces |
| Network isolation | None | Landlock TCP + domain allowlist | Network namespace |
| Syscall filtering | None | seccomp-bpf | seccomp |
| Resource limits | ulimit | seccomp notif (memory, CPU, forks, fds) | cgroups |
| Root required | No | No | Yes* |
| Startup | ~0ms | ~20ms | ~200ms |
| Dependencies | None | None (pure Python, ctypes) | Docker daemon |
The deny-by-default posture you described maps directly to sandlock's defaults -- no network, read-only filesystem, capabilities dropped, configurable per-execution:
from sandlock import Policy, Sandbox
policy = Policy(
fs_readable=["/usr", "/lib", "/lib64", "/etc"],
fs_writable=["/workspace"],
net_allow_hosts=["api.github.com"], # only allowed endpoint
max_memory="512M",
max_cpu=50, # 50% of one core
clean_env=True,
)
result = Sandbox(policy).run(["python3", "agent_task.py"])
# result.returncode, stdout/stderr available
No Docker daemon, no container images, no root -- useful for environments where Docker isn't available or the overhead isn't justified.
Disclaimer: I'm the sandlock author.