harbor-box connects the two. It is a Harbor environment adapter (BoxEnvironment) that maps Harbor’s lifecycle, command, and file operations onto the Box API, so your Harbor trials run on Box machines instead of a local Docker container, E2B, or Modal.
New to both? You only need two things to follow this guide: Python 3.12+ and a Box API key. No prior Harbor or Box experience required.
How it fits together
- Harbor owns your task/eval logic and calls an environment to do filesystem and shell work.
harbor-boxis the adapter you plug into Harbor (it imports asharbor_box_environment).- Box is the machine the work actually happens on.
Set it up
Create a Box account
Sign in at box.ascii.dev with GitHub and start the base plan, which includes a free 7-day trial. You need an account to create boxes. See the Box quickstart for the full onboarding walkthrough.
Get a Box API key
Create a key from the API keys tab of the Box dashboard. Keep it secret: store it in an environment variable, never in source control.
Install the package
harbor>=0.14.0) along with httpx and tenacity. Requires Python 3.12+.A complete example
This standalone script provisions a Box-backed environment and exercises the operations Harbor relies on: running commands, reading files, and writing files. It runs on its own so you can verify your setup before wiring the adapter into a larger Harbor run.hello_box.py
uname output, and exit code 0.
What the adapter maps
Harbor BaseEnvironment operation | Box behaviour |
|---|---|
start / stop | Creates and waits for a Box, or stops and archives it. |
exec | Executes a bounded command in the Box work directory, with optional cwd, env, user, and timeout. |
upload_file / download_file | Transfers files to and from the Box (base64 for binary). |
upload_dir / download_dir | Recursively transfers directory trees. |
ensure_dirs | Creates the configured work and mount directories. |
is_file / is_dir | Checks for paths inside the Box. |
Configuration
BoxEnvironment(...) takes Harbor’s standard arguments (environment_dir, environment_name, session_id, trial_paths, task_env_config) plus these Box-specific options:
| Option | Default | Description |
|---|---|---|
api_key | os.environ["BOX_API_KEY"] | Box API key. |
base_url | public Box API | Box API base URL. |
ttl_seconds | 86400 | Auto-stop TTL in seconds. None disables auto-stop. |
no_env | True | Create no-env boxes (strong isolation). Set False to use your account’s environment. |
request_timeout_seconds | 30 | Per-request HTTP timeout. |
client | none | A preconfigured AsyncBoxClient, if you want to supply your own. |
BOX_API_KEY is required: pass api_key=... or set the environment variable. The adapter calls preflight() and fails fast if it is missing.
Preparing the environment
Box runs a ready image; it doesn’t build Docker images. The adapter prepares each box from your Harbor environment directory instead:- Files in the environment directory are uploaded into the box’s working directory at start, so fixtures, configs, and scripts are in place before the agent runs.
- The
Dockerfileis read only for its final-stageWORKDIR; build steps (RUN/COPY/ …) are not executed; install dependencies from a setup command (await env.exec(...)) or your agent. - Environment variables come from the Harbor environment config and are forwarded into the box; per-command env is passed through
exec.
Isolation
Boxes are created no-env by default: a trial gets none of your Box account’s secrets, credentials, or cloned private repos, and can’t act on your account or other boxes. This is the right default for evals and for boxes you hand to others. Passno_env=False to use your account’s environment instead, configured in the Box dashboard’s Secrets and Repositories tabs. See Secrets & Setup.
Not available on Box
Some Harbor features don’t map to Box today and raise a clear error: network policies (no-network / allow-lists), Docker image builds / Compose, and GPUs / TPUs / Windows. Run those tasks on a backend that supports them.Resources
PyPI package
harbor-box on PyPI.Source on GitHub
Issues, evals, and the adapter source.
Box quickstart
Install Box and create your first sandbox.
Box API keys
Create and manage the key this adapter needs.