Skip to content

refactor: name episode requests and sessions without "native" - #4070

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/rename-native-episode-terms
Oct 6, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/rename-native-episode-terms

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes "native" from the Environment Server code. It meant two different things there, which made the code hard to read:

  • Sessions an Environment Server creates, as opposed to the cookie sessions an agent's /run starts. These now use the protocol's own names: agent session, Resources session, or Environment Server session when both are meant.
  • Typed episode requests, as opposed to flat legacy rows. These are now episode requests, and tasks with a task_id.taskset and task_input are materialized tasksets and rows, matching the existing MaterializedTask and _materialized_taskset.

Renames:

Before After
SingleAgentTurnLegacyEnvironmentServer._native_request _episode_request_from_row (it builds an episode request from a flat row)
rollout_collection._native_episode_request_body _episode_request_body
SWE-bench Pro _native_session_locks, _closed_native_sessions _session_locks, _closed_sessions

Comments and help text that said "native taskset", "native row", "native-only run", or "native episode response" now say materialized taskset or row, a run of materialized rows only, or episode response. Test names and fixture values in the adapter, single_agent_turn, SWE-bench Pro, and Hermes tests follow the same names.

Other uses of "native" are unrelated and unchanged: Gym's built-in agents, native Gym rollouts in reverification, native PDFs, Anthropic- and MCP-native harnesses, and is_responses_native.

No behavior changes.

Issue

No issue is linked; this is naming cleanup for the Environment Server work, following review of #3784.

Validation

  • pytest environment_servers/single_agent_turn/tests environment_servers/single_agent_turn_legacy/tests -q: 30 and 12 passed.
  • pytest resources_servers/swebench_pro/tests -q: 96 passed.
  • pytest tests/unit_tests/test_rollout_collection.py tests/unit_tests/test_environment_server.py -q: 433 passed.
  • pytest responses_api_agents/hermes_agent/tests -q (its own venv): 219 passed.
  • pre-commit run on the changed files.

Rollouts

N/A: renames identifiers, comments, help text, and test names only; no behavior changes.

Compatibility

No API, configuration, or result changes. The renamed functions and attributes are private.

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 5, 2026 22:41
@ananthsub
ananthsub requested review from yaoyu-33 and zyzhou5 October 5, 2026 22:41
@ananthsub ananthsub added the r0.7.0 Auto-cherrypick to release branch. Apply before merge; cherrypick happens after merge. label Oct 5, 2026
@yaoyu-33 yaoyu-33 added area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation complexity:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 5, 2026
zyzhou5
zyzhou5 previously approved these changes Oct 6, 2026

@zyzhou5 zyzhou5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The renaming LGTM.

@ananthsub
ananthsub added this pull request to the merge queue Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37399854608

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 6, 2026
@ananthsub
ananthsub added this pull request to the merge queue Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37414388962

"Native" meant two different things in the Environment Server code: sessions
an Environment Server creates, and typed episode requests as opposed to flat
rows. Both now use descriptive names: agent and Resources sessions, episode
requests, and materialized tasksets and rows. _native_request becomes
_episode_request_from_row, _native_episode_request_body becomes
_episode_request_body, and SWE-bench Pro's session lock and closed-session maps
drop the prefix. No behavior change.

Signed-off-by: Ananth Subramaniam <[email protected]>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 6, 2026
@ananthsub
ananthsub force-pushed the ananthsub/rename-native-episode-terms branch from 72164ca to 41408e7 Compare October 6, 2026 04:47
@ananthsub
ananthsub requested a review from zyzhou5 October 6, 2026 14:17
@ananthsub
ananthsub merged commit 412efc7 into main Oct 6, 2026
44 checks passed
@ananthsub
ananthsub deleted the ananthsub/rename-native-episode-terms branch October 6, 2026 14:17
ananthsub added a commit to ananthsub/Gym that referenced this pull request Oct 6, 2026
…-NeMo#4070)

Removes "native" from the Environment Server code. It meant two
different things there, which made the code hard to read:

- **Sessions an Environment Server creates**, as opposed to the cookie
sessions an agent's `/run` starts. These now use the protocol's own
names: agent session, Resources session, or Environment Server session
when both are meant.
- **Typed episode requests**, as opposed to flat legacy rows. These are
now episode requests, and tasks with a `task_id.taskset` and
`task_input` are materialized tasksets and rows, matching the existing
`MaterializedTask` and `_materialized_taskset`.

Renames:

| Before | After |
|---|---|
| `SingleAgentTurnLegacyEnvironmentServer._native_request` |
`_episode_request_from_row` (it builds an episode request from a flat
row) |
| `rollout_collection._native_episode_request_body` |
`_episode_request_body` |
| SWE-bench Pro `_native_session_locks`, `_closed_native_sessions` |
`_session_locks`, `_closed_sessions` |

Comments and help text that said "native taskset", "native row",
"native-only run", or "native episode response" now say materialized
taskset or row, a run of materialized rows only, or episode response.
Test names and fixture values in the adapter, `single_agent_turn`,
SWE-bench Pro, and Hermes tests follow the same names.

Other uses of "native" are unrelated and unchanged: Gym's built-in
agents, native Gym rollouts in reverification, native PDFs, Anthropic-
and MCP-native harnesses, and `is_responses_native`.

No behavior changes.

No issue is linked; this is naming cleanup for the Environment Server
work, following review of
[NVIDIA-NeMo#3784](NVIDIA-NeMo#3784).

- `pytest environment_servers/single_agent_turn/tests
environment_servers/single_agent_turn_legacy/tests -q`: 30 and 12
passed.
- `pytest resources_servers/swebench_pro/tests -q`: 96 passed.
- `pytest tests/unit_tests/test_rollout_collection.py
tests/unit_tests/test_environment_server.py -q`: 433 passed.
- `pytest responses_api_agents/hermes_agent/tests -q` (its own venv):
219 passed.
- `pre-commit run` on the changed files.

N/A: renames identifiers, comments, help text, and test names only; no
behavior changes.

No API, configuration, or result changes. The renamed functions and
attributes are private.

Signed-off-by: Ananth Subramaniam <[email protected]>
(cherry picked from commit 412efc7)
Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub added a commit that referenced this pull request Oct 6, 2026
…vers (#3818, #4070, #3929, #4053) into `r0.7.0` (#4107)

## What

This PR only cherry-picks four already-merged `main` PRs into `r0.7.0`.
It adds no new code. The commits are applied in their `main` merge order
with `git cherry-pick -x`, so each commit message records its source
commit.

| Original PR | Commit on `main` | Change |
|---|---|---|
| #3818 | `325fb49d6` |
feat(data): collate declared tasksets |
| #4070 | `412efc730` | refactor:
name episode requests and sessions without "native" |
| #3929 | `1f2446c17` |
feat(config): deprecate agents without an environment server and fix the
migration script |
| #4053 | `89c065b0e` |
feat(config): support environment servers that front several agents |

## Why

#4070 and #4053 carry the `r0.7.0` label, but the automatic cherry-pick
workflow could not apply them: both hit merge conflicts on `r0.7.0`. The
workflow still reports success, so the failure was silent. #3818 was
intended for `r0.7.0` but never had the label.

#3929 is included because #4053 builds on it. Every #4053 conflict came
from #3929 changes to `nemo_gym/global_config.py`,
`scripts/add_legacy_agent_environment_servers.py`, and their tests. With
#3929 applied first, #4053 applies cleanly.

## Conflict resolution

Picking #3818 first removed one #4070 conflict. The remaining conflicts
were in tests that other PRs added on `main` after the branch cut:

- **#4070**: renames identifiers, comments, and test names; no behavior
change. Where the conflict was a test that exists only on `main`
(`single_agent_turn`, SWE-bench Pro, and Hermes
`test_agent_sessions.py`), the `r0.7.0` version is kept and the
`main`-only test is not brought in. In `single_agent_turn_legacy`, the
existing test is renamed to
`test_flat_rows_and_episode_requests_project_the_same_result` to match
`main`, and the `task_source` tests from a separate PR are left out.
- **#3929**: one import line in
`tests/unit_tests/test_global_config.py`. `main` also imports
`hide_secrets_in_overrides`, added by
#3679 and unused in this file, so
the `r0.7.0` import is kept.
- **#3818** and **#4053**: applied cleanly.

## Validation

- `pytest tests/unit_tests/test_global_config.py
tests/unit_tests/test_add_legacy_agent_environment_servers.py
tests/unit_tests/test_rollout_collection.py
tests/unit_tests/test_environment_server.py
tests/unit_tests/test_task_materialization.py
tests/unit_tests/test_benchmarks.py`: pass.
- `pytest environment_servers/single_agent_turn/tests` and `pytest
environment_servers/single_agent_turn_legacy/tests` (run separately):
pass.
- `pytest tests/unit_tests -n 8`: same failures as unmodified `r0.7.0`
and no new ones. The existing failures are local-environment tests in
`test_opensandbox_compose.py`, `test_sandbox_stop_retry.py`, and
`test_slurm_script.py`.
- `pre-commit run --files` on all changed files: pass.
- Checked for old names #4070 renames (`_native_request`,
`_native_episode_request_body`, `_native_session_locks`,
`_closed_native_sessions`): none remain. The few remaining "native row"
comments are also on `main`.
- SWE-bench Pro and Hermes server tests were not run locally (they need
per-server venvs); release-branch CI covers them.

## Rollout evidence

N/A. Each change was reviewed and validated on `main`. This PR only
carries them to the release branch: #4070 is a rename with no behavior
change, and the config changes are covered by the unit tests above.

---------

Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: Ananth Subramaniam <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Yu Yao <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
ananthsub added a commit that referenced this pull request Oct 6, 2026
…ions (#3554, #3784) into `r0.7.0` (#4113)

## What

This PR only cherry-picks two already-merged `main` PRs into `r0.7.0`.
It adds no new code. Each commit is applied with `git cherry-pick -x`,
so its message records the source commit.

| Original PR | Commit on `main` | Change |
|---|---|---|
| #3554 | `b846dfaa5` |
fix(hermes): harden sandbox sessions |
| #3784 | `e0e63e526` |
feat(simple-agent): run simple agent through environment server sessions
|

This branch is based on the current `r0.7.0`, which already includes
#4107 (#3818, #4070, #3929,
#4053) and #4078.

## Why

#3784 has the `r0.7.0` label, but the automatic cherry-pick workflow
could not apply it: it hit a merge conflict in
`nemo_gym/base_responses_api_agent.py` and reported success anyway, so
nothing was opened.

#3554 is included because #3784 builds on it. #3554 added the agent
session handling (seed and close retries, session locks, close receipts)
in `nemo_gym/base_responses_api_agent.py` that #3784 extends. With #3554
applied first, the conflict in that file goes away. #3554 has no
`r0.7.0` label; it is included on purpose.

### Behavior changes from #3554

#3554's own description lists these, and they now apply on `r0.7.0` too:

- Hermes host execution now combines the config system prompt, request
instructions, and input system message instead of letting the config
prompt replace the dataset prompt. It honors the request temperature,
including zero, and rejects `developer` messages with 422. These changes
can change benchmark scores for Hermes on the host path.
- Hermes rejects unsupported non-default controls with a permanent 422,
including `top_p=1.0`, `store`, `service_tier`, metadata overrides,
`max_output_tokens`, and a `model` that does not match the configured
model.

## Conflict resolution

- **#3554**: applied cleanly.
- **#3784**: one conflict in
`environment_servers/single_agent_turn_legacy/tests/test_app.py`. #3784
adds two `task_source` tests next to a test that #4070 (already on
`r0.7.0` through #4107) renamed. The resolution keeps both, and the new
tests call the adapter method by its post-#4070 name,
`_episode_request_from_row`. The resulting file is identical to the file
on `main`.

## Validation

- `pytest tests/unit_tests -n 8`: same failures as unmodified `r0.7.0`
and no new ones. The existing failures are local-environment tests in
`test_opensandbox_compose.py`, `test_sandbox_stop_retry.py`, and
`test_slurm_script.py`.
- #3554's focused suite, each path run separately with
`--import-mode=importlib`:
`environment_servers/single_agent_turn/tests`,
`environment_servers/single_agent_turn_legacy/tests`,
`environment_servers/legacy_agent/tests`,
`responses_api_agents/hermes_sandboxed_agent/tests`,
`resources_servers/swebench_pro/tests`, and
`tests/unit_tests/test_{episode_types,environment_server,rollout_outcomes,failure_kinds,agent_session_retries,agent_sessions,base_responses_api_agent,process_supervisor,local_provider}.py`:
all pass.
- `responses_api_agents/hermes_agent/tests` in its own venv from
`requirements.txt`: all pass.
- `responses_api_agents/simple_agent/tests` and
`resources_servers/example_single_tool_call/tests`: all pass.
- `pre-commit run --files` on all files changed by the two commits:
pass.

## Rollout evidence

N/A for the cherry-pick itself. Both changes are applied unchanged from
`main`, except for the one test-file conflict described above. #3554
includes a real-model Hermes with SWE-bench Pro lifecycle smoke rollout.

---------

Signed-off-by: Ananth Subramaniam <[email protected]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: Yu Yao <[email protected]>
Co-authored-by: Marta Stepniewska-Dziubinska <[email protected]>
Co-authored-by: Adil Asif <[email protected]>
macandro96 added a commit that referenced this pull request Oct 17, 2026
The list holds the committed episodes an agent's own /run drives, and NeMo
RL's controller will read it, so name it for what it holds instead of
adding "legacy" to a wire field: Gym dropped that word, and "native",
from this vocabulary in #4070. The comment, test names and variables
follow; existing names such as legacy_run stay.

Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit that referenced this pull request Oct 17, 2026
The list holds the committed episodes an agent's own /run drives, and NeMo
RL's controller will read it, so name it for what it holds instead of
adding "legacy" to a wire field: Gym dropped that word, and "native",
from this vocabulary in #4070. The comment, test names and variables
follow; existing names such as legacy_run stay.

Signed-off-by: Anish Mahishi <[email protected]>
(cherry picked from commit 428e887)
ananthsub pushed a commit that referenced this pull request Oct 19, 2026
… agent commit reply (#4690)

## What changed and why

An agent participant exports every parked session, but only an episode
the agent's own `/run` drives belongs to that `/run`; an agent session's
episode belongs to the environment server that opened it. A checkpoint
controller needs each committed episode's owner: it continues the
episodes someone owns and reports the parked sessions nobody owns.

Today the agent's commit reply lists every exported episode
(`episode_ids`) but not which of them its own `/run` drives, so NeMo
RL's controller opens the agent's records file after the commit, checks
its `records_sha256` against the reply, and reads each record's private
`episode_id` / `episode` fields. That ties the controller to Gym's
on-disk record format.

`AgentSessionParticipant.commit_reply` now adds `run_episode_ids`: the
capture keys of the committed records whose `/run` step boundary is set.
This uses the existing `commit_reply` hook, the same way the policy
model participant reports `staging_keys` and `staging_keys_by_episode`.
Nothing else in the reply or the records changes.

Raised from review of NVIDIA-NeMo/RL#4500
([thread](NVIDIA-NeMo/RL#4500 (comment)));
no separate Gym issue.

Named `run_episode_ids` rather than `legacy_episode_ids`: Gym dropped
"legacy" and "native" from this vocabulary in #4070, and NeMo RL reads
this field.

## Compatibility

Additive: one new field in the agent participant's commit reply.
Existing controllers ignore it. `RestartOnlyAgentParticipant` exports no
records and keeps the base reply.

## Validation

- `pytest tests/unit_tests/test_checkpoint_agent.py`: 38 passed (after
the rename); the earlier run of `test_checkpoint_agent.py`,
`test_checkpoint_control.py` and `test_checkpoint_coordination.py`: 133
passed.
- New `test_commit_reply_names_the_episodes_agent_runs_drive`: an
agent's own `/run` parked in a replayable verify step and an agent
session parked at an activation boundary are committed through the real
control plane; the reply's `episode_ids` names both and
`run_episode_ids` names only the `/run`. With the `episode is not None`
filter removed, the test fails.
- New
`test_a_restored_run_episode_not_yet_reclaimed_is_still_named_in_the_commit_reply`:
an agent's own `/run` is committed, restored into a fresh agent through
the control plane, and committed again before any replacement `/run`
claims it; it is still named in `run_episode_ids` under its next
attempt. A controller that missed it would see a parked session nobody
owns. With the restored episode boundary left out of the export, this
test fails while the first one still passes.
- `ruff check`, `ruff check --select I`, `ruff format --check` (ruff
0.9.9, as pinned in `.pre-commit-config.yaml`) on the changed files.
- DCO sign-off on the commit.

## Rollout evidence

N/A: this adds a field to a checkpoint control reply and changes no
agent, model or verifier behavior during a rollout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Anish Mahishi <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
oyilmaz-nvidia pushed a commit to JeffPengCoder/Gym that referenced this pull request Oct 21, 2026
* refactor: describe session support without "native"

"Native" meant several different things in docs, comments, error messages, and tests about
Environment Server sessions, and none of them told the reader what was meant.
Each use now names the concrete thing, following NVIDIA-NeMo#4070:

- "native sessions" are agent sessions.
- A "native Environment Server" is an Environment Server that drives agent sessions, such as
  `single_agent_turn`.
- "Native rows" and "native task rows" are materialized rows.
- A "native episode request" is an episode request.
- "Native Codex" and "Native Pi" errors now say Codex or Pi in the task sandbox.
- "Native composition" is composition with an Environment Server.

Private names follow the same wording: OpenClaw's `native_session_id` becomes
`openclaw_session_id`, and the checkpoint end-to-end topologies `native` and `legacy` become
`sessions` and `relay`.

Uses of "native" that mean a harness's own transcript, binary, or output, native PDFs, the
Gym-native eval path, and native Gym rollouts are unrelated and unchanged.

Signed-off-by: Ananth Subramaniam <[email protected]>

* docs(agents): avoid contentless qualifiers like "native" in naming

Ask agents to name the specific mechanism, owner, or format instead of
qualifiers such as "native", "legacy", "new", or "old", and reword the
Dataset description so AGENTS.md follows the rule itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

---------

Signed-off-by: Ananth Subramaniam <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 41408e7b Deployed Oct 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #4383
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:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer r0.7.0 Auto-cherrypick to release branch. Apply before merge; cherrypick happens after merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants