Skip to content

feat(opensandbox): derive connection.protocol from a scheme in connection.domain - #3137

Merged
bxyu-nvidia merged 1 commit into
mainfrom
hemild/opensandbox-protocol-from-domain
Sep 6, 2026
Merged

bxyu-nvidia merged 1 commit into
mainfrom
hemild/opensandbox-protocol-from-domain

Conversation

@hemildesai

@hemildesai hemildesai commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Lets sandbox.opensandbox.connection.domain carry its scheme. When the domain is https://sandbox.example (or OPENSANDBOX_DOMAIN=https://sandbox.example), the provider now derives connection.protocol: https from it and hands the SDK the bare host, so an https endpoint no longer needs a separate ++sandbox.opensandbox.connection.protocol=https override on top of #3104's tls_verify.

Behaviour:

  • A scheme in the domain takes precedence over connection.protocol. The shipped opensandbox.yaml always sets protocol: http, so precedence the other way would make the common case (yaml default + https:// domain) silently talk plain HTTP.
  • Any path prefix in the domain is kept (https://host/prefix → domain host/prefix, protocol https); the SDK appends /v1 as before.
  • Only scheme://host[:port][/path-prefix] is accepted: schemes other than http/https, scheme-only domains (https://), and domains carrying a query string or fragment raise a ValueError at config time (before this change a ?token=... in the domain reached the SDK and produced an unroutable .../prefix?token=abc/v1).
  • Surrounding whitespace is stripped from every domain, scheme or not (an OPENSANDBOX_DOMAIN read with a trailing newline previously reached the SDK verbatim and failed URL parsing on the first request; cleanup_sandboxes.py already did this).
  • Bare hosts are otherwise unchanged: protocol still applies as before.

Why normalize in Gym rather than rely on the SDK: the OpenSandbox SDK already lets a scheme in its domain override protocol when it builds its own base URL, but the provider builds the PTY WebSocket URL from connection.protocol directly, so a scheme-in-domain config previously produced an https REST transport and an http PTY URL. Normalizing once in OpenSandboxConnectionConfig.__post_init__ keeps the SDK transport, the PTY path and cleanup_sandboxes.py (which already accepted a scheme in --domain) consistent.

Files: provider.py (new module-level helper split_domain_scheme(domain) -> (domain, scheme) used by a three-line __post_init__; OpenSandboxConnectionConfig drops frozen=True so it can assign its own fields — nothing hashes or replaces it), opensandbox.yaml (comment), opensandbox.mdx and opensandbox-best-practices.mdx (docs), test_opensandbox_provider.py (new tests; one existing assertion updated from pass-through to normalized form).

Usage

export OPENSANDBOX_DOMAIN=https://sandbox.example.internal   # scheme included
export OPENSANDBOX_API_KEY=...
gym run \
    --config resources_servers/swebench/configs/swebench.yaml \
    --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
    ++sandbox.opensandbox.connection.tls_verify=false          # self-signed endpoint; default

Previously this also required ++sandbox.opensandbox.connection.protocol=https.

Testing

  • pytest tests/unit_tests/test_opensandbox_provider.py — 59 passed (3 new tests: the helper directly, normalization/precedence/whitespace/error cases, and the derived protocol reaching the SDK kwargs and the provider's PTY protocol).
  • Reviewed with an adversarial two-dimension pass (correctness, design); the four confirmed low-severity findings (query/fragment silently dropped, whitespace stripped only for scheme'd domains, docstring rationale, sibling docs page) are addressed in this revision.
  • pre-commit run --files <changed files> clean.
  • End-to-end on a live OpenSandbox cluster behind a self-signed https:// load balancer (SWE-bench Verified, 1024 parallel, this branch): OPENSANDBOX_DOMAIN=https://<host>, the shipped protocol: http, no ++sandbox.opensandbox.connection.protocol=https override. Sandbox creation: 0 failures, 0 SSL errors, 0 connection errors; rollouts progressed normally. The same launch on a tree without this change fails every create on port 80 within a minute.

Checklist

  • The change is focused.
  • Tests added or updated and pass locally.
  • Pre-commit checks pass locally.
  • All commits have DCO sign-off.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

@hemildesai
hemildesai force-pushed the hemild/opensandbox-protocol-from-domain branch from 508f7e2 to d7219fa Compare September 6, 2026 21:19
…tion.domain

OpenSandboxConnectionConfig now accepts a domain that carries its scheme
(https://sandbox.example). The scheme becomes connection.protocol and the
bare host is what reaches the SDK, so an https endpoint no longer needs a
separate ++sandbox.opensandbox.connection.protocol=https override. A scheme
in the domain takes precedence over protocol (the shipped yaml always sets
protocol: http). Schemes other than http/https and scheme-only domains are
rejected.

The SDK already lets a scheme in its own domain override protocol for its
base URL, but the provider builds the PTY WebSocket URL from
connection.protocol directly, so normalizing at the Gym config level keeps
the SDK transport, the PTY path and cleanup_sandboxes.py consistent.

Signed-off-by: Hemil Desai <[email protected]>
@hemildesai
hemildesai force-pushed the hemild/opensandbox-protocol-from-domain branch from d7219fa to 3d31c04 Compare September 6, 2026 21:43
@bxyu-nvidia
bxyu-nvidia marked this pull request as ready for review September 6, 2026 22:17
@bxyu-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 3d31c04

@hemildesai

Copy link
Copy Markdown
Contributor Author

End-to-end check of this branch (3d31c04) on a live OpenSandbox cluster behind a self-signed https:// load balancer, SWE-bench Verified, 1024 parallel rollouts, vLLM P/D on 4 nodes:

  • Config: OPENSANDBOX_DOMAIN=https://<host>, the shipped opensandbox.yaml (protocol: http, tls_verify: false), and no ++sandbox.opensandbox.connection.protocol=https override.
  • Startup: 0 Failed to create sandbox, 0 SSLCertVerificationError, 0 Cannot connect to host — the provider talked https to the endpoint from the first create. The identical launch on a tree without this change fails every create on port 80 within a minute.
  • Run (cancelled by design after the sampling window): 955 rows @30 min, 1103 rows / mean reward 0.7461 / 823 resolved at cancel, 1 unfinished — in line with the same launcher configuration on main (929 @30, 0.7159 full-population reward), i.e. no behavioural change beyond the protocol derivation.

Not covered here: the PTY path (this benchmark uses the exec path), which is exercised only by the unit test asserting connection.protocol resolves to https.

@bxyu-nvidia
bxyu-nvidia merged commit 9d164bf into main Sep 6, 2026
41 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the hemild/opensandbox-protocol-from-domain branch September 6, 2026 22:43
jkyi-nvidia pushed a commit that referenced this pull request Sep 11, 2026
…tion.domain (#3137)

## What does this PR do?

Lets `sandbox.opensandbox.connection.domain` carry its scheme. When the
domain is `https://sandbox.example` (or
`OPENSANDBOX_DOMAIN=https://sandbox.example`), the provider now derives
`connection.protocol: https` from it and hands the SDK the bare host, so
an `https` endpoint no longer needs a separate
`++sandbox.opensandbox.connection.protocol=https` override on top of
#3104's `tls_verify`.

Behaviour:
- A scheme in the domain **takes precedence** over
`connection.protocol`. The shipped `opensandbox.yaml` always sets
`protocol: http`, so precedence the other way would make the common case
(yaml default + `https://` domain) silently talk plain HTTP.
- Any path prefix in the domain is kept (`https://host/prefix` → domain
`host/prefix`, protocol `https`); the SDK appends `/v1` as before.
- Only `scheme://host[:port][/path-prefix]` is accepted: schemes other
than `http`/`https`, scheme-only domains (`https://`), and domains
carrying a query string or fragment raise a `ValueError` at config time
(before this change a `?token=...` in the domain reached the SDK and
produced an unroutable `.../prefix?token=abc/v1`).
- Surrounding whitespace is stripped from every domain, scheme or not
(an `OPENSANDBOX_DOMAIN` read with a trailing newline previously reached
the SDK verbatim and failed URL parsing on the first request;
`cleanup_sandboxes.py` already did this).
- Bare hosts are otherwise unchanged: `protocol` still applies as
before.

Why normalize in Gym rather than rely on the SDK: the OpenSandbox SDK
already lets a scheme in *its* domain override `protocol` when it builds
its own base URL, but the provider builds the PTY WebSocket URL from
`connection.protocol` directly, so a scheme-in-domain config previously
produced an `https` REST transport and an `http` PTY URL. Normalizing
once in `OpenSandboxConnectionConfig.__post_init__` keeps the SDK
transport, the PTY path and `cleanup_sandboxes.py` (which already
accepted a scheme in `--domain`) consistent.

Files: `provider.py` (new module-level helper
`split_domain_scheme(domain) -> (domain, scheme)` used by a three-line
`__post_init__`; `OpenSandboxConnectionConfig` drops `frozen=True` so it
can assign its own fields — nothing hashes or replaces it),
`opensandbox.yaml` (comment), `opensandbox.mdx` and
`opensandbox-best-practices.mdx` (docs), `test_opensandbox_provider.py`
(new tests; one existing assertion updated from pass-through to
normalized form).

## Usage

```bash
export OPENSANDBOX_DOMAIN=https://sandbox.example.internal   # scheme included
export OPENSANDBOX_API_KEY=...
gym run \
    --config resources_servers/swebench/configs/swebench.yaml \
    --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
    ++sandbox.opensandbox.connection.tls_verify=false          # self-signed endpoint; default
```
Previously this also required
`++sandbox.opensandbox.connection.protocol=https`.

## Testing

- `pytest tests/unit_tests/test_opensandbox_provider.py` — 59 passed (3
new tests: the helper directly,
normalization/precedence/whitespace/error cases, and the derived
protocol reaching the SDK kwargs and the provider's PTY protocol).
- Reviewed with an adversarial two-dimension pass (correctness, design);
the four confirmed low-severity findings (query/fragment silently
dropped, whitespace stripped only for scheme'd domains, docstring
rationale, sibling docs page) are addressed in this revision.
- `pre-commit run --files <changed files>` clean.
- End-to-end on a live OpenSandbox cluster behind a self-signed
`https://` load balancer (SWE-bench Verified, 1024 parallel, this
branch): `OPENSANDBOX_DOMAIN=https://<host>`, the shipped `protocol:
http`, **no** `++sandbox.opensandbox.connection.protocol=https`
override. Sandbox creation: 0 failures, 0 SSL errors, 0 connection
errors; rollouts progressed normally. The same launch on a tree without
this change fails every create on port 80 within a minute.

## Checklist

- [x] The change is focused.
- [x] Tests added or updated and pass locally.
- [x] Pre-commit checks pass locally.
- [x] All commits have DCO sign-off.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Hemil Desai <[email protected]>
Signed-off-by: Junkeun Yi <[email protected]>
lafrancef pushed a commit that referenced this pull request Sep 18, 2026
…tion.domain (#3137)

## What does this PR do?

Lets `sandbox.opensandbox.connection.domain` carry its scheme. When the
domain is `https://sandbox.example` (or
`OPENSANDBOX_DOMAIN=https://sandbox.example`), the provider now derives
`connection.protocol: https` from it and hands the SDK the bare host, so
an `https` endpoint no longer needs a separate
`++sandbox.opensandbox.connection.protocol=https` override on top of
#3104's `tls_verify`.

Behaviour:
- A scheme in the domain **takes precedence** over
`connection.protocol`. The shipped `opensandbox.yaml` always sets
`protocol: http`, so precedence the other way would make the common case
(yaml default + `https://` domain) silently talk plain HTTP.
- Any path prefix in the domain is kept (`https://host/prefix` → domain
`host/prefix`, protocol `https`); the SDK appends `/v1` as before.
- Only `scheme://host[:port][/path-prefix]` is accepted: schemes other
than `http`/`https`, scheme-only domains (`https://`), and domains
carrying a query string or fragment raise a `ValueError` at config time
(before this change a `?token=...` in the domain reached the SDK and
produced an unroutable `.../prefix?token=abc/v1`).
- Surrounding whitespace is stripped from every domain, scheme or not
(an `OPENSANDBOX_DOMAIN` read with a trailing newline previously reached
the SDK verbatim and failed URL parsing on the first request;
`cleanup_sandboxes.py` already did this).
- Bare hosts are otherwise unchanged: `protocol` still applies as
before.

Why normalize in Gym rather than rely on the SDK: the OpenSandbox SDK
already lets a scheme in *its* domain override `protocol` when it builds
its own base URL, but the provider builds the PTY WebSocket URL from
`connection.protocol` directly, so a scheme-in-domain config previously
produced an `https` REST transport and an `http` PTY URL. Normalizing
once in `OpenSandboxConnectionConfig.__post_init__` keeps the SDK
transport, the PTY path and `cleanup_sandboxes.py` (which already
accepted a scheme in `--domain`) consistent.

Files: `provider.py` (new module-level helper
`split_domain_scheme(domain) -> (domain, scheme)` used by a three-line
`__post_init__`; `OpenSandboxConnectionConfig` drops `frozen=True` so it
can assign its own fields — nothing hashes or replaces it),
`opensandbox.yaml` (comment), `opensandbox.mdx` and
`opensandbox-best-practices.mdx` (docs), `test_opensandbox_provider.py`
(new tests; one existing assertion updated from pass-through to
normalized form).

## Usage

```bash
export OPENSANDBOX_DOMAIN=https://sandbox.example.internal   # scheme included
export OPENSANDBOX_API_KEY=...
gym run \
    --config resources_servers/swebench/configs/swebench.yaml \
    --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
    ++sandbox.opensandbox.connection.tls_verify=false          # self-signed endpoint; default
```
Previously this also required
`++sandbox.opensandbox.connection.protocol=https`.

## Testing

- `pytest tests/unit_tests/test_opensandbox_provider.py` — 59 passed (3
new tests: the helper directly,
normalization/precedence/whitespace/error cases, and the derived
protocol reaching the SDK kwargs and the provider's PTY protocol).
- Reviewed with an adversarial two-dimension pass (correctness, design);
the four confirmed low-severity findings (query/fragment silently
dropped, whitespace stripped only for scheme'd domains, docstring
rationale, sibling docs page) are addressed in this revision.
- `pre-commit run --files <changed files>` clean.
- End-to-end on a live OpenSandbox cluster behind a self-signed
`https://` load balancer (SWE-bench Verified, 1024 parallel, this
branch): `OPENSANDBOX_DOMAIN=https://<host>`, the shipped `protocol:
http`, **no** `++sandbox.opensandbox.connection.protocol=https`
override. Sandbox creation: 0 failures, 0 SSL errors, 0 connection
errors; rollouts progressed normally. The same launch on a tree without
this change fails every create on port 80 within a minute.

## Checklist

- [x] The change is focused.
- [x] Tests added or updated and pass locally.
- [x] Pre-commit checks pass locally.
- [x] All commits have DCO sign-off.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Hemil Desai <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 3d31c043 Deployed Sep 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #2646
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants