Skip to navigation

nemo_gym.sandbox.providers.e2b.provider

View as MarkdownOpen in Claude

Sandbox provider backed by the E2B Python SDK.

Works against e2b.dev itself and against any e2b-compatible gateway (point connection.api_url/connection.sandbox_url at it).

Two E2B concepts differ from the provider-neutral SandboxSpec and are handled explicitly rather than silently:

Templates, not images. E2B starts sandboxes from a pre-built template name or ID, not from an arbitrary registry reference. Because tagged template names and OCI image references can both contain :, the direct SandboxSpec.image shortcut is deliberately limited to unambiguous names in [A-Za-z0-9_-]. Use provider_options.template or create.template_map for tagged names, IDs, and image references.

Resources are fixed at template build time. cpu_count/memory_mb are arguments to the template build, so a per-sandbox SandboxSpec.resources cannot be honoured at create time. Requests are reported once per provider instance (or raise, with create.strict_resources) instead of being dropped quietly.

Snapshots keep processes. A snapshot (create_snapshot) saves the whole VM: memory, running processes and disk. A sandbox created from it resumes those processes where they were, so the provider declares capabilities.snapshot_keeps with "processes". The snapshot is usable as soon as the call returns.

Commands run in login shells. The SDK starts every command as bash -l -c and every terminal as bash -i -l. A process does start with its image’s environment, but a Debian image’s /etc/profile then resets PATH. Each new sandbox therefore gets a profile.d hook (create.restore_login_env) that gives a login shell back the environment it started with.

Module Contents

Classes

NameDescription
E2BConnectionConfigConnection settings forwarded to the SDK.
E2BCreateConfigSandbox creation settings.
E2BCreateErrorRaised when a sandbox cannot be created.
E2BExecConfigCommand execution settings.
E2BOperationConfigRetry policy for transient SDK/transport failures.
E2BProviderProvider backed by the E2B Python SDK.
E2BSandboxUnreachableErrorRaised when the E2B gateway could not reach a sandbox it reports as running (HTTP 502, or the SDK’s
E2BSnapshotConfigSnapshot settings.
E2BSnapshotErrorRaised when the installed e2b SDK or the service cannot snapshot a sandbox.
_Lease-

Functions

NameDescription
_config_from_mappingBuild a config dataclass from a mapping, rejecting unknown keys.
_is_finite_number-
_is_missing_templateWhether a create failed because its template does not exist: AgentENV answers HTTP 400 “template … not found”
_is_not_foundWhether an SDK error says the resource does not exist, including a 404 the SDK could not parse.
_is_refusedWhether the service answered a request with a client error other than a timeout, so it did not carry it out.
_is_sandbox_timeoutWhether error is how an SDK without SandboxUnreachableException reports a 502 from the gateway.
_is_unreachableWhether the gateway could not reach a sandbox (HTTP 502); the sandbox may still be alive.
_network_optionsMap an OpenSandbox-shaped network_policy onto E2B’s network create option.
_require_e2b_sdkLoad the optional SDK through the shared helper.
_validate_nonnegative_int-
_validate_nonnegative_number-
_validate_optional_number-

Data

CLEANUP_DRAIN_TIMEOUT_S

KILL_RECHECK_DELAY_S

LEASE_NOT_FOUND_ROUNDS

LEASE_RENEW_CONCURRENCY

LEASE_RENEW_TIMEOUT_S

LOGGER

NEW_SANDBOX_RETRY_S

REACHABLE_PROBE_TIMEOUT_S

REACHABLE_RETRY_DELAY_S

REACHABLE_RETRY_MAX_DELAY_S

SANDBOX_RUNTIME_RETURN_CODE

T

_API_PARAM_KEYS

_DEADLINE_FRACTION

_DIRECT_TEMPLATE_RE

_DYING_STATE

_EXEC_MARKER_ENV

_KILL_MARKED_SCRIPT

_KILL_MARKED_TIMEOUT_S

_LOGIN_ENV_HOOK

_LOGIN_ENV_HOOK_PATH

_NETWORK_API_KEYS

_NETWORK_POLICY_KEYS

_PORT_ROUTING_MODES

_PROVIDER_OPTION_KEYS

_TIMEOUT_RETURN_CODE

_resource_warning_logged

API

class nemo_gym.sandbox.providers.e2b.E2BConnectionConfig(
api_key: str | None = None,
api_url: str | None = None,
sandbox_url: str | None = None,
domain: str | None = None,
debug: bool | None = None,
validate_api_key: bool | None = None,
headers: dict[str, str] | None = None,
api_headers: dict[str, str] | None = None,
proxy: str | None = None,
request_timeout_s: float | None = None,
port_routing: str = 'auto',
port_scheme: str | None = None
)
Dataclass

Connection settings forwarded to the SDK.

Any field left None falls back to the SDK’s own environment variables (E2B_API_KEY, E2B_API_URL, E2B_SANDBOX_URL, E2B_DOMAIN, …).

api_headers
dict[str, str] | None = None
api_key
str | None = None
api_url
str | None = None
debug
bool | None = None
domain
str | None = None
headers
dict[str, str] | None = None
port_routing
str = 'auto'
port_scheme
str | None = None
proxy
str | None = None
request_timeout_s
float | None = None
sandbox_url
str | None = None
validate_api_key
bool | None = None
nemo_gym.sandbox.providers.e2b.E2BConnectionConfig.__post_init__() -> None
class nemo_gym.sandbox.providers.e2b.E2BCreateConfig(
template: str | None = None,
template_map: dict[str, str] = dict(),
timeout_s: float | None = 3600.0,
allow_internet_access: bool = True,
secure: bool = True,
network: dict[str, list[str]] | None = None,
custom_extension_params: dict[str, typing.Any] | None = None,
strict_resources: bool = False,
auto_resume: bool | None = False,
renew_ttl_s: float | None = None,
reachable_timeout_s: float | None = None,
restore_login_env: bool = False
)
Dataclass

Sandbox creation settings.

allow_internet_access
bool = True
auto_resume
bool | None = field(default=False, kw_only=True)
custom_extension_params
dict[str, Any] | None = None
network
dict[str, list[str]] | None = None
reachable_timeout_s
float | None = field(default=None, kw_only=True)
renew_ttl_s
float | None = field(default=None, kw_only=True)
restore_login_env
bool = field(default=False, kw_only=True)
secure
bool = True
strict_resources
bool = False
template
str | None = None
template_map
dict[str, str] = field(default_factory=dict)
timeout_s
float | None = 3600.0
nemo_gym.sandbox.providers.e2b.E2BCreateConfig.__post_init__() -> None
class nemo_gym.sandbox.providers.e2b.E2BCreateError()

Bases: SandboxCreateError

Raised when a sandbox cannot be created.

class nemo_gym.sandbox.providers.e2b.E2BExecConfig(
default_timeout_s: float | None = 180.0,
user: str | None = None,
request_timeout_s: float | None = None,
background: bool = True,
reconnect_attempts: int = 2
)
Dataclass

Command execution settings.

background
bool = True
default_timeout_s
float | None = 180.0
reconnect_attempts
int = 2
request_timeout_s
float | None = None
user
str | None = None
nemo_gym.sandbox.providers.e2b.E2BExecConfig.__post_init__() -> None
class nemo_gym.sandbox.providers.e2b.E2BOperationConfig(
retries: int = 2,
retry_delay_s: float = 0.5,
retry_max_delay_s: float = 8.0,
new_sandbox_grace_s: float = 15.0,
snapshot_list_timeout_s: float = 300.0
)
Dataclass

Retry policy for transient SDK/transport failures.

new_sandbox_grace_s
float = 15.0
retries
int = 2
retry_delay_s
float = 0.5
retry_max_delay_s
float = 8.0
snapshot_list_timeout_s
float = 300.0
nemo_gym.sandbox.providers.e2b.E2BOperationConfig.__post_init__() -> None
class nemo_gym.sandbox.providers.e2b.E2BProvider(
connection: nemo_gym.sandbox.providers.e2b.provider.E2BConnectionConfig | collections.abc.Mapping[str, typing.Any] | None = None,
create: nemo_gym.sandbox.providers.e2b.provider.E2BCreateConfig | collections.abc.Mapping[str, typing.Any] | None = None,
exec: nemo_gym.sandbox.providers.e2b.provider.E2BExecConfig | collections.abc.Mapping[str, typing.Any] | None = None,
operations: nemo_gym.sandbox.providers.e2b.provider.E2BOperationConfig | collections.abc.Mapping[str, typing.Any] | None = None,
attribution: nemo_gym.sandbox.attribution.AttributionConfig | collections.abc.Mapping[str, typing.Any] | None = None,
snapshots: nemo_gym.sandbox.providers.e2b.provider.E2BSnapshotConfig | collections.abc.Mapping[str, typing.Any] | None = None
)

Provider backed by the E2B Python SDK.

_abandoned_creates
set[Task[None]] = set()
_attribution
_connection
_create
= _config_from_mapping(E2BCreateConfig, create)
_exec
= _config_from_mapping(E2BExecConfig, exec)
_lease_task
Task[None] | None = None
_leases
dict[str, _Lease] = {}
_new_until
dict[str, float] = {}
_operations
_snapshots
= _config_from_mapping(E2BSnapshotConfig, snapshots)
_unreturned_snapshots
set[Task[None]] = set()
_warned_resource_specs
set[str] = set()
capabilities
SandboxCapabilities
name
= 'e2b'
nemo_gym.sandbox.providers.e2b.E2BProvider._api_params() -> dict[str, typing.Any]

SDK ApiParams for connection-scoped calls; omitted keys fall back to env.

Only create/connect/kill open a connection and accept these. Everything else runs against an already-connected sandbox — see _request_params.

nemo_gym.sandbox.providers.e2b.E2BProvider._check_resources(
template: str
) -> None

Surface resource requests E2B cannot honour per sandbox.

nemo_gym.sandbox.providers.e2b.E2BProvider._cleanup_failed_create(
sandbox: typing.Any,
reason: str
) -> None
async

Kill a new sandbox the caller will not get; the lease or its timeout ends one the kill misses.

nemo_gym.sandbox.providers.e2b.E2BProvider._create_sandbox(
template: str,
extension_params: collections.abc.Mapping[str, typing.Any] | None = None
async
nemo_gym.sandbox.providers.e2b.E2BProvider._create_with_extension_params(
e2b: typing.Any,
kwargs: dict[str, typing.Any],
extension_params: collections.abc.Mapping[str, typing.Any]
) -> typing.Any
async

Create through POST /sandboxes, adding customExtensionParams.

The POST goes through the SDK’s own API client, so it gets the URL, auth headers, proxy, timeout and HTTP transport of AsyncSandbox.create, and like it is never replayed. AsyncSandbox.connect then attaches; it also returns the envd access token a secure sandbox needs.

nemo_gym.sandbox.providers.e2b.E2BProvider._delete_unreturned_snapshot(
name: str
) -> None
async

Delete by name a snapshot whose request returned no id; the service may have taken it all the same.

nemo_gym.sandbox.providers.e2b.E2BProvider._exec_request_timeout() -> float | None

Return the E2B 2.36 stream-open timeout for command requests.

nemo_gym.sandbox.providers.e2b.E2BProvider._gone_behind_unparsed_reply(
error: BaseException,
sandbox_id: str,
path: str | None = None
) -> bool
async

Whether error is a reply the SDK could not parse about a sandbox the service no longer has.

path looks up another resource instead, such as a snapshot’s template.

AgentENV answers a request about a sandbox it no longer has with a 404 whose body is empty, and the SDK parses the body before it checks the status, so the not-found arrives as a JSONDecodeError instead of the SDK’s not-found exception. Only for such an error is the sandbox looked up; a 404 there settles it. Any other answer, or a lookup that fails, leaves the original error to the caller.

nemo_gym.sandbox.providers.e2b.E2BProvider._hold_lease(
sandbox: typing.Any,
lifetime_s: float | None
) -> None
nemo_gym.sandbox.providers.e2b.E2BProvider._in_grace(
sandbox_id: str
) -> bool

Whether sandbox_id is still in its new-sandbox grace period; forgets one whose period has ended.

nemo_gym.sandbox.providers.e2b.E2BProvider._kill(
sandbox: typing.Any,
not_found: tuple[type[BaseException], ...]
) -> bool
async

Kill a sandbox; False when the service did not find it.

A reply the SDK cannot parse (an empty or plain-text 404) also counts as “not found”: during the new-sandbox grace period without a lookup, so the caller retries, and after it only when a lookup confirms the 404.

nemo_gym.sandbox.providers.e2b.E2BProvider._kill_marked(
sandbox: typing.Any,
marker: str
) -> None
async

Kill what a timed-out command left running, found by its environment marker; best effort.

nemo_gym.sandbox.providers.e2b.E2BProvider._kill_unattached(
e2b: typing.Any,
sandbox_id: str,
after: str
) -> None
async

Kill a sandbox POST /sandboxes created that no SDK object is attached to.

nemo_gym.sandbox.providers.e2b.E2BProvider._lease_renewal_loop() -> None
async

Renew every held lease each third of a lease, until none is held.

nemo_gym.sandbox.providers.e2b.E2BProvider._provider_options(
) -> collections.abc.Mapping[str, typing.Any]
nemo_gym.sandbox.providers.e2b.E2BProvider._renew_lease(
sandbox_id: str,
) -> None
async
nemo_gym.sandbox.providers.e2b.E2BProvider._renew_leases() -> None
async

Renew every held lease once: LEASE_RENEW_CONCURRENCY at a time, each within LEASE_RENEW_TIMEOUT_S.

A renewal that takes a slot frees it for the next one waiting, so a slow renewal holds up no other.

nemo_gym.sandbox.providers.e2b.E2BProvider._request_params() -> dict[str, typing.Any]

Return the request timeout; data-plane methods reject connection parameters.

nemo_gym.sandbox.providers.e2b.E2BProvider._resolve_template(
) -> str

Map a spec onto an E2B template.

Precedence: provider_options.template -> create.template_map -> an unambiguous direct spec.image. create.template is used only when spec.image is omitted; an unmapped image must not silently select an unrelated fallback template.

Building a template from an image is provisioning, not part of starting a sandbox, so it lives in nemo_gym.sandbox.providers.e2b.build and never runs on this path.

nemo_gym.sandbox.providers.e2b.E2BProvider._run_background(
sandbox: typing.Any,
kwargs: dict[str, typing.Any]
) -> typing.Any
async

Run a command detached, reattaching by pid if the stream drops.

commands.run(background=True) returns as soon as the process has started, handing back its pid. The command then keeps running inside the sandbox independently of the stream carrying its output, so losing that stream — a gateway rollout, a proxy restart, a network blip — no longer destroys the command: reattach with commands.connect(pid) and the real exit code still arrives.

Reattaching has two inherent limits:

  • Output emitted while disconnected is lost. Output already received by the previous handle is retained and combined with the reattached stream, but the stream is live rather than replayed.
  • The process must still be running. connect raises not-found once it has exited, so a command that finishes during the gap cannot be recovered.
nemo_gym.sandbox.providers.e2b.E2BProvider._run_cleanup(
cleanup: collections.abc.Coroutine[typing.Any, typing.Any, None],
name: str,
tasks: set[asyncio.Task[None]]
) -> None
staticmethod

Run cleanup as a task of its own in tasks, off the path of the cancel that made it necessary.

nemo_gym.sandbox.providers.e2b.E2BProvider._sandbox(
) -> typing.Any
staticmethod
nemo_gym.sandbox.providers.e2b.E2BProvider._start_grace(
sandbox_id: str
) -> None
nemo_gym.sandbox.providers.e2b.E2BProvider._stop(
sandbox: typing.Any,
sandbox_id: str
) -> None
async

Kill a sandbox, making sure a “not found” really means it is gone.

During the new-sandbox grace period, a kill that finds nothing is repeated until it finds the sandbox or the period ends. After it, a kill that finds nothing is checked again once: a gateway replica that has not seen the sandbox can answer “not found” for one that still runs.

nemo_gym.sandbox.providers.e2b.E2BProvider._wait_reachable(
sandbox: typing.Any,
timeout_s: float
) -> None
async

Run a no-op command until the gateway reaches sandbox.

“Could not be reached” (502) and “not found” (404, including one whose body the SDK cannot parse) are waited out: in a new sandbox’s first seconds a gateway node can answer either for a sandbox that runs. The command does nothing, so running it again is always safe, unlike the caller’s own commands.

nemo_gym.sandbox.providers.e2b.E2BProvider._with_retries(
factory: typing.Callable[[], typing.Awaitable[nemo_gym.sandbox.providers.e2b.provider.T]],
operation: str,
retry_timeouts: bool = False
async

Retry transient failures with exponential backoff.

nemo_gym.sandbox.providers.e2b.E2BProvider._write_login_env_hook(
sandbox: typing.Any
) -> None
async

Write the login-shell hook, waiting out a “not found” about a sandbox still in its grace period.

nemo_gym.sandbox.providers.e2b.E2BProvider.aclose() -> None
async

Stop renewing leases; sandboxes own their connections.

nemo_gym.sandbox.providers.e2b.E2BProvider.close(
) -> None
async
nemo_gym.sandbox.providers.e2b.E2BProvider.connect(
descriptor: collections.abc.Mapping[str, typing.Any]
async

Attach to the sandbox described by descriptor.

E2B’s public connect API applies its default sandbox timeout when none is supplied, so attaching may renew a sandbox that is close to expiry.

nemo_gym.sandbox.providers.e2b.E2BProvider.create(
async
nemo_gym.sandbox.providers.e2b.E2BProvider.create_from_snapshot(
snapshot_id: str,
async

Create a sandbox from a snapshot: E2B starts it from the snapshot’s template id.

The sandbox resumes the snapshot’s memory and processes, and with snapshots.keep_guest_clock its wall clock too. Raises SandboxSnapshotNotFoundError when the service has no such snapshot.

nemo_gym.sandbox.providers.e2b.E2BProvider.delete_snapshot(
snapshot_id: str
) -> None
async

Delete a snapshot (its template), by id or by name; one that is already gone is not an error.

nemo_gym.sandbox.providers.e2b.E2BProvider.download_file(
source_path: str,
target_path: pathlib.Path
) -> None
async
nemo_gym.sandbox.providers.e2b.E2BProvider.endpoint(
port: int
async

Resolve a declared service port to a caller-reachable endpoint.

E2B deployments publish sandbox ports in one of two shapes, and the endpoint differs accordingly:

hostname One DNS name per port, {port}-{sandbox_id}.{domain}. The caller dials it directly, so no headers are needed. gateway A single origin fronts every sandbox and every port, and the proxy picks the target from request headers. A self-hosted deployment without wildcard DNS for sandbox subdomains uses this, and points sandbox_url at that origin. The SDK mints X-Access-Token and E2b-Sandbox-Id per sandbox and sets E2b-Sandbox-Port to envd’s own port, so the target port must be re-pointed here.

auto selects gateway exactly when a sandbox URL is configured, which is the same signal the SDK uses to decide that one origin serves every sandbox.

The returned headers are the caller’s to send verbatim. X-Access-Token is minted per sandbox and is not the deployment’s API key.

nemo_gym.sandbox.providers.e2b.E2BProvider.exec(
command: str | collections.abc.Sequence[str],
cwd: str | None = None,
env: dict[str, str] | None = None,
timeout_s: int | float | None = None,
user: str | int | None = None
async
nemo_gym.sandbox.providers.e2b.E2BProvider.list_snapshots(
prefix: str
async

Every snapshot one of whose names starts with prefix; the service matches whole names only.

A snapshot’s name is its template alias without the team namespace and tag. One taken without a name has name=None and matches only the empty prefix. Without snapshots.list_by_name a non-empty prefix finds none and the service is not asked. Raises SandboxSnapshotError when the listing fails, or is not complete within operations.snapshot_list_timeout_s.

nemo_gym.sandbox.providers.e2b.E2BProvider.network_options(
hosts: collections.abc.Sequence[str],
provider_options: collections.abc.Mapping[str, typing.Any]
) -> dict[str, typing.Any]

Apply a portable egress rule through E2B’s existing network_policy adapter.

nemo_gym.sandbox.providers.e2b.E2BProvider.pause(
) -> None
async

Pause the sandbox through the E2B SDK without replaying failed requests.

nemo_gym.sandbox.providers.e2b.E2BProvider.read_file(
source_path: str
) -> bytes
async
nemo_gym.sandbox.providers.e2b.E2BProvider.resume(
) -> None
async

Resume the sandbox and replace its SDK handle only after success.

nemo_gym.sandbox.providers.e2b.E2BProvider.serialize_handle(
scope: str | None = None
) -> dict[str, typing.Any]
async

Return a descriptor for attaching to this sandbox from another process.

nemo_gym.sandbox.providers.e2b.E2BProvider.snapshot(
name: str | None = None
) -> str
async

Snapshot the whole VM and return the snapshot id; it is usable when this returns.

The VM pauses for the moment it is captured and then keeps running. Not retried: a repeated request could leave a second snapshot nobody knows the id of. name is sent only with snapshots.send_names. A request that sent one and ends without an id, cancelled or failed, has that name deleted off the caller’s path: the service may have taken the snapshot all the same. So a name is used for one request only. A request the service refused (_is_refused) took no snapshot, so its name is left alone: a name that is already taken is refused, and deleting it would delete the snapshot that holds it.

nemo_gym.sandbox.providers.e2b.E2BProvider.status(
async
nemo_gym.sandbox.providers.e2b.E2BProvider.upload_file(
source_path: pathlib.Path,
target_path: str
) -> None
async
nemo_gym.sandbox.providers.e2b.E2BProvider.wait_snapshot_ready(
snapshot_id: str
) -> None
async

Nothing to wait for: an E2B snapshot is usable once snapshot returns.

nemo_gym.sandbox.providers.e2b.E2BProvider.write_file(
target_path: str,
data: str | bytes
) -> None
async
class nemo_gym.sandbox.providers.e2b.E2BSandboxUnreachableError()

Bases: RuntimeError

Raised when the E2B gateway could not reach a sandbox it reports as running (HTTP 502, or the SDK’s SandboxUnreachableException); the sandbox may still be alive.

class nemo_gym.sandbox.providers.e2b.E2BSnapshotConfig(
send_names: bool = False,
list_by_name: bool = False,
keep_guest_clock: bool = False
)
Dataclass

Snapshot settings.

keep_guest_clock
bool = False
list_by_name
bool = False
send_names
bool = False
nemo_gym.sandbox.providers.e2b.E2BSnapshotConfig.__post_init__() -> None
class nemo_gym.sandbox.providers.e2b.E2BSnapshotError()

Bases: SandboxSnapshotError

Raised when the installed e2b SDK or the service cannot snapshot a sandbox.

class nemo_gym.sandbox.providers.e2b.provider._Lease(
sandbox: typing.Any,
lifetime_end: float | None,
not_found_rounds: int = 0
)
Dataclass
lifetime_end
float | None
not_found_rounds
int = 0
nemo_gym.sandbox.providers.e2b.provider._config_from_mapping(
value: typing.Any

Build a config dataclass from a mapping, rejecting unknown keys.

nemo_gym.sandbox.providers.e2b.provider._is_finite_number(
value: typing.Any
) -> bool
nemo_gym.sandbox.providers.e2b.provider._is_missing_template(
error: BaseException | None
) -> bool

Whether a create failed because its template does not exist: AgentENV answers HTTP 400 “template … not found” for a template or snapshot id it does not have.

nemo_gym.sandbox.providers.e2b.provider._is_not_found(
error: BaseException | None,
e2b: typing.Any
) -> bool

Whether an SDK error says the resource does not exist, including a 404 the SDK could not parse.

nemo_gym.sandbox.providers.e2b.provider._is_refused(
error: BaseException
) -> bool

Whether the service answered a request with a client error other than a timeout, so it did not carry it out.

Read from the status the SDK puts on its error, or failing that from the "<status>:" its message starts with. An error with no status (a dropped connection, a reply the SDK cannot parse) does not count: the request may have been carried out.

nemo_gym.sandbox.providers.e2b.provider._is_sandbox_timeout(
error: BaseException,
e2b: typing.Any
) -> bool

Whether error is how an SDK without SandboxUnreachableException reports a 502 from the gateway.

Such an SDK raises a TimeoutException built by its format_sandbox_timeout_exception, for a 502 from the sandbox’s HTTP API and for an unavailable command stream, and for nothing else. The error carries no status, so it is told from the SDK’s other timeouts by the text that formatter appends, read from the SDK itself. A sandbox that reached its lifetime gets the same error, so callers bound their retries.

nemo_gym.sandbox.providers.e2b.provider._is_unreachable(
error: BaseException,
e2b: typing.Any
) -> bool

Whether the gateway could not reach a sandbox (HTTP 502); the sandbox may still be alive.

nemo_gym.sandbox.providers.e2b.provider._network_options(
network_policy: typing.Any
) -> dict[str, list[str]]

Map an OpenSandbox-shaped network_policy onto E2B’s network create option.

{"defaultAction": "deny", "egress": [{"action": "allow", "target": T}, ...]} denies all egress but the allowed targets; defaultAction: allow denies only the targets marked deny. Anything else is refused rather than applied loosely.

nemo_gym.sandbox.providers.e2b.provider._require_e2b_sdk() -> typing.Any

Load the optional SDK through the shared helper.

Keep this small wrapper local so provider unit tests can replace the SDK without importing or contacting E2B.

nemo_gym.sandbox.providers.e2b.provider._validate_nonnegative_int(
name: str,
value: typing.Any
) -> None
nemo_gym.sandbox.providers.e2b.provider._validate_nonnegative_number(
name: str,
value: typing.Any
) -> None
nemo_gym.sandbox.providers.e2b.provider._validate_optional_number(
name: str,
value: typing.Any,
positive: bool
) -> None
nemo_gym.sandbox.providers.e2b.provider.CLEANUP_DRAIN_TIMEOUT_S = 30.0
nemo_gym.sandbox.providers.e2b.provider.KILL_RECHECK_DELAY_S = 1.0
nemo_gym.sandbox.providers.e2b.provider.LEASE_NOT_FOUND_ROUNDS = 2
nemo_gym.sandbox.providers.e2b.provider.LEASE_RENEW_CONCURRENCY = 64
nemo_gym.sandbox.providers.e2b.provider.LEASE_RENEW_TIMEOUT_S = 10.0
nemo_gym.sandbox.providers.e2b.provider.LOGGER = logging.getLogger(__name__)
nemo_gym.sandbox.providers.e2b.provider.NEW_SANDBOX_RETRY_S = 1.0
nemo_gym.sandbox.providers.e2b.provider.REACHABLE_PROBE_TIMEOUT_S = 30.0
nemo_gym.sandbox.providers.e2b.provider.REACHABLE_RETRY_DELAY_S = 1.0
nemo_gym.sandbox.providers.e2b.provider.REACHABLE_RETRY_MAX_DELAY_S = 8.0
nemo_gym.sandbox.providers.e2b.provider.SANDBOX_RUNTIME_RETURN_CODE = 125
nemo_gym.sandbox.providers.e2b.provider.T = TypeVar('T')
nemo_gym.sandbox.providers.e2b.provider._API_PARAM_KEYS = ('api_key', 'api_url', 'sandbox_url', 'domain', 'debug', 'validate_api_key', 'he...
nemo_gym.sandbox.providers.e2b.provider._DEADLINE_FRACTION = 0.99
nemo_gym.sandbox.providers.e2b.provider._DIRECT_TEMPLATE_RE = re.compile('^[A-Za-z0-9_-]+$')
nemo_gym.sandbox.providers.e2b.provider._DYING_STATE = re.compile('invalid state Kill(?:ing|ed)\\b')
nemo_gym.sandbox.providers.e2b.provider._EXEC_MARKER_ENV = 'NEMO_GYM_E2B_EXEC'
nemo_gym.sandbox.providers.e2b.provider._KILL_MARKED_SCRIPT = 'm={marker}; for d in /proc/[0-9]*; do p=${{d#/proc/}}; [ "$p" = "$$" ] && conti...
nemo_gym.sandbox.providers.e2b.provider._KILL_MARKED_TIMEOUT_S = 30.0
nemo_gym.sandbox.providers.e2b.provider._LOGIN_ENV_HOOK = '# Written by NeMo Gym\'s E2B provider: give this login shell back the environme...
nemo_gym.sandbox.providers.e2b.provider._LOGIN_ENV_HOOK_PATH = '/etc/profile.d/zz-nemo-gym-env.sh'
nemo_gym.sandbox.providers.e2b.provider._NETWORK_API_KEYS = {'allow_out': 'allowOut', 'deny_out': 'denyOut'}
nemo_gym.sandbox.providers.e2b.provider._NETWORK_POLICY_KEYS = frozenset({'defaultAction', 'egress'})
nemo_gym.sandbox.providers.e2b.provider._PORT_ROUTING_MODES = ('auto', 'hostname', 'gateway')
nemo_gym.sandbox.providers.e2b.provider._PROVIDER_OPTION_KEYS = frozenset({'template', 'resource_requests', 'network_policy'})
nemo_gym.sandbox.providers.e2b.provider._TIMEOUT_RETURN_CODE = 124
nemo_gym.sandbox.providers.e2b.provider._resource_warning_logged = False