Skip to content

fix(gymnasium): release subclass state when episodes end - #3440

Merged
cmunley1 merged 2 commits into
mainfrom
athitten/issue-3157
Sep 21, 2026
Merged

cmunley1 merged 2 commits into
mainfrom
athitten/issue-3157

Conversation

@athitten

Copy link
Copy Markdown
Contributor

What does this PR do?

Releases Gymnasium subclass state when an episode terminates or is truncated.

  • Adds one idempotent _cleanup_session() path used by terminal release and reset replacement.
  • Removes Sokoban and Tetris state and closes each environment at most once.
  • Removes multi-turn example counters together with base session state.
  • Keeps cleanup safe when called repeatedly or concurrently.
  • Leaves a single helper for the future feat(core): define resources-session identity and close protocol #2609 release_session() hook to delegate to.

Closes #3157.

Validation

  • uv run --extra dev pytest resources_servers/gymnasium/tests/test_app.py resources_servers/example_multi_turn_gymnasium/tests/test_app.py -q — 15 passed.
  • uv run gym env test --resources-server grl_sokoban — 9 passed.
  • uv run gym env test --resources-server grl_tetris — 8 passed.
  • Tests cover terminal and truncated episodes, reset replacement, repeated concurrent cleanup, state removal, and exactly-once environment closure.
  • uv run pre-commit run --all-files — passed.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format/copyright pass).
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

@copy-pr-bot

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

@athitten

Copy link
Copy Markdown
Contributor Author

/ok to test 0539472

@athitten

Copy link
Copy Markdown
Contributor Author

/ok to test 048b546

@cmunley1
cmunley1 added this pull request to the merge queue Sep 21, 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/35651312362

Merged via the queue into main with commit bd58b2c Sep 21, 2026
42 checks passed
@cmunley1
cmunley1 deleted the athitten/issue-3157 branch September 21, 2026 20:38

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gymnasium): release subclass state when an episode ends

2 participants