Repository navigation
feat(checkpoint): name the episodes an agent's own /run drives in the agent commit reply - #4690
Conversation
…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]>
…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]>
…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]>
| 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]: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
…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]>
|
/ok to test 428e887 |
…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]>
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]>
…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]>
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]>
…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]>
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]>
…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]>
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]>
…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]>
…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]>
…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]>
What changed and why
An agent participant exports every parked session, but only an episode the agent's own
/rundrives 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/rundrives, so NeMo RL's controller opens the agent's records file after the commit, checks itsrecords_sha256against the reply, and reads each record's privateepisode_id/episodefields. That ties the controller to Gym's on-disk record format.AgentSessionParticipant.commit_replynow addsrun_episode_ids: the capture keys of the committed records whose/runstep boundary is set. This uses the existingcommit_replyhook, the same way the policy model participant reportsstaging_keysandstaging_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_idsrather thanlegacy_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.
RestartOnlyAgentParticipantexports no records and keeps the base reply.Validation
pytest tests/unit_tests/test_checkpoint_agent.py: 38 passed (after the rename); the earlier run oftest_checkpoint_agent.py,test_checkpoint_control.pyandtest_checkpoint_coordination.py: 133 passed.test_commit_reply_names_the_episodes_agent_runs_drive: an agent's own/runparked in a replayable verify step and an agent session parked at an activation boundary are committed through the real control plane; the reply'sepisode_idsnames both andrun_episode_idsnames only the/run. With theepisode is not Nonefilter removed, the test fails.test_a_restored_run_episode_not_yet_reclaimed_is_still_named_in_the_commit_reply: an agent's own/runis committed, restored into a fresh agent through the control plane, and committed again before any replacement/runclaims it; it is still named inrun_episode_idsunder 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.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