Sandboxes
A sandbox runs an agent's programs and Harbor trials away from the Reef host. Program executors are local (no isolation), sandbox (bubblewrap on Linux, Seatbelt on macOS), e2b and modal. Harbor runs trials in Docker, E2B or Modal.
What you implement #
Trial observer #
-
Hook: TrialObserver.observe(trial).
-
Called by: the evaluation service, after each attempt of a rollout, before it removes the trial directory.
-
Selected by: evaluation.trial-observer.
-
Contract: trials.py.
Cloud sandbox provider #
-
Hook: a RemoteExecutor subclass.
-
Called by: the training service, for harness evaluation runs (evolution.executor) and the coding agent (evolution.agent.sandbox).
-
Selected by: its name in REMOTE_EXECUTORS of sandbox/config.py.
-
Contract: remote.py.
Harbor task environments #
|
Provider |
Harbor environment |
Setup on the host that runs the trial |
|---|---|---|
|
Docker |
docker |
A running Docker daemon |
|
E2B |
e2b |
reef-infra[e2b] and E2B_API_KEY |
|
AgentENV |
e2b |
reef-infra[e2b] with your deployment's endpoints and API key (Dockerfile setup) |
|
Modal |
modal |
reef-infra[modal], MODAL_TOKEN_ID and MODAL_TOKEN_SECRET |
Harbor reads CPU, memory and time limits from task.toml. environment_config builds a trial's environment section, and ExecutorEnvironment gives a program executor Harbor's environment interface without an image build.
Rules #
-
Seatbelt profiles cannot nest; LAN addresses stay reachable and memory limits do not apply.
-
A cloud sandbox runs its image's binary and refuses a program that isolates itself.
-
A transfer cannot leave the staged root, which the caller owns. ExecutorEnvironment closes the sessions that it opened, not borrowed ones; cancellation closes both.
-
A trial observer copies what it needs before it returns, and keeps no reference to the directory.
-
wait_closed returns true only after the work and its cleanup end. Do not block the thread or loop that cleanup needs.
-
ProcessScope owns local child processes; detached processes and remote resources need their own cleanup. BackgroundJobWorker.close raises TimeoutError when cleanup takes more than 20 seconds.
Test it #
Run tests/sandbox/ and tests/execution/. Cloud providers have opt-in tests in tests/smoke/.