Repository navigation
fix(scaffold): move a reused scorer's environment server with its agent - #4085
Conversation
`gym env init --reuse-verifier <scorer>` derives the workload's agent with `_inherit_from: <scorer>_simple_agent`, which moves that agent. Since #3724 every shipped scorer config also bundles `<scorer>_environment_server` naming the original agent, so the generated workload failed `gym env validate` with a dangling `agent_server` reference. Inherit the scorer's environment server under the workload's own name and point it at the renamed agent, as the shipped benchmarks that reuse a scorer do, so each agent keeps exactly one environment server. A workload named after its scorer inherits under `<name>_catalog_environment_server`, so several workloads reusing one scorer can run together. Reject reused configs whose agent has several environment servers, whose server is itself derived with `_inherit_from` or `_copy`, or whose server is a taskset route target. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
|
/ok to test bc1fcd5 |
POR Test Summary — Reused Scorer Environment ServerVerdict: PASS — clean red-before / green-after regression A new black-box QA case runs the documented benchmark scaffold command against both shipped fixture-bearing scorers and requires the generated workload to pass static validation.
The case also verifies that each generated manifest still names the reused scorer, so the green result cannot come from silently replacing or dropping the requested verifier.
The QA registry intentionally remains expected-fail against main until this fix lands; after merge, that metadata can be flipped to the normal passing state. |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37705352991 |
…s agent (4085)` into `r0.7.0` (#4203) beep boop [🤖]: Hi @qiaochuz-nv 👋, we've cherry picked #4085 into `r0.7.0` for you! 🚀 Please review and approve this cherry pick by your convenience! Signed-off-by: qiaochuz <[email protected]> Signed-off-by: NeMo Bot <[email protected]> Co-authored-by: Qiaochu Zhu US <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: kajalj22 <[email protected]>
|
Retrospective QA-fix tracking issue: #4356. It records the fix authored by @qiaochuz-nv and delivered by this merged PR. |
What does this PR do?
gym env init --reuse-verifier <scorer>now produces a workload that validates and runs when the scorer's config bundles an agent behind an environment server. Every shipped scorer that exportsVERIFIER_FIXTUREdoes since #3724, so the documented reuse command in the New Environment guide failed for all of them:Cause
The scaffold derives the workload's agent with
_inherit_from: <scorer>_simple_agent, which moves that agent to the new name. #3724 added<scorer>_environment_serverto every shipped scorer config, naming the original agent, and made the scaffold write a fresh<name>_environment_server. After the move, the scorer's server named an agent that no longer existed.Running the same repro against Gym before and after #3724 confirms the window:
65943edd(its parent) validates, and016bb6b8(#3724) fails. Every later commit through325fb49dfails too.test_reuse_supports_a_bundled_default_agentdid not catch it because its synthetic scorer has no environment server.Fix
When the reused config has an environment server in front of its bundled agent, the scaffold moves that server with the agent. It inherits the server under the workload's name and points it at the renamed agent:
This is the shape the shipped benchmarks that reuse a scorer already use (for example
benchmarks/aegis_v4_safety/config.yaml), and theINHERITEDblock inscripts/add_legacy_agent_environment_servers.py. Each agent ends up behind exactly one environment server, which rollout collection requires (AmbiguousEnvironmentServerErrorotherwise).Two alternatives were tried and rejected:
error_on_agent_without_environment_server. Inheriting gives each workload its own server. This also applies to a workload named after its scorer: it now inherits under<name>_catalog_environment_server, mirroring the existing<name>_catalog_agentfallback.The scaffold now rejects three reused configs it cannot inherit safely, each with an error that says to compose the config by hand:
_inherit_fromor_copy(inheriting it again leaves its own source unresolved);environment_server_routesin the reused config names that server (inheriting retires the name).No config in the repository hits any of these. Reused configs without a bundled environment server keep the previous behavior, a fresh
legacy_agentserver.Related work
environment_server_routesuses. This PR does not touch the files feat(config): support environment servers that front several agents #4053 changes. The scaffold inherits instead because of the multi-workload case above, and it refuses the routed case rather than renaming a routed server._agent_reference_fieldsuses the same reference rule that feat(config): support environment servers that front several agents #4053 introduces asenvironment_server_agent_refs:agent_servermay omit its type, and any other field must be typedresponses_api_agents.r0.7.0contains both [3/4] feat(environments): add profile-aware scaffolding #2442 and feat: add legacy environment servers #3724, so the release branch has the same defect. This fix is a cherry-pick candidate.Known limitation, unchanged
With
--profile custom-gym-agent-looporexternal-agent-loop, reusing a scorer that bundles an agent still fails validation (AlmostServerError). The generated agent adds a second implementation key to the inheritedsimple_agent. This fails onmaintoo, is independent of this change, and is left for a separate fix.No GitHub issue exists. NeMo Gym QA found this while adding coverage for the onboarding commands from #1029; an NVBug is being filed with the same repro.
Validation
tests/unit_tests/test_environment_scaffold.py: 14 new or extended reuse tests. Each one resolves the generated config as a run does, witherror_on_agent_without_environment_server: true, and checksrollout_collection._environment_servers_by_agent. They cover the following:agent_serverreferences;13 of the new tests fail against
main'sscaffold.py. 9 fail against a first draft of this fix that repointed in place for a workload named after its scorer.pytest tests/unit_tests/test_environment_scaffold.py tests/unit_tests/test_global_config.py tests/unit_tests/test_cli_main.py tests/unit_tests/test_cli.py tests/unit_tests/test_environment_validation.py tests/unit_tests/test_environment_onboarding.py tests/unit_tests/test_environment_publication.py tests/unit_tests/test_add_legacy_agent_environment_servers.py: 657 passed.pre-commit run --all-files: all hooks pass.Standalone repro, run on
mainand on this branch:example_single_tool_callandequivalence_llm_judge.gym env validate.Rollout evidence
The live smoke test ran against this branch, using the
inference_providermodel type withnvidia/nvidia/Nemotron-3-Nano-30B-A3B:gym env init --environment qa_reuse_smoke --reuse-verifier example_single_tool_call --reward-range 0 1 --higher-is-better, with the sample row replaced by one row from the scorer's owndata/example.jsonl.gym env validate qa_reuse_smoke.gym env start --environment qa_reuse_smoke --search-dir <workspace>.gym eval run --no-serve --agent qa_reuse_smoke_agent --limit 1.Results:
example_single_tool_call,qa_reuse_smoke_agent,qa_reuse_smoke_environment_server, andpolicy_model.get_weather.The QA suite case that runs the documented reuse command for both shipped fixture scorers fails on
mainand passes on this branch.Compatibility and docs
gym env init --reuse-verifiernow generates a config with an inherited environment server. Workloads previously generated this way did not validate, so nothing that worked before changes. No runtime, config-engine, or benchmark-result change.🤖 Generated with Claude Code