Skip to content

fix(grl): start GRL READMEs without the unbound gymnasium_agent and keep agent_ref on --agent - #4544

Merged
ananthsub merged 3 commits into
mainfrom
qiaochuz/nvb-6775679-grl-readme-gymnasium-config
Oct 12, 2026
Merged

ananthsub merged 3 commits into
mainfrom
qiaochuz/nvb-6775679-grl-readme-gymnasium-config

Conversation

@qiaochuz-nv

@qiaochuz-nv qiaochuz-nv commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 (Linear GYM-1016). Closes #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 (#1330, #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 #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):

gym env start \
    --model-type openai_model \
    --config responses_api_agents/gymnasium_agent/configs/gymnasium_agent.yaml \
    --resources-server grl_sokoban
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:

gym env start \
    --model-type openai_model \
    --resources-server grl_sokoban
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 ...:

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

qiaochuz-nv and others added 3 commits October 12, 2026 11:55
…ommands

The GRL Sokoban and Tetris READMEs passed the generic
gymnasium_agent.yaml to gym env start. That file defines an extra
gymnasium_agent instance with no resources_server or model_server, so
GymnasiumAgentConfig rejects it and startup aborts. Each resource config
already ships a bound <resource>_gymnasium_agent, matching the blackjack
and wordle READMEs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
…s own agent

gym eval run --agent X sets agent_map._default = X, and the agent_map
branch rewrote every row's agent_ref to {"name": X} even when the row
already named X. That dropped extra fields such as type from the
materialized and rollout rows. Restamp only on a real re-route, matching
the fan-out path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
@qiaochuz-nv qiaochuz-nv added bug Something isn't working QA_fix Fix implemented by a QA team member area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters needs-review PR is ready for code review and waiting on a reviewer complexity:low Localized change in one scope with a small, straightforward review surface labels Oct 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 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.

@ananthsub

Copy link
Copy Markdown
Contributor

/ok to test a8c36b0

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38308835709

Merged via the queue into main with commit 124accc Oct 12, 2026
53 of 55 checks passed
@ananthsub
ananthsub deleted the qiaochuz/nvb-6775679-grl-readme-gymnasium-config branch October 12, 2026 21:23

This branch was previously deployed

1 inactive deployment
public — a8c36b08 Deployed Oct 12, 2026 by copy-pr-bot[bot] via release / finalize / notify #5096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer QA_fix Fix implemented by a QA team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NVBug 6775679] Drop redundant gymnasium_agent --config from GRL Sokoban/Tetris READMEs

2 participants