nemo_gym.web.browser_session
nemo_gym.web.browser_session
Browser-supply leases shared by stateful web environments.
The benchmark owns tasks, actions, observations, and evaluation. A browser session provider owns only the lifecycle of the isolated runtime in which the browser executes. Keeping that boundary asynchronous lets a provider acquire an AgentEnv, container, VM, or remote browser without blocking the resources server event loop, while synchronous Playwright operations remain on their session-affine worker thread.
Remote providers should issue expiring leases and renew them from
heartbeat. If the Gym process dies, heartbeats stop and provider-side TTL
cleanup becomes the final backstop against orphaned training sessions.
Module Contents
Classes
Functions
Data
API
Bases: RuntimeError
A provider could not supply or maintain a usable browser session.
Opaque provider handle retained until the rollout is released.
transport describes how the benchmark driver reaches the runtime.
The built-in reference runtime uses local_process. Future providers
may return agentenv or remote_cdp and pair that lease with a driver
that implements the same WebBrowserDriver contract.
The handle is deliberately transport-neutral. Providers may keep their
SDK object in provider_state; benchmark code must use only the declared
transport, endpoint, and metadata instead of depending on that object.
Acquire and release one isolated browser runtime per rollout.
Implementations with synchronous SDKs must offload blocking calls with
asyncio.to_thread. release must be idempotent. Metered or remote
providers must enforce BrowserSessionSpec.lease_ttl_seconds outside the
Gym process so a process crash cannot leak the session indefinitely.
Provider-neutral request for one rollout-scoped browser runtime.
Represent the resources-server process and its DISPLAY as one lease.
The provider itself does not launch Chromium; the visual-browser driver does that on its dedicated thread. The handle records the owning process so a forked child cannot accidentally operate a parent’s Playwright state.
Bases: BrowserSessionProvider
Optional provider extension for renewing an expiring external lease.
Instantiate a provider from a single-key {name: kwargs} mapping.
Register an in-process provider implementation by configuration name.