Repository navigation
feat: GRL Sokoban Gymnasium Environment - #1330
Merged
Merged
Conversation
Signed-off-by: Yixin Huang <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
yixinhuang48
approved these changes
May 15, 2026
bxyu-nvidia
previously approved these changes
May 15, 2026
Signed-off-by: cmunley1 <[email protected]>
khazic
pushed a commit
to khazic/Gym-lao
that referenced
this pull request
Oct 13, 2026
…eep agent_ref on --agent (NVIDIA-NeMo#4544) ## What does this PR do? The `gym env start` commands in the GRL Sokoban and GRL Tetris READMEs now start the servers. Before this change both aborted at startup with a `GymnasiumAgentConfig` validation error, before any model call. With startup fixed, the README flow reached a second bug. `gym eval run --agent X` dropped `type` from each row's `agent_ref` in the materialized and rollout files, even though the row already named `X`. This PR fixes both. Fixes NVBug [6775679](https://nvbugspro.nvidia.com/bug/6775679) (Linear GYM-1016). Closes NVIDIA-NeMo#4490. ### Cause `resources_servers/grl_sokoban/README.md:16` and `resources_servers/grl_tetris/README.md:17` pass `--config responses_api_agents/gymnasium_agent/configs/gymnasium_agent.yaml` in addition to `--resources-server`. That generic file declares a top-level `gymnasium_agent` instance with only `entrypoint: app.py`. Its name differs from the resource's own `grl_<x>_gymnasium_agent`, so Gym starts both, and the generic one fails validation because `GymnasiumAgentConfig` requires `resources_server` and `model_server`. The line came in with the READMEs themselves (NVIDIA-NeMo#1330, NVIDIA-NeMo#1331). At those commits the generic config already had no references and the agent config already required them, so the command never worked. `gym eval run --agent X` sets `agent_map._default = X` (`nemo_gym/rollout_collection.py:1564`). The agent_map branch of `_preprocess_rows_from_config` then rewrote `agent_ref` to `{"name": X}` for every row, including rows already routed to `X`. This contradicts the fan-out path a few lines later, which keeps the row's `agent_ref` dict byte-for-byte. GRL example rows carry `{"type": "responses_api_agents", "name": "grl_<x>_gymnasium_agent"}`, so the README's `--agent` command lost `type`. The rewrite came in with NVIDIA-NeMo#2710. ### Fix 1. README: remove the extra `--config` line from both commands. Each resource config already ships a bound `grl_<x>_gymnasium_agent` (resource, `policy_model`, `max_steps: 20`), so `--resources-server <name>` alone is the full recipe. The blackjack and wordle READMEs already use this form. 2. `rollout_collection.py`: restamp `agent_ref` only when agent_map actually re-routes the row (`mapped != agent_name`). Re-routes still restamp and warn as before. New test `TestAgentMapRouting::test_agent_name_matching_row_keeps_agent_ref_dict` fails before this change (`{'name': 'x'}`) and passes after; `test_agent_name_reroute_restamps_clean_agent_ref` pins that a real re-route still writes a clean `{"name": new}` (the old agent's `type` is not carried over). ### Before the fix Gym `f054cf644` (main), README command (model endpoint values are local placeholders; startup fails before any model call): ```bash gym env start \ --model-type openai_model \ --config responses_api_agents/gymnasium_agent/configs/gymnasium_agent.yaml \ --resources-server grl_sokoban ``` ```text 0 / 6 servers ready. Waiting for servers to spin up: ['gymnasium_agent', 'gymnasium_agent_environment_server', 'grl_sokoban', 'grl_sokoban_gymnasium_agent', 'grl_sokoban_environment_server', 'policy_model'] ... pydantic_core._pydantic_core.ValidationError: 2 validation errors for GymnasiumAgentConfig resources_server Field required [type=missing, input_value={'entrypoint': 'app.py', ...ame': 'gymnasium_agent'}, input_type=dict] model_server Field required [type=missing, input_value={'entrypoint': 'app.py', ...ame': 'gymnasium_agent'}, input_type=dict] ... RuntimeError: Process `gymnasium_agent` finished unexpectedly! (exit 1) ``` `grl_tetris` fails the same way. ### After the fix Gym `ea41df3a2` (README commit on this branch), the README's corrected command: ```bash gym env start \ --model-type openai_model \ --resources-server grl_sokoban ``` ```text 2 / 4 servers ready. Waiting for servers to spin up: ['grl_sokoban', 'grl_sokoban_gymnasium_agent'] All 4 / 4 servers ready! Polling every 60s ``` `grl_tetris`: `All 4 / 4 servers ready!` `agent_ref` in `example_rollouts_materialized_inputs.jsonl` after `gym eval run --no-serve --agent grl_sokoban_gymnasium_agent --input resources_servers/grl_sokoban/data/example.jsonl ...`: ```text before: {'name': 'grl_sokoban_gymnasium_agent'} after: {'type': 'responses_api_agents', 'name': 'grl_sokoban_gymnasium_agent'} ``` ### Validation - QA testcases `grl_sokoban`, `grl_tetris` (full README flow with a hosted model, all 5 examples, 20-turn budget): on `f054cf644` both FAIL (`rollout agent identity: expected {'type': 'responses_api_agents', 'name': 'grl_<x>_gymnasium_agent'}, got {'name': ...}`); on `d7bb77ebd` both PASS. One earlier tetris attempt on `d7bb77ebd` hit a hosted-model 503 (`Model ... is not ready to serve requests yet`) and was rerun. - `pytest tests/unit_tests/test_rollout_collection.py`: 432 passed. Full `tests/unit_tests` on macOS: the same 42 sandbox/telemetry/launcher failures with and without this change; none touch rollout collection - `pre-commit run --all-files`: passed - `tests/unit_tests/test_fern_docs_links.py`: 18 passed - Rollout evidence: hosted `nemotron-3.5-super-vl-preview`, 5 examples each, 0 failure rows; sokoban mean/reward 10.56, tetris 9.04, both matching the persisted rollouts; sokoban moves replayed against the seeded board. ### Compatibility README change: none. Rollout collection: rows already routed to the selected agent now keep their full `agent_ref` (e.g. `type`) in materialized and rollout files. Gym consumers key on `agent_ref.name`; ATIF export also reads `type` when present (`nemo_gym/atif_export.py:901`), so it now sees the value the data declared. Routing, re-route warnings, and rows that are actually re-routed are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: qiaochuz <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributed by @yixinhuang48
Updated version of #564