Add CUBE-standard MVP with OSWorld.
Summary
Adds a CUBE-backed resources server and cube agent so NeMo Gym can run multi-step tool + environment rollouts (e.g. OSWorld via CUBE), integrated with ng_collect_rollouts and the existing head-server / verify / aggregate-metrics flow.
Also adds optional per-step debug on the rollout client (+debug_each_step) and best-effort cleanup of live CUBE tasks when the resources server shuts down.
What changed
CUBE resources server (resources_servers/cube/)
- HTTP surface:
/seed_session,/step,/verify,/close,/aggregate_metrics. - Pluggable
env_domain(e.g.osworld) via registry and adapters; shared schemas for verify / step / seed. - Config, example JSONL, requirements, README, and HTML docs (architecture + primitives).
- Shutdown:
close_all_open_environments()closes every tracked CUBEtaskon ASGI lifespan teardown (chained after the router’s existing lifespan, including profiling). Blockingtask.close()runs in a thread pool.atexitregisters the same closer as a fallback. Does not run on SIGKILL /kill -9or hard crashes.
Cube agent (responses_api_agents/cube_agent/)
- Agent loop: seed session → policy
/v1/responses→ resources/step→ verify; options such asrender_last_n_obs, transitions vs flattened output, etc.
Rollout collection (nemo_gym/rollout_collection.py)
+debug_each_step=true: sendsdebug_each_stepon eachPOST /runbody.cube_agentattachesdebug_step_eventsat the top level of the verify payload (not inside the OpenAI-shapedresponseobject) so it survives JSON round-trip.ng_collect_rolloutsprints one line per step on the client terminal, then removesdebug_step_eventsbefore writing JSONL.+debug=truestays separate: per-/runtiming, tqdm, aiohttp request debug, logging.
Schemas
CubeAgentVerifyRequest/CubeAgentVerifyResponse: optionaldebug_step_events.cube_agent:_cube_rolloutreturns(response, events);run()mergesdebug_step_eventsinto the verify request.
Tests
resources_servers/cube/tests/test_server_shutdown.py:close_all_open_environmentscloses tasks and clears maps.- Additional tests under
resources_servers/cube/tests/andresponses_api_agents/cube_agent/tests/as applicable.
How to verify
- Bring up services per
resources_servers/cube/README.md. - Run
ng_collect_rolloutswith+debug_each_step=true(and optionally+debug=true) and confirm per-step lines on the collect_rollouts process stdout. - Stop the CUBE resources server gracefully (Ctrl+C / SIGTERM) and confirm environments / QEMU teardown behaves as expected (subject to CUBE/OS timing).
Limitations
- SIGKILL,
kill -9, and OOM kills cannot run Python teardown. - Uvicorn uses a short graceful shutdown window; in-flight HTTP handlers may still race shutdown.
- Aggregate metrics may show
mean/debug_each_stepbecause the boolean flag can appear on verify payloads; that is independent of per-step event printing (which relies on top-leveldebug_step_events).
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.
Hey Felipe — great work on this integration, the overall design is solid.
One note on resources_servers/cube/domains/osworld/bootstrap.py: I'm assuming this file is here for rapid iteration on your side, which totally makes sense. Just confirming we'll take ownership of this layer on the CUBE side.
osworld-cube already exposes the standard CUBE benchmark pattern, so the 90 lines of manual wiring here can be replaced with:
from osworld_cube.benchmark import OSWorldBenchmark, OSWorldTestSet
from osworld_cube.computer import ComputerConfig
benchmark = OSWorldBenchmark(
default_tool_config=ComputerConfig(action_space=..., require_a11y_tree=True),
test_set_name=OSWorldTestSet.TEST_SMALL,
)
benchmark.setup()
task_configs = list(benchmark.get_task_configs())
OSWorldBenchmark already handles VM backend instantiation, repo cloning, metadata loading, and task config generation internally. The _import_class, _parse_test_set, _cfg_extra helpers, ComputerConfig construction, and vm_backend wiring are all things benchmark.setup() takes care of.
We're opening a PR on cube-standard to expose a CubeResourcesServer that wraps this — so from NemoGym's side you'll just import it and point your YAML config at it. The domains/ directory and registry can then go away entirely.