Skip to content

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

Closed

Description

@ananthsub

Priority

Wave 0 — immediate independent bug fix. No framework dependency.

Problem

GymnasiumServer._step_endpoint() calls inherited cleanup after terminal or truncated steps, but the base method removes only session_state. Sokoban and Tetris store environments in session_id_to_state; the multi-turn example stores counters in session_turns. Their actual subclass state therefore leaks.

Essential scope

  • Remove subclass-owned state immediately on terminal and truncated episodes.
  • Close closeable environments exactly once.
  • Use one idempotent local cleanup helper shared by terminal release and reset replacement.
  • Make repeated and concurrent cleanup safe.

Later integration

When #2609 lands, release_session() delegates to this same helper. Do not create a second ownership path.

Acceptance criteria

  • Terminal and truncated Sokoban/Tetris episodes remove session_id_to_state and close the environment exactly once.
  • Terminal and truncated multi-turn example episodes remove session_turns.
  • Reset replacement and terminal release share one idempotent cleanup path.
  • Repeated and concurrent cleanup is safe.
  • The future feat(core): define resources-session identity and close protocol #2609 hook can delegate without changing cleanup semantics.

Activity

  1. athitten commented on Sep 9, 2026

    @athitten
    Contributor

    Hi @ananthsub can I take this one ?

  2. added
    waiting-on-customer
    on Sep 10, 2026
  3. removed
    waiting-on-customer
    on Sep 22, 2026
  4. added a commit that references this issue on Sep 22, 2026
    bd58b2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions