boxed

module
v0.3.0-paper Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT

README ΒΆ

Boxed Logo

Boxed

A self-hosted code execution substrate for AI agents. Ephemeral Docker sandboxes with a streaming in-sandbox agent, behind a driver interface designed to admit other isolation backends.

Go Rust TypeScript Python License


The Story πŸ“–

Building an AI Agent that writes code? You have a problem.

  • Run it locally? 🚨 Security Risk. One rm -rf / and your laptop is gone.
  • Run it in cloud? πŸ’Έ Expensive. AWS instances for every user?
  • Use SaaS sandbox? 🐌 Vendor Lock-in. High latency and data privacy concerns.

Meet Boxed. The open-source, sovereign engine that gives your Agents a safe place to play. It provides a unified API to spawn ephemeral sandboxes, execute arbitrary code, and retrieve results instantly.


✨ Features

  • πŸ”’ Backend behind an interface β€” one Driver interface; the Docker driver is the only implementation. Set BOXED_DOCKER_RUNTIME=runsc (gVisor) or =kata to swap the OCI runtime under it; the paper measures all three on one host. No Firecracker or Wasm driver exists yet.
  • πŸ›‘οΈ Bring-Your-Own-Key auth β€” operator-chosen API key via X-Boxed-API-Key. No vendor accounts.
  • ⚑ Fast lifecycle β€” create+exec+destroy measured against raw Docker on the same host; numbers and CIs in the paper and bench/results/.
  • πŸ“ First-class artifacts β€” in-VM Rust agent streams stdout, stderr, and emitted files (images, PDFs, datasets) over JSON-RPC.
  • πŸ”Œ Polyglot SDKs β€” first-class support for TypeScript and Python.
  • 🌐 Network fail-closed β€” every sandbox runs with Docker's none network; requests that enable networking are rejected until a per-sandbox egress policy exists.

Scoping: the Docker driver sets a read-only root filesystem, CapDrop: ALL, no-new-privileges, PidsLimit 256, a memory cgroup (default 512 MiB), a CPU quota, tmpfs for /tmp, /output, and the workdir, and network none. It uses Docker's default seccomp profile; a custom profile and a per-sandbox egress policy are not implemented. A twelve-vector escape probe with post-condition checks (bench/security/escapes.sh) and its results are in the paper and bench/results/. Docker shares the host kernel: this is configuration hardening, not a virtualization boundary.


πŸš€ Getting Started

πŸ“‹ Prerequisites

To run Boxed locally, you'll need:

  • Go 1.22+ (for the Control Plane)
  • Rust 1.75+ (for the Agent)
  • Docker Desktop (running and accessible)
  • Standard Images: Ensure you have a base image like python:3.10-slim pulled:
    docker pull python:3.10-slim
    

[!NOTE] First Run: The first sandbox creation may take a few seconds while Docker pulls the required images. Subsequent runs are near-instant.


πŸ—οΈ Local Development

We provide a Makefile to simplify the build process.

# 1. Clone the repository
git clone https://github.com/akshayaggarwal99/boxed.git
cd boxed

# 2. Build everything (Agent + CLI)
make build

# 3. Start the Control Plane with Auth
export BOXED_API_KEY="super-secret-key"
./bin/boxed serve --api-key $BOXED_API_KEY

# Cleanup build artifacts
make clean
πŸ” Security & Auth

Boxed uses a Bring Your Own Key (BYOK) model. Since you run your own instance, you define the secret key yourself at startup.

You can set the key via the --api-key flag or BOXED_API_KEY environment variable:

All CLI commands and SDKs must provide this key:

./bin/boxed list --api-key $BOXED_API_KEY

πŸ’» CLI Usage
# Run interactive REPL (Sticky Session)
./bin/boxed repl <sandbox-id> --lang python

πŸ”Œ SDKs
TypeScript
# Local install
npm install ./sdk/typescript
Python
# Local install
pip install -e ./sdk/python

πŸ’» SDK Examples
Python
from boxed_sdk import Boxed

client = Boxed(base_url="http://localhost:8080", api_key="super-secret-key")

# Create a secure session
session = client.create_session(template="python:3.10-slim")

# Run unsafe code
result = session.run("print('hello from boxed')")
print(result.stdout)

# Cleanup
session.close()

πŸ“š Documentation


πŸ“„ Paper

A preprint describing Boxed's design and an open benchmark harness is available in this repo:

Every performance number in the paper expands from a LaTeX macro in paper-v2/tables/numbers.tex, which is generated by bench/analyze/stats.py from those CSVs β€” the prose cannot drift from the data.

paper/ holds the superseded v1 draft. It states that the in-sandbox agent runs as PID 1 and that large artifacts are handed back via a pre-signed URL; neither is true of the implementation. Both are corrected in v2. Read v2.

Headline numbers (MacBook Pro M1 Pro, 16 GB, macOS, Docker Desktop; n=200 cold-start trials):

Metric Value
Median create+exec+destroy 303 ms
p95 / p99 395 ms / 495 ms
Peak throughput 9.8 sandboxes/s
Idle agent RSS (median) 0.4 MiB
Behavioural escape probe 5/12 denied
HumanEval-style agent trace 20/20 passed

To reproduce:

cd bench && make all   # requires `boxed serve` running and BOXED_API_KEY set
Cite
@misc{boxed2026,
  title  = {Boxed: A Sovereign, Polyglot Sandbox Substrate for Autonomous Code-Generating Agents},
  author = {Kumar, Akshay},
  year   = {2026},
  howpublished = {\url{https://github.com/akshayaggarwal99/boxed/blob/main/paper-v2/Boxed-IEEE.pdf}}
}

πŸ› οΈ Architecture

Boxed uses a Control Plane vs Data Plane architecture.

Architecture Diagram

  • Control Plane (Go): REST API + WebSocket gateway with BYOK API-key auth (Echo, ~2.8k LOC, 12 MiB binary).
  • Agent (Rust): Lightweight 1.32 MiB stripped binary injected into every sandbox; streams stdout/stderr/artifacts over JSON-RPC.

πŸ—ΊοΈ Roadmap

  • Docker driver + Go control plane + Rust in-VM agent
  • Polyglot SDKs (TypeScript, Python)
  • Sticky sessions (REPL mode, WebSocket proxy)
  • API-key auth (Bring-Your-Own-Key)
  • Hardening β€” ReadonlyRootfs, CapDrop: ALL, no-new-privileges, PidsLimit, network none
  • Custom seccomp profile and fine-grained egress allow-lists
  • Firecracker driver β€” MicroVMs for stronger isolation
  • Wasm driver β€” sub-millisecond cold start for compatible workloads
  • Pool-based reuse β€” warm sandboxes for sub-millisecond exec (see paper Β§6)
  • Multi-host scheduler

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide.

πŸ“„ License

MIT License β€” do whatever you want with it.

Directories ΒΆ

Path Synopsis
cmd
boxed command
boxed-server command
Package main is the entry point for the Boxed Control Plane server.
Package main is the entry point for the Boxed Control Plane server.
internal
api
cli
driver
Package driver defines the abstraction layer for sandbox backends.
Package driver defines the abstraction layer for sandbox backends.
proto
Package proto defines the JSON-RPC message types for Control Plane <-> Agent communication.
Package proto defines the JSON-RPC message types for Control Plane <-> Agent communication.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL