Skip to content

feat(checkpoint): name the episodes an agent's own /run drives in the agent commit reply - #4690

Merged
ananthsub merged 4 commits into
mainfrom
amahishi/checkpoint-legacy-episode-ids
Oct 19, 2026
Merged

ananthsub merged 4 commits into
mainfrom
amahishi/checkpoint-legacy-episode-ids

Conversation

@macandro96

@macandro96 macandro96 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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); 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

…gent commit reply

An agent exports every parked session, but only a legacy /run session owns
its episode; a native session's episode belongs to its environment server. A
controller needs each committed episode's owner, and today has to open the
agent's records file and read its private fields to learn it.

The agent participant's commit reply now carries legacy_episode_ids, the
capture keys of the committed records with a legacy episode boundary, the
same way the policy model reports its staging keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 16, 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.

@macandro96
macandro96 marked this pull request as ready for review October 16, 2026 16:42
@macandro96
macandro96 marked this pull request as draft October 16, 2026 16:42
…run claims it

A checkpoint taken between a restore and the replacement /run exports the
restored session with the episode boundary it was restored with. Check that
the commit reply still credits that episode to its legacy run, so a
controller does not mistake it for a parked session nobody owns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
@macandro96
macandro96 marked this pull request as ready for review October 16, 2026 18:42
@macandro96
macandro96 requested a review from ananthsub October 16, 2026 18:43
@yaoyu-33 yaoyu-33 added area:core Shared APIs, servers, telemetry, health, and registries 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 16, 2026
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 16, 2026
…pisode ids

Move the Gym pin from 120d516f, a merge of the pre-merge checkpoint stack
that is on no Gym branch head and does not descend from main's pin, to
a6bf27ff on NVIDIA-NeMo/Gym amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin da9f6714;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes legacy /run sessions own in
  the agent commit reply;
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.

Relock with uv 0.11.18: Gym moves ray and jinja2 out of its core
dependencies and adds requests; every resolved package keeps its version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
…nt-server sessions in Gym's terms

Replace "native session" in the commit-reply comment and its test with an
agent session an environment server started, as the agent participant's
module docstring describes the two ways an episode reaches an agent.

Signed-off-by: Anish Mahishi <[email protected]>

@ananthsub ananthsub 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.

we should sort out this PR vs #3909's responsibilities

async def restored_pending(self) -> list[EpisodeId]:
return [session.episode_id for session in self._sessions.values() if session.restored_pending]

def commit_reply(self, records: list[CheckpointRecord]) -> dict[str, Any]:

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.

legacy_episode_ids puts "legacy" into a wire field that NeMo RL's controller will depend on, and the comment and tests call the other kind of session "native".
Gym dropped both words from the environment server's vocabulary in #4070: a session an environment server opens is an agent session, and the session an agent's /run starts is that /run's own.
Renaming after NeMo RL consumes the field means a coordinated change on both sides, so it is cheapest to settle the name now.
run_episode_ids says what the list holds: the committed episodes whose agent's own /run drives them.
The comment could read: "An episode an agent's own /run drives belongs to that /run; an agent session's episode belongs to the environment server that opened it."
The test names and the legacy_id / native_id variables would follow, for example run_id and session_id.
Existing code names such as legacy_run and LegacyRun can stay as they are; this is only about new names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed in 428e887: the field is run_episode_ids, the comment uses your wording, and the two tests and their variables follow (run_id / session_id, own_run(), test_commit_reply_names_the_episodes_agent_runs_drive, test_a_restored_run_episode_not_yet_reclaimed_is_still_named_in_the_commit_reply). legacy_run / LegacyRun and the existing tests are unchanged. NeMo RL's adapter now reads run_episode_ids (NVIDIA-NeMo/RL#4500), so the name is settled before anything ships against it.

def commit_reply(self, records: list[CheckpointRecord]) -> dict[str, Any]:
# A legacy /run session owns its episode; a native session's episode belongs to its environment server.
# The controller needs each committed episode's owner and should not read the records file to learn it.
return {

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.

With several agent workers, #3909's CoordinatedServerParticipant answers the commit and currently does not forward a participant's commit_reply, so this field would be dropped.
#3909 will delegate commit_reply to the wrapped participant, with a two-worker test, so nothing is needed in this PR; noting it so the two land consistently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I checked #3909 at 0f648ed: CoordinatedServerParticipant.commit_reply already hands the merged, one-copy-per-session records to the wrapped participant, and this PR builds run_episode_ids only from those records (the ones whose /run step boundary is set). So the two compose without a change here, including the restored episodes the coordinator adds to the export before a replacement /run claims them.

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 macandro96 changed the title feat(checkpoint): name the episodes legacy /run sessions own in the agent commit reply feat(checkpoint): name the episodes an agent's own /run drives in the agent commit reply Oct 17, 2026
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 17, 2026
…L needs

Move the Gym pin from 120d516f, a merge of the pre-merge checkpoint stack
that is on no Gym branch head and does not descend from main's pin, to
bf631d0a on NVIDIA-NeMo/Gym amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin da9f6714;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Relock with uv 0.11.18: Gym moves ray and jinja2 out of its core
dependencies and adds requests; every resolved package keeps its version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
@macandro96
macandro96 requested a review from ananthsub October 17, 2026 01:03
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Oct 19, 2026
@ananthsub

Copy link
Copy Markdown
Contributor

/ok to test 428e887

@ananthsub
ananthsub enabled auto-merge October 19, 2026 22:24
@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Oct 19, 2026
@ananthsub
ananthsub disabled auto-merge October 19, 2026 23:52
@ananthsub
ananthsub merged commit b082583 into main Oct 19, 2026
45 of 53 checks passed
@ananthsub
ananthsub deleted the amahishi/checkpoint-legacy-episode-ids branch October 19, 2026 23:52
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 22, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 23, 2026
The pin no longer needs commits that exist only on an unmerged branch. The
turn-recovery test holds its boundary through a policy-call proxy, so it no
longer uses the checkpoint test agent (NVIDIA-NeMo/Gym#4773), and the agent
commit reply's run_episode_ids (NVIDIA-NeMo/Gym#4690) is on main. The other
pin-only commits, the indirect prompt injection and proof refinement
checkpoint exports (NVIDIA-NeMo/Gym#3897, #3898), are for environments RL's
tests do not use.

Gym's pyproject.toml is identical to the previous pin's, so uv.lock is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 26, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 26, 2026
The pin no longer needs commits that exist only on an unmerged branch. The
turn-recovery test holds its boundary through a policy-call proxy, so it no
longer uses the checkpoint test agent (NVIDIA-NeMo/Gym#4773), and the agent
commit reply's run_episode_ids (NVIDIA-NeMo/Gym#4690) is on main. The other
pin-only commits, the indirect prompt injection and proof refinement
checkpoint exports (NVIDIA-NeMo/Gym#3897, #3898), are for environments RL's
tests do not use.

Gym's pyproject.toml is identical to the previous pin's, so uv.lock is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 27, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 27, 2026
The pin no longer needs commits that exist only on an unmerged branch. The
turn-recovery test holds its boundary through a policy-call proxy, so it no
longer uses the checkpoint test agent (NVIDIA-NeMo/Gym#4773), and the agent
commit reply's run_episode_ids (NVIDIA-NeMo/Gym#4690) is on main. The other
pin-only commits, the indirect prompt injection and proof refinement
checkpoint exports (NVIDIA-NeMo/Gym#3897, #3898), are for environments RL's
tests do not use.

Gym's pyproject.toml is identical to the previous pin's, so uv.lock is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 28, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 28, 2026
The pin no longer needs commits that exist only on an unmerged branch. The
turn-recovery test holds its boundary through a policy-call proxy, so it no
longer uses the checkpoint test agent (NVIDIA-NeMo/Gym#4773), and the agent
commit reply's run_episode_ids (NVIDIA-NeMo/Gym#4690) is on main. The other
pin-only commits, the indirect prompt injection and proof refinement
checkpoint exports (NVIDIA-NeMo/Gym#3897, #3898), are for environments RL's
tests do not use.

Gym's pyproject.toml is identical to the previous pin's, so uv.lock is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 31, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 31, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit to NVIDIA-NeMo/RL that referenced this pull request Nov 2, 2026
…L needs

Move the Gym pin from main's 6f295d7d to bf631d0a on NVIDIA-NeMo/Gym
amahishi/rl-gym-turn-recovery-pin:

- Gym main at 9ef5ed0f, which carries the merged checkpoint stack
  (#3882-#3889) and descends from main's pin 6f295d7d;
- NVIDIA-NeMo/Gym#3894: checkpoint Workplace Assistant sessions;
- NVIDIA-NeMo/Gym#4690: name the episodes an agent's own /run drives in
  the agent commit reply (run_episode_ids);
- the checkpoint test agent the turn-recovery functional test runs, with
  its participant installed once per app now that Gym installs it twice.
- NVIDIA-NeMo/Gym#3895-#3898: Gymnasium servers on the shared resources
  server setup, and checkpointing for Blackjack, indirect prompt
  injection and the proof refinement agent.

Gym adds requests to its core dependencies, so the lock records it for
nemo-gym; requests is already locked, and every resolved package keeps its
version.

Gym's coordination now sends each control body pre-encoded as data
rather than json, so the adapter test's in-process client forwards both.

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

This branch was previously deployed

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

Labels

area:core Shared APIs, servers, telemetry, health, and registries 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants