Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/harbor.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Harbor Hub datasets are pinned by content digest and the older registry datasets
- **Network:** every sandbox gets an explicit policy. Tasks that declare nothing are public, as with the other sandboxes. `no-network` and allowlists (hostnames and wildcards included) are enforced by the sandbox's egress sidecar. Harbor sets a task up with network and narrows it for the agent and the verifier (DeepSWE's `no-network` tasks): each change replaces the sandbox's policy and is read back, and a change that doesn't take effect fails the trial. Connections opened before a change outlive it.
- **Cleanup:** sandboxes carry a `sandbox-run` label unique to the run, and the runner deletes any left when the run ends. If the runner is killed outright, they stay until their 24-hour timeout.

**Agents that run inside the sandbox (`--model-tunnel`).** `terminus-2` runs on the node and calls the model from there. An agent that is installed in the task's sandbox (OpenHands, mini-swe-agent, ...) calls the model from the microVM, and Breithorn's sandboxes cannot open connections to Clariden (calls from Clariden to the OpenSandbox server work, the other direction times out). `--model-tunnel` (with `--sandbox opensandbox`, an in-sandbox `--agent` and `--chisel-dir`, default `$CHISEL_DIR`) opens a reverse tunnel for every sandbox through the OpenSandbox server's proxy, which carries WebSockets: a [chisel](https://github.com/jpillora/chisel) server in the microVM (uploaded at start, so the image needs no internet) and a chisel client on the node that forwards the microVM's `127.0.0.1:8000` to the model at `--api-base-url`. The agent gets `api_base=http://127.0.0.1:8000/v1` unless you pass your own `--agent-kwarg api_base=...`. A trial fails at start if the tunnel does not answer `GET /health`. A separate verifier sandbox gets no tunnel. With direct serving the chisel directory must be one the eval image mounts (the checkout, or your scratch directory). Two limits: chisel takes the server's request headers (with the OpenSandbox API key) only as flags, so they show in `ps` on the node while the run lasts, and a client that dies mid-trial is not restarted by anything but chisel's own reconnects (10 tries), after which the agent's model calls fail. The binaries come from `CHISEL_DIR=<dir> scripts/harbor/fetch_chisel.sh` (checksums pinned, run it on a login node: arm64 for the node, amd64 for the microVMs). Adapted from the model tunnel of swiss-ai/rl-infra (PR 7); the tunnel adds load to the OpenSandbox server (one WebSocket per sandbox), which is why it is opt-in. **OpenHands** (`--agent openhands --model-tunnel`): Harbor 0.25.0 installs the newest `openhands-ai` into every sandbox with `uv pip install`, so the result depends on the day (the newest has no `openhands.core.main`, 0.62.0 and 1.0.0 fail on a missing `pydantic_settings`, 1.2.0 on the newest `mcp`). Pin both: `--agent-kwarg version=1.2.0` and `--agent-env UV_EXCLUDE_NEWER=2026-01-20T00:00:00Z` (Harbor's `--ae KEY=VALUE`: an environment variable in the sandbox, installation included, so uv resolves the dependencies as of that date). The run's sampling profile and `--reasoning-effort` reach OpenHands as its `temperature`, `top_p` and `reasoning_effort` kwargs, the same values terminus-2 gets; other samplers and `--enable-thinking` (a chat-template switch) are refused, because OpenHands has no way to carry them. `chonk_swe_terminal_experts` has the two OpenHands rows (`swe_bench_openhands`, `terminal_bench_2_openhands`) with the terminus-2 rows' sandbox, concurrency, attempts and window; they need `CHISEL_DIR` in the environment of the launch. **OpenCode** (`--agent opencode --model-tunnel`): it takes the endpoint from `OPENAI_BASE_URL` (no `api_base` kwarg), and its `openai` provider is hard-wired to the Responses API, so the runner registers the model as `local/<model>` through a generated `opencode_config` (`@ai-sdk/openai-compatible`, chat completions; no token limits, since OpenCode needs `limit.output` next to `limit.context` and the limits only drive compaction, which the rows turn off, so a `model_info` kwarg is dropped; thinking flags as the model's `chat_template_kwargs` option, which is not yet verified to reach the server). Your own `--agent-kwarg opencode_config=<json>` is merged over the generated one, key by key; the suite rows (`swe_bench_opencode`, `terminal_bench_2_opencode`) pass `{"compaction": {"auto": false}}`, because compaction at the window limit ended every smoke trial. The sampling profile's `temperature` and `top_p` (what terminus-2 and OpenHands get) are the `build` agent's settings in that config (OpenCode sends none otherwise, and the server samples at 1.0 and 1.0); your own `opencode_config` wins over them. The other samplers are refused for OpenCode.
**Agents that run inside the sandbox (`--model-tunnel`).** `terminus-2` runs on the node and calls the model from there. An agent that is installed in the task's sandbox (OpenHands, mini-swe-agent, ...) calls the model from the microVM, and Breithorn's sandboxes cannot open connections to Clariden (calls from Clariden to the OpenSandbox server work, the other direction times out). `--model-tunnel` (with `--sandbox opensandbox`, an in-sandbox `--agent` and `--chisel-dir`, default `$CHISEL_DIR`) opens a reverse tunnel for every sandbox through the OpenSandbox server's proxy, which carries WebSockets: a [chisel](https://github.com/jpillora/chisel) server in the microVM (the copy the OpenSandbox server mounts read-only at `/opt/rl-tools/chisel/<version>/chisel` in every sandbox, the same version as the client, so the image needs no internet and nothing is uploaded) and a chisel client on the node that forwards the microVM's `127.0.0.1:8000` to the model at `--api-base-url`. The agent gets `api_base=http://127.0.0.1:8000/v1` unless you pass your own `--agent-kwarg api_base=...`. A trial fails at start if the tunnel does not answer `GET /health`. A separate verifier sandbox gets no tunnel. With direct serving the chisel directory must be one the eval image mounts (the checkout, or your scratch directory). Two limits: chisel takes the server's request headers (with the OpenSandbox API key) only as flags, so they show in `ps` on the node while the run lasts, and a client that dies mid-trial is not restarted by anything but chisel's own reconnects (10 tries), after which the agent's model calls fail. The binaries come from `CHISEL_DIR=<dir> scripts/harbor/fetch_chisel.sh` (checksums pinned, run it on a login node: arm64 for the GH200 nodes, amd64 for x86 ones: only the node's client comes from there). Adapted from the model tunnel of swiss-ai/rl-infra (PR 7); the tunnel adds load to the OpenSandbox server (one WebSocket per sandbox), which is why it is opt-in. **OpenHands** (`--agent openhands --model-tunnel`): Harbor 0.25.0 installs the newest `openhands-ai` into every sandbox with `uv pip install`, so the result depends on the day (the newest has no `openhands.core.main`, 0.62.0 and 1.0.0 fail on a missing `pydantic_settings`, 1.2.0 on the newest `mcp`). Pin both: `--agent-kwarg version=1.2.0` and `--agent-env UV_EXCLUDE_NEWER=2026-01-20T00:00:00Z` (Harbor's `--ae KEY=VALUE`: an environment variable in the sandbox, installation included, so uv resolves the dependencies as of that date). The run's sampling profile and `--reasoning-effort` reach OpenHands as its `temperature`, `top_p` and `reasoning_effort` kwargs, the same values terminus-2 gets; other samplers and `--enable-thinking` (a chat-template switch) are refused, because OpenHands has no way to carry them. `chonk_swe_terminal_experts` has the two OpenHands rows (`swe_bench_openhands`, `terminal_bench_2_openhands`) with the terminus-2 rows' sandbox, concurrency, attempts and window; they need `CHISEL_DIR` in the environment of the launch. **OpenCode** (`--agent opencode --model-tunnel`): it takes the endpoint from `OPENAI_BASE_URL` (no `api_base` kwarg), and its `openai` provider is hard-wired to the Responses API, so the runner registers the model as `local/<model>` through a generated `opencode_config` (`@ai-sdk/openai-compatible`, chat completions; no token limits, since OpenCode needs `limit.output` next to `limit.context` and the limits only drive compaction, which the rows turn off, so a `model_info` kwarg is dropped; thinking flags as the model's `chat_template_kwargs` option, which is not yet verified to reach the server). Your own `--agent-kwarg opencode_config=<json>` is merged over the generated one, key by key; the suite rows (`swe_bench_opencode`, `terminal_bench_2_opencode`) pass `{"compaction": {"auto": false}}`, because compaction at the window limit ended every smoke trial. The sampling profile's `temperature` and `top_p` (what terminus-2 and OpenHands get) are the `build` agent's settings in that config (OpenCode sends none otherwise, and the server samples at 1.0 and 1.0); your own `opencode_config` wins over them. The other samplers are refused for OpenCode.

**On Clariden:** the nodes are aarch64 and have no Docker, so `scripts/harbor/run_harbor_eval.sbatch` runs Harbor and the agent in a CPU job, with the task containers as Breithorn pods (`--sandbox k8s`, namespace `rob-poc` by default). The kubeconfig on Clariden authenticates through an OIDC login (kubelogin) that a batch job can't renew: log in first (`kubectl get pods` works on the login node) and keep the run within the token's lifetime. Three minutes before the job's time limit the run is stopped (`summary.json` keeps the trials that finished, marked `interrupted`), and at the end the job deletes the pods and NetworkPolicies left with its label, `sandbox-run=harbor-<job id>`.

Expand Down
5 changes: 3 additions & 2 deletions scripts/harbor/fetch_chisel.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
# Fetch chisel (github.com/jpillora/chisel, MIT) for --model-tunnel (scripts/harbor/model_tunnel.py)
# into CHISEL_DIR, checked against the release's sha256 (pinned here). Run on a login node (needs
# internet); idempotent. Both architectures: arm64 for the GH200 nodes (the client), amd64 for the
# OpenSandbox microVMs on Breithorn (the server, uploaded into every sandbox).
# internet); idempotent. Both architectures, since the client runs on the node: arm64 for the GH200
# nodes, amd64 for x86 ones. The server in the sandbox is not fetched: the OpenSandbox server mounts
# it (same version) at /opt/rl-tools/chisel/<version>/chisel.
# CHISEL_DIR=$SCRATCH/chisel bash scripts/harbor/fetch_chisel.sh
# Leaves chisel_<version>_linux_{amd64,arm64} in CHISEL_DIR, the layout --model-tunnel expects.
# Taken from swiss-ai/rl-infra backends/nemo-rl/apertus2/fetch-chisel.sh.
Expand Down
44 changes: 22 additions & 22 deletions scripts/harbor/model_tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
on the node: chisel client -> <target> (the model server, host:port)

Adapted from the per-sandbox model tunnel of swiss-ai/rl-infra (PR 7). chisel
(https://github.com/jpillora/chisel) is not shipped: scripts/harbor/fetch_chisel.sh puts
chisel_<version>_linux_{amd64,arm64} in a directory, which the sandbox copy is uploaded from at every
start, so the task image needs no internet and no tools beyond sh and grep. Agents that run on the
node (terminus-2) call the model directly and need no tunnel.
(https://github.com/jpillora/chisel) runs in the sandbox from the copy the OpenSandbox server mounts
into every sandbox, read-only, at /opt/rl-tools/chisel/<version>/chisel (the pinned version, so
both ends match), so the task image needs no internet and no tools beyond sh and grep. The node's
client is not shipped: scripts/harbor/fetch_chisel.sh puts chisel_<version>_linux_{amd64,arm64} in a
directory, and the one of the node's architecture is used. Agents that run on the node (terminus-2)
call the model directly and need no tunnel.
"""

from __future__ import annotations
Expand All @@ -32,7 +34,9 @@
CHISEL_VERSION = "1.12.0"
ARCH = {"x86_64": "amd64", "amd64": "amd64", "aarch64": "arm64", "arm64": "arm64"}
CONNECTED_MARKER = "Connected (Latency"
POD_BINARY = "/tmp/.chisel"
# The server's chisel in every sandbox (a read-only mount of the OpenSandbox server), and its log.
POD_BINARY = f"/opt/rl-tools/chisel/{CHISEL_VERSION}/chisel"
POD_LOG = "/tmp/.chisel.log"

# The environment variables run.py sets for the environment (--model-tunnel).
TARGET_ENV = "HARBOR_MODEL_TUNNEL_TARGET"
Expand All @@ -43,7 +47,7 @@

@dataclass(frozen=True)
class ModelTunnelConfig:
"""target: host:port the node-side client dials (the model server). chisel_dir: where
"""target: host:port the node-side client dials (the model server). chisel_dir: where the node's
chisel_<version>_linux_{amd64,arm64} are. pod_port: loopback port in the sandbox that reaches the
target. server_port: sandbox port of the chisel server."""

Expand Down Expand Up @@ -76,10 +80,11 @@ def server_start_script(cfg: ModelTunnelConfig, wait_s: float = 15.0) -> str:
The command must not return before the server has left the exec's process group (the exec
service may signal that group when the command ends), and a server that dies at start (bad
binary, port taken) should fail here, not as a client timeout later."""
binary, log = shlex.quote(POD_BINARY), shlex.quote(POD_BINARY + ".log")
binary, log = shlex.quote(POD_BINARY), shlex.quote(POD_LOG)
tries = max(1, int(wait_s / 0.2))
return (
f"chmod +x {binary} || exit 1; (setsid nohup {binary} server --host 0.0.0.0 --port {cfg.server_port} "
f"[ -x {binary} ] || {{ echo 'no chisel at {POD_BINARY}: this OpenSandbox server does not mount it'; exit 1; }}; "
f"(setsid nohup {binary} server --host 0.0.0.0 --port {cfg.server_port} "
f"--reverse > {log} 2>&1 &); "
f"i=0; while [ $i -lt {tries} ]; do "
f"grep -q 'Listening on' {log} 2>/dev/null && exit 0; i=$((i+1)); sleep 0.2; done; "
Expand All @@ -102,19 +107,18 @@ def health_check_script(pod_port: int, path: str, attempts: int = 40) -> str:
class ModelTunnel:
"""One tunnel for one sandbox: open() once it is running, close() before it is deleted.

exec(command, env) -> (return_code, stdout), upload(source, target) and endpoint(port) ->
(url, headers) are the sandbox's: the environment passes its own."""
exec(command, env) -> (return_code, stdout) and endpoint(port) -> (url, headers) are the sandbox's:
the environment passes its own."""

def __init__(
self,
cfg: ModelTunnelConfig,
exec: Callable[..., Awaitable[tuple[int, str]]],
upload: Callable[[Path, str], Awaitable[None]],
endpoint: Callable[[int], Awaitable[tuple[str, dict[str, str]]]],
logger: Any,
label: str = "",
) -> None:
self._cfg, self._exec, self._upload, self._endpoint = cfg, exec, upload, endpoint
self._cfg, self._exec, self._endpoint = cfg, exec, endpoint
self._logger, self._label = logger, label
self._proc: Optional[asyncio.subprocess.Process] = None
self._reader: Optional[asyncio.Task] = None
Expand All @@ -138,15 +142,11 @@ async def open(self) -> None:
async def _open(self) -> str:
cfg = self._cfg
node_arch = ARCH.get(platform.machine())
code, out = await self._exec("uname -m", None)
pod_arch = ARCH.get(out.strip())
if code != 0 or node_arch is None or pod_arch is None:
raise RuntimeError(f"model_tunnel: unsupported architecture (node {platform.machine()!r}, sandbox {out!r})")
node_bin, pod_bin = cfg.binary(node_arch), cfg.binary(pod_arch)
for path in {node_bin, pod_bin}:
if not path.is_file():
raise FileNotFoundError(f"model_tunnel: {path} not found (scripts/harbor/fetch_chisel.sh)")
await self._upload(pod_bin, POD_BINARY)
if node_arch is None:
raise RuntimeError(f"model_tunnel: unsupported node architecture {platform.machine()!r}")
node_bin = cfg.binary(node_arch)
if not node_bin.is_file():
raise FileNotFoundError(f"model_tunnel: {node_bin} not found (scripts/harbor/fetch_chisel.sh)")
# One credential per sandbox: the endpoint is open to every holder of the server's API key. It
# goes in AUTH (chisel reads it from the environment), not in argv.
auth = f"harbor:{secrets.token_hex(16)}"
Expand Down Expand Up @@ -175,7 +175,7 @@ async def _open(self) -> str:
if not fut.done():
fut.cancel()
if not self._connected.is_set():
_, pod_log = await self._exec(f"tail -n 20 {shlex.quote(POD_BINARY + '.log')}", None)
_, pod_log = await self._exec(f"tail -n 20 {shlex.quote(POD_LOG)}", None)
raise RuntimeError(
f"model_tunnel{self._label}: chisel client did not connect within {cfg.connect_timeout_s:g}s; "
f"client output: {list(self._tail)[-10:]}; sandbox side: {pod_log.strip()!r}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/harbor/opensandbox_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def start(self, force_build: bool) -> None:
# Only the agent's environment: a separate verifier's (session id ..__verifier__..) never calls the model.
if config is not None and "__verifier__" not in (self.session_id or ""):
self._model_tunnel = ModelTunnel(
config, self._tunnel_exec, self.upload_file, self._tunnel_endpoint, self.logger, f" [{self.session_id}]"
config, self._tunnel_exec, self._tunnel_endpoint, self.logger, f" [{self.session_id}]"
)
await self._model_tunnel.open()

Expand Down
4 changes: 2 additions & 2 deletions scripts/harbor/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ def parse_args(argv: Optional[List[str]] = None) -> argparse.Namespace:
help="For an agent that runs inside the sandbox (OpenHands, ...): open a reverse tunnel from "
"every sandbox to the model server at --api-base-url (scripts/harbor/model_tunnel.py), because "
"Breithorn's sandboxes cannot reach Clariden. The agent gets api_base=http://127.0.0.1:"
f"{DEFAULT_POD_PORT}/v1. Needs --sandbox opensandbox and the chisel binaries in --chisel-dir. "
f"{DEFAULT_POD_PORT}/v1. Needs --sandbox opensandbox and the node's chisel client in --chisel-dir. "
"Not for terminus-2, which calls the model from the node.",
)
p.add_argument(
"--chisel-dir",
default=os.environ.get("CHISEL_DIR"),
help="Directory with chisel_<version>_linux_{amd64,arm64} (scripts/harbor/fetch_chisel.sh); default $CHISEL_DIR.",
help="Directory with the node's chisel_<version>_linux_{amd64,arm64} (scripts/harbor/fetch_chisel.sh); default $CHISEL_DIR.",
)
args = p.parse_args(argv)
if args.model_tunnel:
Expand Down
5 changes: 3 additions & 2 deletions scripts/harbor/run_harbor_eval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@
# internet (configs/agent_allowlists.json).
# --model-tunnel An agent that runs inside the sandbox (OpenHands, ...) cannot reach the
# --chisel-dir <dir> model on Clariden from Breithorn: open a reverse tunnel from every sandbox to
# --api-base-url (chisel, scripts/harbor/model_tunnel.py; binaries from
# scripts/harbor/fetch_chisel.sh, default dir $CHISEL_DIR). The agent gets
# --api-base-url (chisel, scripts/harbor/model_tunnel.py; the node's client from
# scripts/harbor/fetch_chisel.sh, default dir $CHISEL_DIR; the server is the
# sandbox's own, mounted by the OpenSandbox server). The agent gets
# api_base=http://127.0.0.1:8000/v1. --sandbox opensandbox only; not for
# terminus-2, which calls the model from the node.
# --wandb-entity <entity> W&B entity and project to upload the results to (also WANDB_ENTITY,
Expand Down
Loading