Repository navigation
fix(cli): check Environment Server configs in gym env validate - #5008
Merged
Merged
Conversation
`gym env validate` and `gym env resolve` checked only type-level fields and server references. An Environment Server block was checked against its server's own config class only when `gym env start` launched that server, after the other servers were up. A `single_agent_turn_legacy` block without `resources_server` therefore passed validation and failed at launch. Validate now imports each Environment Server entrypoint, takes the config class of the server class it calls run_webserver() on, and validates the block as load_config_from_global_config does at launch. It reports every invalid field by its path in the merged config and exits 1. A server whose entrypoint does not import in the gym environment gets a warning and is left to its launch. `gym env resolve` still prints the config and reports the same fields as a warning. Because the schema comes from the server's own code, the check follows changes such as #4952's optional resources_server without edits. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test a9f1f31 |
Contributor
yaoyu-33
marked this pull request as ready for review
October 28, 2026 22:21
Skip top-level mappings without a recognized server type before indexing their contents. Cover validate and resolve with empty and nested-empty auxiliary overrides, including preservation in resolved YAML. Validation: all four regression cases fail before the fix and pass after it. test_cli.py, test_cli_main.py and test_ray_opt_out.py: 445 passed; one Linux-procfs memory-profiler test fails on macOS, reproduced with the original PR code. pre-commit run --all-files passed. No model rollout needed for offline configuration handling. Signed-off-by: yaoyu-33 <[email protected]>
weijiac0619
approved these changes
Oct 29, 2026
weijiac0619
enabled auto-merge
October 29, 2026 17:28
Contributor
|
/ok to test 702016e |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40958769256 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40962962022 |
This branch was previously deployed
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.
What and why
Found while test-driving the harness onboarding guide on LangChain DeepAgents (#5003). The guide relies on
gym env validateandgym env resolvebefore a real run, but neither checks an Environment Server block against its server's own config class. That check happens only inload_config_from_global_config, whengym env startlaunches the server, after the other servers are already up.Reproduction on
main: inresources_servers/reasoning_gym/configs/reasoning_gym_langchain_deepagents_agent_model_server.yaml, switch thelegacy_agentblock tosingle_agent_turn_legacywithout adding its other fields. Before this PR:gym env startthen failed at that server's launch with pydantic'sSingleAgentTurnEnvironmentServerConfig … Field required. With this PR:(exit 1). Each line is the field's full path in the merged config, so it can be fixed in the YAML or with a
++override.cleanup_timeout_secondsis reported too, because the launch would reject the block for it as well.Changes
gym env validate(nemo_gym/cli/env.py): for each Environment Server, it imports the server's entrypoint, finds the config class of the server class the entrypoint callsrun_webserver()on, and validates the block against it exactly asload_config_from_global_configdoes at launch. Every invalid field is reported, and the command exits 1 withEnvironmentServerConfigError, a newConfigError.gymenvironment (because its own venv has a package this one lacks) is not an error. Validation warns that it could not check that server and leaves the check to its launch.gym env resolvestill prints the config, since it is a debugging tool, and reports the same fields as a warning on stderr.nemo_gym/server_utils.py:entrypoint_server_class_names()is factored out ofentrypoint_class_flag(), soray_enableddetection and this check use the same rule to find the launched class.reference/cli-commands.mdx(validate and resolve) and a new troubleshooting entry, "Environment Server Config Does Not Match Its Server".Why import instead of a static schema
Environment Servers ship with Gym, and all six shipped ones import in Gym's development environment, so the config class comes straight from the server's code. A copied or AST-derived schema would drift from it. Resources servers and agents are out of scope: their entrypoints pull in heavy, venv-only dependencies.
Coordination with #4952
#4952 makes
SingleAgentTurnEnvironmentServerConfig.resources_serveroptional, so the server falls back to its agent's resources server. This check reads the config class from the server's code, so it follows that change without edits. With #4952's field change applied locally, the reproduction above (whose agent namesreasoning_gym) passes validation, which matches the fallback. Onmainit still reports the field. The regression tests use only fields that stay required under #4952 (cleanup_timeout_seconds, plus a misspelled field), so they pass on both. #4952's other new check, that neither the server nor its agent names a resources server, runs in the server'smodel_post_init, which this offline check does not run.Validation
tests/unit_tests/test_cli.py::TestValidate, 3 new tests against the realvalidate()parse path:single_agent_turn_legacyblock missingcleanup_timeout_secondsand with a misspelledresources_tool_transportexits 1 and names both full field paths and the config class;With the check disabled, the first and third fail.
Same
TestValidatewith feat(scripts): switch simple_agent relays to single_agent_turn_legacy #4952'sresources_server: ResourcesServerRef | None = Noneapplied locally: 5 passed.Sweep over every shipped config with an
environment_serversblock (538 files, each withopenai_model.yaml): 450 parse, and all 450 pass the new check, with no false positives and no server that fails to import. The other 88 fail to parse before reaching the check (missing secrets or interpolations, configs that need companion files), as they do onmain.Time: the check takes about 0.01 s in-process on the original reasoning_gym config.
gym env validateon it takes about 4 s end to end.pytest tests/unit_tests -n 8(macOS): 10157 passed, 40 failed, 2 collection errors. Rerunning those 42 on unmodifiedmaingives the same failures (OpenSandbox, Slurm launcher, wandb and telemetry imports in this local environment). The exceptions are twotest_docker_compose.pycases that pass when run alone either way, and atest_harbor_package_store.pysocket test that passes and fails on reruns of the same code.test_cli.py,test_cli_main.pyandtest_ray_opt_out.py, which coverentrypoint_class_flag, pass excepttest_memory_profiler_uses_spawned_server_metadata, which also fails onmainhere.pre-commit run --all-files: clean.fern check: 0 errors.Rollout evidence
N/A: this changes only offline config checks (
gym env validateandgym env resolve). It does not change how servers launch or how episodes run. The CLI reproduction above uses the shipped DeepAgents config.Compatibility
A config whose Environment Server block
gym env startwould reject now failsgym env validate(exit 1) instead of passing.gym env resolvekeeps exit 0 and only adds a stderr warning. Valid configs are unaffected, as the sweep shows.🤖 Generated with Claude Code