Skip to content

feat: add legacy environment servers - #3724

Merged
marta-sd merged 23 commits into
mainfrom
ananthsub/episode-orchestration-09-legacy-adapter
Sep 29, 2026
Merged

marta-sd merged 23 commits into
mainfrom
ananthsub/episode-orchestration-09-legacy-adapter

Conversation

@ananthsub

@ananthsub ananthsub commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds compatibility Environment Servers before environment-specific Resources and Agent migrations:

  • legacy_agent relays existing Agent /run and /aggregate_metrics contracts without interpreting them.
  • single_agent_turn_legacy converts legacy flat rows to the single-agent-turn protocol and returns its result in the legacy result shape, adding only agent_ref.
  • Config composition, Agent swapping, scaffolding, migration tooling, and repository configs route existing Agents through compatibility deployments.

Rollout collection routes each flat row to the Environment Server that fronts its Agent. The Agent-to-Environment-Server map is built once, and every Agent in a batch is resolved before any rollout is dispatched. An Agent fronted by several Environment Servers raises AmbiguousEnvironmentServerError before dispatch, instead of silently sending every row to the first one in config order. Several Environment Servers may still front one Agent when no row routes by that Agent.

Compatibility flow

This is the compatibility flow for existing single-agent environments. Other Environment Servers may coordinate different participants.

sequenceDiagram
    participant C as RolloutCollector
    participant E as LegacyEnvironmentServer
    participant A as ExistingAgentServer

    C->>E: POST /run with legacy row
    E->>A: Relay existing /run
    A-->>E: Existing result body
    E-->>C: Unchanged result body
Loading

Stack position

Part 2 of 6. Previous: #3717. Next: #3718.

No issue is linked because this is one layer of the Environment Server stack.

Validation

  • uv run pytest tests/unit_tests/test_global_config.py tests/unit_tests/test_rollout_collection.py -q
  • uv run pytest environment_servers/single_agent_turn_legacy/tests/test_app.py -q
  • uv run pytest environment_servers/legacy_agent/tests/test_app.py -q
  • The rollout collection tests check that an ambiguous Agent fails before any request is sent, and that twin Environment Servers for an Agent no row uses do not interfere.

Rollouts

example_single_tool_call with Simple Agent was run through legacy_agent against a real model. The relay returned the same status, result fields, and Set-Cookie as calling the Agent's /run directly, and passed a malformed request's 422 through unchanged. End-to-end evidence for the whole stack is on #3722.

Compatibility and migration impact

Every runnable Agent instance now needs an Environment Server in front of it. Out-of-tree configurations, including NeMo RL configurations, must add a legacy_agent deployment or run scripts/add_legacy_agent_environment_servers.py. Legacy request and result bodies do not change.

A run whose rows route by an Agent that several Environment Servers front now fails before dispatch with an error naming the candidates.

@ananthsub
ananthsub added this pull request to stack #3725 September 28, 2026 15:43
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team September 28, 2026 15:43
@yaoyu-33 yaoyu-33 added area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Sep 28, 2026
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-09-legacy-adapter branch from de5d9b0 to a2542b5 Compare September 28, 2026 15:48
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-09-legacy-adapter branch from 3f27818 to fc39502 Compare September 28, 2026 18:49
marta-sd and others added 10 commits September 29, 2026 10:57
Benchmarks that landed after the last sweep declare an agent with no environment
server, which rollout collection cannot reach.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
…an environment server

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
… servers

A flat row routes to the environment server that fronts its agent.
The lookup returned the first server in config order, so a second
server for the same agent silently received no rows or aggregation.
It also rescanned the whole config for every dispatched row.

Build the agent-to-server map once and resolve every agent before
dispatch. An agent with several servers now raises
AmbiguousEnvironmentServerError before any rollout starts; twin servers
for an agent that no row routes by remain valid. Aggregation reuses
the same map.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
SingleAgentTurnResult is now the verify response itself, so the legacy
projection dumps the result directly and adds only agent_ref.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
…cit task IDs

Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marta Stepniewska-Dziubinska <martas@nvidia.com>
@marta-sd
marta-sd force-pushed the ananthsub/episode-orchestration-09-legacy-adapter branch from b4e05d4 to 1af0b1c Compare September 29, 2026 08:57
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team September 29, 2026 08:57
@marta-sd
marta-sd added this pull request to the merge queue Sep 29, 2026
@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/36548336483

This branch was previously deployed

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

Labels

area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Milestone 2: legacy compatibility processor

4 participants