Skip to content

feat(scaffold): generate single_agent_turn instead of a legacy_agent relay - #6037

Draft
yaoyu-33 wants to merge 1 commit into
mainfrom
yuya/scaffold-single-agent-turn
Draft

yaoyu-33 wants to merge 1 commit into
mainfrom
yuya/scaffold-single-agent-turn

Conversation

@yaoyu-33

Copy link
Copy Markdown
Contributor

What

gym env init now generates the single_agent_turn Environment Server with a typed taskset, instead of a legacy_agent relay in front of the agent.

New benchmarks are meant to run through an Environment Server's agent sessions, and a legacy_agent /run relay is not allowed in new work. The docs that teach this path (#6031, #6032) still had to tell readers to replace the relay the scaffold wrote. With this change, the generated config and the tutorials agree.

Generated shape (all scaffolds except the ones noted below):

config_paths:
  - environment_servers/single_agent_turn/configs/single_agent_turn.yaml
environment_server_routes:
  <name>_example: <name>_environment_server        # one route per dataset taskset
<name>_resources_server:
  resources_servers:
    <name>:
      datasets:
      - name: example
        type: example
        taskset: <name>_example
        ...
<name>_simple_agent:                                # no datasets on the agent
  responses_api_agents:
    simple_agent: {...}
<name>_environment_server:
  _inherit_from: single_agent_turn
  environment_servers:
    single_agent_turn:
      resources_server: {type: resources_servers, name: <name>_resources_server}
      agent_server: {type: responses_api_agents, name: <name>_simple_agent}
      resources_tool_transports: [direct_http]

Changes in nemo_gym/environment/scaffold.py:

  • --resources-server NAME. Train, validation and example each get their own taskset (<name>_train, <name>_validation, <name>_example). Rows without an explicit id get positional task ids that restart in each split, so a shared taskset would give different train and validation tasks the same identity.
  • --environment / --benchmark. The example dataset routes as <name>_example and the benchmark dataset as <name> (the taskset benchmark preparation already defaults to).
  • --reuse-verifier. If the reused config bundles an Environment Server in front of its agent, the workload still inherits that server, unchanged, with flat rows and no taskset. If it bundles none, the workload gets the same single_agent_turn server, bound to the reused resources server.
  • external-agent-loop keeps its legacy_agent relay. This profile's agent runs the whole episode in run() and is told to make responses() raise NotImplementedError. Agent sessions call only /v1/agent_sessions and /v1/responses, never /run, so under single_agent_turn this agent could not run. Moving the profile to agent sessions needs a different agent template and a different profile inference rule in validation.py; that belongs in its own PR. custom-gym-agent-loop does move: its agent subclasses SimpleAgent and overrides responses(), which is the handler the session route calls, and it inherits the session hooks.
  • YAML output. The workload config is now dumped one top-level block at a time. The old code inserted a blank line by splitting the text at the first occurrence of <name>_agent. With the new config path, that split corrupted environment_servers/single_agent_turn/... for names such as single or e.

fern/.../contribute/environments/new-environment.mdx described the relay the scaffold generated. It now describes single_agent_turn and the external-agent-loop exception, and adds the collate step a standalone server's smoke needs: single_agent_turn takes typed rows, so --agent with the flat example.jsonl no longer works. This PR doesn't touch the pages #6031 and #6032 edit.

No issue: this follows from the review rule for new benchmarks and from the docs PRs above.

Compatibility

  • Configs that gym env init generated before this change are unchanged and keep working.
  • To smoke a newly scaffolded standalone resources server, first collate the rows: gym dataset collate --resources-server NAME --mode example_validation --output-dir DIR. Then run gym eval run --no-serve --resources-server NAME --input DIR/example.jsonl. --agent NAME_simple_agent with flat rows no longer applies. The generated config's comment gives the collate command.

Validation

  • tests/unit_tests/environment/test_environment_scaffold.py: 78 passed. Locally, test_generated_python_passes_repo_lint_and_format fails identically on origin/main, because the local venv's ruff (0.12.11) sorts imports differently from the repo's pin. This PR changes no generated Python.
    • New test_scaffold_routes_its_taskset_through_single_agent_turn, run for every kind × profile. It resolves the generated config the way a run does, and checks the route, the dataset taskset, the inherited single_agent_turn block (entrypoint, bindings, direct_http), that the base single_agent_turn instance moves rather than starts, and that resolve_dataset_agent reaches the agent through the route. For external-agent-loop it checks the relay, with no taskset and no routes.
    • New test_scaffold_named_like_part_of_a_config_path_keeps_that_path covers the names single and e.
    • Updated standalone tests check every split's taskset, route and resolved agent, and the resolved single_agent_turn block. Updated reuse tests check the single_agent_turn server for a reused config without a bundled server, and that an inherited server gets no taskset.
  • test_environment_onboarding.py (13 passed) and test_environment_publication.py (11 passed), which build on the scaffold.
  • Configs from a scratch scaffold (standalone demo, benchmark bench, environment single on custom-gym-agent-loop, environment ext on external-agent-loop, benchmark drv on external-rollout-driver):
    • gym env validate --config <config>: valid for all five. --config checks each Environment Server block against SingleAgentTurnEnvironmentServerConfig. A config with a misspelled resources_tool_transports is rejected.
    • gym env validate --manifest <workload>/manifest.yaml: valid for the four workloads. The inferred profiles and warnings are the same as before (template agents still delegate to super()).
    • gym dataset collate --mode example_validation: the standalone and environment example rows become {"task_id": {"taskset": "demo_example", "task_id": "0"}, "task_input": {...}} (and single_example).
  • pre-commit run --all-files: passed. Commits are DCO signed off.

Rollout evidence

N/A for now. This changes a config generator, not an existing environment or agent: no shipped server, config or dataset changes. I have not run an end-to-end scripted-model smoke of a generated workload (gym env start plus one collated example through single_agent_turn). The workstation for heavy runs was out of disk today. I'll add it here before this PR leaves draft.

🤖 Generated with Claude Code

…relay

`gym env init` now pairs a new resources server, environment or benchmark
with simple_agent through the single_agent_turn Environment Server: each
dataset declares a taskset, environment_server_routes maps it to
`<name>_environment_server`, and that server inherits single_agent_turn and
binds the resources server and agent with direct_http tool access.

- --resources-server: train, validation and example each get their own
  taskset (`<name>_train`, `<name>_validation`, `<name>_example`).
- --environment / --benchmark: the example dataset routes as
  `<name>_example`, the benchmark dataset as `<name>`. A reused verifier
  without a bundled Environment Server gets the same server, bound to the
  reused resources server; one with a bundled server still inherits it.
- external-agent-loop keeps its legacy_agent relay: its agent runs the
  episode in /run, which agent sessions never call.
- The workload config is dumped one top-level block at a time, replacing a
  split on the agent name that broke the single_agent_turn config path for
  names such as `single`.

new-environment.mdx describes the generated server and the collate step a
standalone server's smoke needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33 yaoyu-33 added feature New capabilities, enhancements, or enablement work area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation labels Nov 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 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.

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 48b4848

@github-actions

Copy link
Copy Markdown
Contributor

This branch had an error being deployed

1 failed deployment
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 feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant