Skip to content

feat(opensandbox): add connection.tls_verify (default off) to the OpenSandbox provider - #3104

Merged
bxyu-nvidia merged 1 commit into
mainfrom
hemild/opensandbox-insecure-tls
Sep 6, 2026
Merged

bxyu-nvidia merged 1 commit into
mainfrom
hemild/opensandbox-insecure-tls

Conversation

@hemildesai

@hemildesai hemildesai commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make the OpenSandbox provider usable against an https:// endpoint whose certificate the client cannot verify, such as the cell-3 validation cluster behind a self-signed load balancer, with a config key only (no environment variable).

  • New connection.tls_verify on the provider, default false, applied to every connection it opens: the httpx transport, the httpx-aiohttp bridge transport (transport_backend: aiohttp, the shipped default), and the aiohttp client behind each PTY WebSocket session.
  • Set tls_verify: true for endpoints with a verifiable certificate. Pair https endpoints with connection.protocol: https.
  • cleanup_sandboxes.py mirrors the setting: --tls-verify flag, or tls_verify from --connection-config; verification is off by default there too.
  • Docs and the shipped yaml gain the setting.

Note the default: with this change the provider does not verify server certificates unless tls_verify: true is set. That is the intended behavior for the current deployments (internal endpoints, self-signed certificates); flip the yaml default if the project prefers verification on.

Usage with an https:// endpoint

Two settings are required for an https:// endpoint: connection.protocol=https (the shipped default is http, and without this override nothing works) and connection.tls_verify=false (the default) when the certificate is self-signed or otherwise unverifiable. Minimal form, as overrides on the shipped provider config:

gym env start \
  --config responses_api_agents/opencode_sandboxed_agent/configs/opencode_sandboxed_agent.yaml \
  --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
  --config responses_api_models/vllm_model/configs/vllm_model.yaml \
  ++sandbox.opensandbox.connection.domain=https://sandbox.example.internal \
  ++sandbox.opensandbox.connection.protocol=https \
  ++sandbox.opensandbox.connection.tls_verify=false

Or as an override config layered on top of the shipped one (--config configs/opensandbox_https.yaml in place of the three ++ lines):

# configs/opensandbox_https.yaml
sandbox:
  opensandbox:
    connection:
      domain: https://sandbox.example.internal        # or ${oc.env:OPENSANDBOX_DOMAIN,...}
      api_key: ${oc.env:OPENSANDBOX_API_KEY}
      protocol: https      # required: the shipped default is http
      tls_verify: false    # default; set true when the certificate chain is verifiable

The cleanup helper follows the same setting:

python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --connection-config configs/opensandbox_https.yaml --run-id <slurm-job-id> --user <user>   # protocol and tls_verify from the config
python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --domain https://sandbox.example.internal --protocol https --api-key "$OPENSANDBOX_API_KEY" --tls-verify \
  --run-id <slurm-job-id> --user <user>                                                          # verification on

Why

Every cell-3 run so far has run from side branches that carried an env-var opt-out; main has no way to reach an https endpoint with an unverifiable certificate, so a stock checkout cannot run there. This is the smallest upstreamable piece, expressed as Hydra config so it composes like the other connection settings.

Test plan

  • pytest tests/unit_tests/test_opensandbox_provider.py tests/unit_tests/test_opensandbox_cleanup.py in a fresh worktree venv with opensandbox, httpx-aiohttp, tenacity installed: 107 passed. New tests: CERT_NONE by default and CERT_REQUIRED with tls_verify: true on both the httpx and bridge transports, the PTY client's connector ssl flag following the setting, and the cleanup script's connector with and without --tls-verify.
  • pre-commit run --files ... on the changed files.
  • SWE-bench Verified from this branch against an https endpoint with a self-signed certificate: 1475 rows / 0.7159 mean reward / 1056 resolved at the 2 h wall, no TLS or sandbox errors (details in the comment below).

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 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 4, 2026

Copy link
Copy Markdown
Contributor

@hemildesai hemildesai changed the title feat(opensandbox): connection.tls_verify with OPENSANDBOX_INSECURE_TLS opt-out feat(opensandbox): connection.tls_verify (default off) for every provider connection Sep 4, 2026
@hemildesai
hemildesai force-pushed the hemild/opensandbox-insecure-tls branch from cc6e1e7 to af69635 Compare September 4, 2026 20:27
…nSandbox provider

Add connection.tls_verify to the OpenSandbox provider and apply it to every
connection the provider opens: the httpx transport, the httpx-aiohttp bridge
transport, and the aiohttp client behind each PTY session. It defaults to
false, so https endpoints whose certificate the client cannot verify (for
example a validation cell behind a self-signed load balancer) work without
extra setup; set tls_verify: true for endpoints with a verifiable
certificate. The cleanup_sandboxes.py helper mirrors the setting with
--tls-verify and reads tls_verify from --connection-config.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Hemil Desai <[email protected]>
@hemildesai hemildesai changed the title feat(opensandbox): connection.tls_verify (default off) for every provider connection feat(opensandbox): add connection.tls_verify (default off) to the OpenSandbox provider Sep 4, 2026
@hemildesai
hemildesai force-pushed the hemild/opensandbox-insecure-tls branch from af69635 to b4c7a33 Compare September 4, 2026 21:31
@hemildesai
hemildesai marked this pull request as ready for review September 4, 2026 21:34
@hemildesai

Copy link
Copy Markdown
Contributor Author

/claude review

@hemildesai

Copy link
Copy Markdown
Contributor Author

/ok to test b4c7a33

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — the tls_verify plumbing is correct and consistently applied across all four connection paths (httpx SDK transport, httpx-aiohttp bridge, PTY aiohttp session, and the cleanup connector), and the tests assert real behavior (verify_mode, connector._ssl, connector kwargs). No async-pattern, public-API, or config-convention violations.

One thing to be deliberate about, not a blocker:

RISK — default flips TLS verification from on to off.

  • WHAT: Base behavior for https endpoints was verifying (httpx.AsyncHTTPTransport → verify=True; PTY aiohttp.ClientSession() → SSL verified). With tls_verify defaulting to false, any https endpoint now runs unverified by default (verify=False / TCPConnector(ssl=False)), i.e. MITM-exposed.
  • BLAST RADIUS: Limited in the common case — the shipped default connection.protocol is http, so TLS isn't in play unless an operator opts into https. The exposure lands only on users who switch to https and don't also set tls_verify: true. provider.py:738, provider.py:1477-1478, cleanup_sandboxes.py:40-41.
  • This is documented and clearly intentional (self-signed validation-cluster LBs). Fine as a design decision; flagging so it's a conscious choice that an https default is insecure-by-default rather than an oversight.

No changes required to merge.

@hemildesai

Copy link
Copy Markdown
Contributor Author

Validation run of this branch (b4c7a3343 content) on an internal OpenSandbox cluster fronted by an https:// load balancer with a self-signed certificate, protocol: https, default tls_verify: false, bridge transport (transport_backend: aiohttp):

  • SWE-bench Verified, 1500 rollouts, 1024 concurrency, 2 h wall: 1475 graded rows, mean reward 0.7159, 1056 resolved, 4 unfinished. Zero certificate/SSL errors, zero sandbox-create failures, no fallback to the plain httpx transport.
  • A second run of the same branch with a different API key: 1466 rows / 0.7080 / 1038 resolved (stopped at 1:43).
  • Reference runs on the same infrastructure from earlier branches that carried an env-var opt-out: 1453 / 0.7220 and 1458 / 0.7181.
  • cleanup_sandboxes.py with the default (verification off) reaped the leftovers of the stopped run over https; the finished run left none.

🤖 Generated with Claude Code

@bxyu-nvidia
bxyu-nvidia merged commit 76f3d74 into main Sep 6, 2026
41 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the hemild/opensandbox-insecure-tls branch September 6, 2026 21:03
bxyu-nvidia pushed a commit that referenced this pull request Sep 6, 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]>
jkyi-nvidia pushed a commit that referenced this pull request Sep 11, 2026
…nSandbox provider (#3104)

## Summary

Make the OpenSandbox provider usable against an `https://` endpoint
whose certificate the client cannot verify, such as the cell-3
validation cluster behind a self-signed load balancer, with a config key
only (no environment variable).

- New `connection.tls_verify` on the provider, **default `false`**,
applied to every connection it opens: the httpx transport, the
httpx-aiohttp bridge transport (`transport_backend: aiohttp`, the
shipped default), and the aiohttp client behind each PTY WebSocket
session.
- Set `tls_verify: true` for endpoints with a verifiable certificate.
Pair `https` endpoints with `connection.protocol: https`.
- `cleanup_sandboxes.py` mirrors the setting: `--tls-verify` flag, or
`tls_verify` from `--connection-config`; verification is off by default
there too.
- Docs and the shipped yaml gain the setting.

Note the default: with this change the provider does **not** verify
server certificates unless `tls_verify: true` is set. That is the
intended behavior for the current deployments (internal endpoints,
self-signed certificates); flip the yaml default if the project prefers
verification on.

## Usage with an `https://` endpoint

Two settings are required for an `https://` endpoint:
`connection.protocol=https` (the shipped default is `http`, and without
this override nothing works) and `connection.tls_verify=false` (the
default) when the certificate is self-signed or otherwise unverifiable.
Minimal form, as overrides on the shipped provider config:

```bash
gym env start \
  --config responses_api_agents/opencode_sandboxed_agent/configs/opencode_sandboxed_agent.yaml \
  --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
  --config responses_api_models/vllm_model/configs/vllm_model.yaml \
  ++sandbox.opensandbox.connection.domain=https://sandbox.example.internal \
  ++sandbox.opensandbox.connection.protocol=https \
  ++sandbox.opensandbox.connection.tls_verify=false
```

Or as an override config layered on top of the shipped one (`--config
configs/opensandbox_https.yaml` in place of the three `++` lines):

```yaml
# configs/opensandbox_https.yaml
sandbox:
  opensandbox:
    connection:
      domain: https://sandbox.example.internal        # or ${oc.env:OPENSANDBOX_DOMAIN,...}
      api_key: ${oc.env:OPENSANDBOX_API_KEY}
      protocol: https      # required: the shipped default is http
      tls_verify: false    # default; set true when the certificate chain is verifiable
```

The cleanup helper follows the same setting:

```bash
python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --connection-config configs/opensandbox_https.yaml --run-id <slurm-job-id> --user <user>   # protocol and tls_verify from the config
python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --domain https://sandbox.example.internal --protocol https --api-key "$OPENSANDBOX_API_KEY" --tls-verify \
  --run-id <slurm-job-id> --user <user>                                                          # verification on
```

## Why

Every cell-3 run so far has run from side branches that carried an
env-var opt-out; `main` has no way to reach an https endpoint with an
unverifiable certificate, so a stock checkout cannot run there. This is
the smallest upstreamable piece, expressed as Hydra config so it
composes like the other connection settings.

## Test plan

- [x] `pytest tests/unit_tests/test_opensandbox_provider.py
tests/unit_tests/test_opensandbox_cleanup.py` in a fresh worktree venv
with `opensandbox`, `httpx-aiohttp`, `tenacity` installed: 107 passed.
New tests: `CERT_NONE` by default and `CERT_REQUIRED` with `tls_verify:
true` on both the httpx and bridge transports, the PTY client's
connector `ssl` flag following the setting, and the cleanup script's
connector with and without `--tls-verify`.
- [x] `pre-commit run --files ...` on the changed files.
- [x] SWE-bench Verified from this branch against an https endpoint with
a self-signed certificate: 1475 rows / 0.7159 mean reward / 1056
resolved at the 2 h wall, no TLS or sandbox errors (details in the
comment below).

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

Signed-off-by: Hemil Desai <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Junkeun Yi <[email protected]>
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]>
bxyu-nvidia pushed a commit that referenced this pull request Sep 16, 2026
## What does this PR do?

With `connection.keepalive_expiry_s: null` and `connection.tls_verify:
false`, the OpenSandbox provider omitted its configured transport. The
SDK then verified certificates anyway, so requests to self-signed HTTPS
endpoints failed even though PTY connections honored the same TLS
setting.

Keep the shared provider transport when certificate verification is
disabled, including when keepalive is unset. Preserve the SDK-default
path when verification is enabled and pooling remains enabled. This
completes the TLS configuration support from #3104 without changing the
current TLS default.

Adds a 16-case regression matrix across TLS verification, HTTP backend,
and pooling settings, and documents when the SDK-default transport is
used.

## Validation

- Focused sandbox/docs suite: **336 passed, 3 skipped**, plus 20 passing
subtests. The regression matrix fails in the two affected cases before
the fix.
- Real OpenSandbox SDK requests against a local self-signed HTTPS
server: all six checks behaved as expected. Both HTTP backends succeed
with verification disabled after the fix; verification enabled still
rejects the certificate; unchanged main reproduces the failure with
verification disabled.
- `pre-commit run --all-files`: passed.
- `make docs-check`: zero errors; the redirect check is skipped without
Fern authentication.
- Full core run on macOS in CPU mode: **4,832 passed, 107 skipped, 1
failed**. Unchanged main (`676cf1f4e`) gives **4,816 passed, 107
skipped, 1 failed** with the same Enroot `/proc` failure
(`test_create_start_timeout_cleans_up`) and the same **93.07%**
aggregate coverage, below the configured gate. The 16 additional tests
pass; the changed OpenSandbox provider has **97.90%** coverage. The
full-suite checkbox remains unchecked.
- Public lint, copyright, secret-scanning and DCO checks passed. Full
test CI has not started; per `CONTRIBUTING.md`, an NVIDIA-NeMo member
can authorize it with `/ok to test
5fe5bd3`.

## Checklist

- [x] I have read the [contributing
guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup).
- [x] The change is focused; unrelated "drive-by" edits are tracked as
separate issues/PRs.
- [ ] Tests added or updated and pass locally, or N/A for docs-only /
non-code changes (so CI unit/server checks pass when applicable).
- [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so
CI lint/format/copyright pass).
- [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check
passes).

Signed-off-by: Stephen Ge <[email protected]>
lafrancef pushed a commit that referenced this pull request Sep 18, 2026
…nSandbox provider (#3104)

## Summary

Make the OpenSandbox provider usable against an `https://` endpoint
whose certificate the client cannot verify, such as the cell-3
validation cluster behind a self-signed load balancer, with a config key
only (no environment variable).

- New `connection.tls_verify` on the provider, **default `false`**,
applied to every connection it opens: the httpx transport, the
httpx-aiohttp bridge transport (`transport_backend: aiohttp`, the
shipped default), and the aiohttp client behind each PTY WebSocket
session.
- Set `tls_verify: true` for endpoints with a verifiable certificate.
Pair `https` endpoints with `connection.protocol: https`.
- `cleanup_sandboxes.py` mirrors the setting: `--tls-verify` flag, or
`tls_verify` from `--connection-config`; verification is off by default
there too.
- Docs and the shipped yaml gain the setting.

Note the default: with this change the provider does **not** verify
server certificates unless `tls_verify: true` is set. That is the
intended behavior for the current deployments (internal endpoints,
self-signed certificates); flip the yaml default if the project prefers
verification on.

## Usage with an `https://` endpoint

Two settings are required for an `https://` endpoint:
`connection.protocol=https` (the shipped default is `http`, and without
this override nothing works) and `connection.tls_verify=false` (the
default) when the certificate is self-signed or otherwise unverifiable.
Minimal form, as overrides on the shipped provider config:

```bash
gym env start \
  --config responses_api_agents/opencode_sandboxed_agent/configs/opencode_sandboxed_agent.yaml \
  --config nemo_gym/sandbox/providers/opensandbox/configs/opensandbox.yaml \
  --config responses_api_models/vllm_model/configs/vllm_model.yaml \
  ++sandbox.opensandbox.connection.domain=https://sandbox.example.internal \
  ++sandbox.opensandbox.connection.protocol=https \
  ++sandbox.opensandbox.connection.tls_verify=false
```

Or as an override config layered on top of the shipped one (`--config
configs/opensandbox_https.yaml` in place of the three `++` lines):

```yaml
# configs/opensandbox_https.yaml
sandbox:
  opensandbox:
    connection:
      domain: https://sandbox.example.internal        # or ${oc.env:OPENSANDBOX_DOMAIN,...}
      api_key: ${oc.env:OPENSANDBOX_API_KEY}
      protocol: https      # required: the shipped default is http
      tls_verify: false    # default; set true when the certificate chain is verifiable
```

The cleanup helper follows the same setting:

```bash
python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --connection-config configs/opensandbox_https.yaml --run-id <slurm-job-id> --user <user>   # protocol and tls_verify from the config
python nemo_gym/sandbox/providers/opensandbox/cleanup_sandboxes.py \
  --domain https://sandbox.example.internal --protocol https --api-key "$OPENSANDBOX_API_KEY" --tls-verify \
  --run-id <slurm-job-id> --user <user>                                                          # verification on
```

## Why

Every cell-3 run so far has run from side branches that carried an
env-var opt-out; `main` has no way to reach an https endpoint with an
unverifiable certificate, so a stock checkout cannot run there. This is
the smallest upstreamable piece, expressed as Hydra config so it
composes like the other connection settings.

## Test plan

- [x] `pytest tests/unit_tests/test_opensandbox_provider.py
tests/unit_tests/test_opensandbox_cleanup.py` in a fresh worktree venv
with `opensandbox`, `httpx-aiohttp`, `tenacity` installed: 107 passed.
New tests: `CERT_NONE` by default and `CERT_REQUIRED` with `tls_verify:
true` on both the httpx and bridge transports, the PTY client's
connector `ssl` flag following the setting, and the cleanup script's
connector with and without `--tls-verify`.
- [x] `pre-commit run --files ...` on the changed files.
- [x] SWE-bench Verified from this branch against an https endpoint with
a self-signed certificate: 1475 rows / 0.7159 mean reward / 1056
resolved at the 2 h wall, no TLS or sandbox errors (details in the
comment below).

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

Signed-off-by: Hemil Desai <[email protected]>
Co-authored-by: Claude Fable 5.1 <[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 — b4c7a334 Deployed Sep 4, 2026 by copy-pr-bot[bot] via release / finalize / notify #2608
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