Repository navigation
feat(cli): report each entry's resources and agent servers by one rule in gym list environments - #5446
Conversation
|
/ok to test 3378284 |
8379ebf to
f649fd7
Compare
18a0415 to
66caea9
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
Server-name lookup can omit or misidentify the Resources Server for sessions-based workloads. The inline RISK describes the failure and required correction.
I reviewed all seven changed files and traced the affected CLI, discovery, parser, manifest-validation, and runtime-routing contracts. This was a static review; I couldn't execute tests.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
/ok to test 56e819e |
yaoyu-33
left a comment
There was a problem hiding this comment.
Stacked on #5392. Reports each entry's resources_server and agent_server in gym list environments --json and the inspect view by one selection rule (manifest names, then resolved config wiring, then names written in the file, then unknown), and follows the Environment Server's resources binding that the earlier automated review asked for.
The route-aware lookup holds up on what we probed: on the 468 real catalog entries it returns the same names as the previous head, and the new cases the body says fail on 66caea93 do fail there (11 of 13). No scoring, verifier or rollout path is touched. One robustness gap, one docstring/behavior mismatch, missing tests and a compatibility note are inline.
Optional, for the author to weigh:
- The lookup parses configs strictly, so 38 of the 256 entries without a manifest fall back to file names, and one entry's JSON depends on the caller's environment (
hle_diamond/opencode_referencereportsequivalence_llm_judgeonly whenTAVILY_API_KEYandPOLICY_API_KEYare set).read_config_metadataalready has a listing-tolerant parser (_parse_no_environment_tolerating_unset_values,discovery.py:79-105); in a scratch prototype, reusing it cut the fallbacks to 22 and made the output independent of those variables. The fallback is the documented rule, so this is a suggestion, not a request. _catalog_resources_servermirrors the route precedence inrollout_collection.pywithout a shared helper, and spells out"legacy_agent","environment_servers"and"resources_servers"whereglobal_config.pyhas constants. The tests requested inline are the cheapest guard against the two drifting.
Process: the red preview check fails parsing the generated judge_profile.mdx, which this PR does not touch (fixed on main by #5602), and the non-blocking harness-conformance failures (kilocode, Publish check) are unrelated.
Overall: ship with care.
| try: | ||
| wiring = _resolve_config_wiring(config_path, parser=_ServerLookupParser()) | ||
| resources_server = _catalog_resources_server(wiring) | ||
| except _CONFIG_LOOKUP_ERRORS: |
There was a problem hiding this comment.
This allowlist lets some odd configs abort the whole gym list environments --json and the inspect view, which listed them fine before this PR (the body says malformed input no longer aborts the listing). At this head, a config with policy_model: {port: 12345} raises StopIteration from the dummy-model cleanup (global_config.py:1599; the lookup merges a dummy policy_model that read_config_metadata only adds when the file has none), results_dir: "~nosuchuser/out" raises RuntimeError from expanduser, and a recursive YAML alias raises RecursionError. Could you catch Exception here, as read_config_metadata and read_environment_details already do, and log it at debug level so a bug in the new routing code does not silently turn into the file-name fallback? A regression case with the policy_model shape would pin it.
There was a problem hiding this comment.
Fixed in 6f548db. The best-effort catalog boundary now catches Exception around the complete server-name lookup, records the config path and traceback at debug level, and returns None for the existing fallback. Manifest composition still raises the original errors.
Added regressions for the policy_model port shape, failed home expansion, and a recursive YAML alias, plus list/inspect coverage containing healthy and malformed entries together. Before the fix the focused selection had 4 failures and 17 passes; afterward all 21 passed. The broader CLI/environment/manifest/public API suite passed all 1,770 tests.
| class _ServerLookupParser(GlobalConfigDictParser): | ||
| """Fails on an almost-server without printing the run-time warning, since a lookup starts nothing.""" | ||
|
|
||
| def detect_and_report_almost_servers(self, global_config_dict: DictConfig) -> list[tuple[str, ValidationError]]: |
There was a problem hiding this comment.
Could you correct the resolve_config_servers docstring ("nothing is printed") or silence the rest of the lookup's output? This subclass skips only the almost-server banner: a config whose agent has no Environment Server still prints the ~25-line "DEPRECATED: agents without an environment server" warning (global_config.py:1584), and the file-name fallback re-parses through read_config_metadata, which prints the almost-server banner again. It also raises on almost-servers when the config sets error_on_almost_servers: false, so such a config always falls back to file names. No shipped catalog entry prints anything today (stderr is empty over all 468), so this only affects custom or older-style configs.
There was a problem hiding this comment.
Addressed in 6f548db using the docstring correction option. Removed the blanket “nothing is printed” claim and documented that parser compatibility warnings and metadata fallback can still emit stderr diagnostics. The lookup deliberately rejects invalid server blocks even with error_on_almost_servers: false, rather than selecting from only the valid subset.
Added tests for an unreferenced invalid block with both true and false: lookup returns None without its almost-server banner. Runtime validation and warning behavior are unchanged.
| assert resolve_config_servers(config_path) == (expected, "simple_agent") | ||
|
|
||
|
|
||
| def test_resolve_config_servers_does_not_guess_between_environment_routes(tmp_path: Path) -> None: |
There was a problem hiding this comment.
test_environment_validation.py:202
Could you add cases for the routing branches that no test pins? Mutating each of these leaves every test in test_environment_validation.py, test_cli.py and test_registry.py green: an Environment Server that fronts only another agent, next to the real one (validation.py:386-390 and the guard at :408), environment_routing_mode: taskset with a flat dataset (:400, expecting unknown resources), the file-name fallback when the file names two different resources servers (None) or the same one twice (env.py:1034-1038), and an unreferenced almost-server (_ServerLookupParser, expecting None). A legacy route that names a missing or non-environment server, and a routed dataset next to an unroutable one, are worth adding if cheap.
There was a problem hiding this comment.
Added in 6f548db: an unrelated environment fronting another agent; an explicit route to that wrong agent, a missing instance, or a resources server; taskset-only mode with flat rows; a routed taskset followed by an unroutable flat dataset; and an unreferenced invalid server with either error_on_almost_servers value. The raw-name fallback test now covers one, repeated, and distinct resources implementation names alongside the existing agent cases, for both list JSON and inspect JSON.
The focused selection passes all 21 cases, and the broader validation passes all 1,770 tests. The tests assert the selected implementation names or unknown results, including retaining the known agent when resources are unresolved.
| gym list environments --json | jq '.[].name' | ||
| ``` | ||
|
|
||
| The inspect view and `--json` report the resources server and agent an entry runs with. An entry with a manifest takes them from the manifest. Otherwise Gym resolves which servers the config wires, without the dataset rules a manifest adds. For agent-owned datasets, this follows the taskset route, explicit flat-row route, or unique Environment Server fronting the agent. Session-based Environment Servers supply their own resources binding; `legacy_agent` relays use the agent's binding. Ambiguous routes or routes selecting different resources leave the resources field unknown. Resource-owned datasets retain their selected owner. When the config does not resolve on its own, because it needs values that only a run supplies, such as a judge model server, or because it is malformed, Gym uses the names written in the config file, each only when the file names exactly one. A server that none of these identifies is omitted from the inspect view and `null` in `--json`. |
There was a problem hiding this comment.
Could you tighten this paragraph and the compatibility note? "Without the dataset rules a manifest adds" is too strong, because resolution still needs exactly one dataset-bearing agent (so biomnibench_da and labbench2_pdf fall back to file names); "explicit flat-row route" means environment_routing_mode: legacy with environment_server_name; and the values are implementation names (simple_agent), unlike the instance name in gym list benchmarks --json's agent_name. Two entries show less than before this PR and are not in the compatibility section: resources_servers/legal_agent_bench no longer reports its resources server (an unbound agent behind a legacy_agent relay, which looks intended) and swe_together/opencode no longer reports an agent (it has two). Also worth stating there: the --json listing takes about 5 s more CPU over the full catalog (roughly double), and Python callers of discover_environment_catalog() still get None for resources_server/agent_server on entries without a manifest.
There was a problem hiding this comment.
Updated the CLI reference and PR compatibility section in 6f548db. They now state the remaining dataset-owner/agent requirement, spell out environment_routing_mode: legacy with environment_server_name, distinguish implementation names from benchmark agent_name instance names, and describe the Python discovery API boundary.
The compatibility section explicitly records the omitted legal_agent_bench resources binding and the ambiguous swe_together/opencode agent during raw-name fallback. It also attributes the approximately five extra CPU seconds over 468 entries to your measurement at 56e819e, rather than presenting it as a fresh measurement of this head. Fern validation passed with zero errors; only the unauthenticated redirect check was skipped.
c103d1e to
3dd1833
Compare
56e819e to
3c7ec0c
Compare
3dd1833 to
763a10b
Compare
3c7ec0c to
328ec09
Compare
The inspect view read servers from the config file's text, which misses a resources server the file inherits (aime24 showed none instead of math_with_judge), while --json resolved the config. Both views now take the manifest's servers, else the resolved config's, else the names the config file states when it states exactly one of a kind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yuhe Zhang <[email protected]>
Looking up an entry's servers went through the manifest resolver, which also converts datasets to manifest form. A benchmark without prepare_script, which Gym runs, raised a pydantic ValidationError, and a malformed config raised OmegaConf or decoding errors; neither was caught, so one such entry stopped gym list environments --json and its inspect view. The lookup now resolves only the wiring, falls back on any error a config file can cause, and fails on an almost-server without printing the run-time warning. Manifest validation is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yuhe Zhang <[email protected]>
A field of the wrong type, such as `config_paths: 1`, `_inherit_from: 1` or a server block that is a string, made Gym's config parser raise TypeError or AttributeError, which the server lookup did not catch. An agent with `datasets: 1` made the scan of the file's server names raise while iterating the number. Either stopped `gym list environments --json` for every entry. The lookup now treats those errors as "does not resolve", and the scan skips a datasets value that is not a list, as its docstring promises. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yuhe Zhang <[email protected]>
… list Discovery looped over an agent's `datasets` in each resources-server config to decide whether it is runnable. A config with `datasets: 1` raised TypeError there and stopped catalog discovery, so every listing failed. This has been on main since #2443; the listing tests in this PR now cover it. Discovery and the file scan behind the inspect view now share one helper that returns the dataset blocks a server declares, and none when `datasets` is not a list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yuhe Zhang <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
6f548db to
165aa3d
Compare
|
/ok to test 165aa3d |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42347582262 |
…ools Brings in 42 commits from main (bd6f5f0..363af5e), including #5709 (centralized resources lifecycle and verification ownership), #5551 (MCP tools of extra tool servers granted to session agents), #5763 (HLE agent loop bounded with max_steps 1) and #5446 (gym list environments). Only README.md overlapped textually; the environment table was regenerated with scripts/update_env_list.py and the Hle Web Tools row is preserved. Signed-off-by: Rima Shahbazyan <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
Stacked on #5392; merge that first. This PR targets its branch so the diff contains only the server-name changes. Supports #3946; no separate issue is needed for this focused catalog improvement.
What and why
gym list environments --jsonnow includesresources_serverandagent_server. List and inspect use the same selection rule:environment_routing_mode: legacywithenvironment_server_name), or the unique Environment Server fronting the agent. Session-based Environment Servers supply their resources binding;legacy_agentrelays use the agent's binding. Resource-owned datasets retain their selected owner.nullin list JSON and omitted from inspect output. Successfully resolved but ambiguous, conflicting, or unbound resources routes stay unknown without falling back to raw names.For example, a session-based Environment Server using
demoreportsdemoeven if its agent has no resources binding or still names another server. Conversely, a malformedpolicy_model: {port: 12345}no longer aborts the entire catalog: the lookup records a debug traceback and uses the existing fallback. Lookup catches ordinary exceptions at this best-effort boundary; manifest validation keeps its existing errors. Discovery and inspection share defensive dataset-shape handling.The lookup suppresses its own almost-server banner and rejects invalid server blocks even with
error_on_almost_servers: false. Other parser compatibility warnings and metadata fallback diagnostics can still go to stderr; the docstrings now state that accurately.Compatibility
simple_agent, unlikeagent_nameingym list benchmarks --json, which identifies a config instance.resources_servers/legal_agent_benchno longer reports the resources server its agent does not bind; whenswe_together/opencodefalls back to raw names, its two distinct agent implementations leave the agent unknown instead of choosing the first.biomnibench_daandlabbench2_pdfenvironment configs, still fall back to names written in the file.56e819ec96d0edfd6bd36dec1f8fda92c0d56da8found approximately five extra CPU seconds over 468 entries, roughly doubling that listing's CPU time. This is the reviewer's measurement of that revision, not a fresh benchmark of the current head.discover_environment_catalog()still receiveNonefor both server attributes on entries without manifests; CLI resolution does not mutate those objects.read_environment_detailshelper returns anagentslist instead of the firstagent, preserving ambiguity. Manifest composition, explicitdataset_ownerhandling, rollout execution, and benchmark results are unchanged.Validation
Validation at
6f548db19da17f049ad92148f117a33ce46b0b07with Python 3.13.14 and locked development dependencies:pytest tests/unit_tests/cli/test_cli.py tests/unit_tests/cli/test_cli_main.py \ tests/unit_tests/environment/test_registry.py \ tests/unit_tests/environment/test_environment_validation.py \ tests/unit_tests/environment/test_environment_manifest.py \ tests/unit_tests/environment/test_environment_scaffold.py \ tests/unit_tests/environment/test_environment_publication.py \ tests/unit_tests/test_moved_paths.py tests/unit_tests/test_public_api.py \ tests/unit_tests/test_public_api_facades.py tests/unit_tests/test_import_linter_coverage.py \ tests/unit_tests/config/test_environment_resources_binding.py \ -q -o addopts='' -o log_cli=false21336149.3completed with exit0:0.328ec09e297fc1aba321039b99f5d04ca9ee5bcb; all 21 passed after the fix. This coversStopIteration, home-expansionRuntimeError, and recursive-aliasRecursionError, debug traceback retention, and unchanged strict manifest errors. The list/inspect integration regression includes healthy and malformed entries together.error_on_almost_servers.pre-commit run --all-files: passed. The guardwords hook skipped its private scan because the private catalog was unavailable locally.cd fern && npm run check -- --warnings: zero errors; one warning that authenticated missing-redirect checking was skipped because no Fern login was available.Rollout evidence: N/A. This changes CLI/catalog error handling and metadata only; no agent execution, model inference, or verifier behavior changes.