Skip to content

Prevent timeout bootstrapping for terminated Gymnasium episodes - #416

Merged
Denys88 merged 3 commits into
Denys88:masterfrom
Afloat16:afloat16/termination-before-timeout-bootstrap-20261116
Nov 19, 2026
Merged

Denys88 merged 3 commits into
Denys88:masterfrom
Afloat16:afloat16/termination-before-timeout-bootstrap-20261116

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

A Gymnasium step can report both terminated=True and truncated=True, for example when the task ends on its time limit. GymnasiumVecEnv currently copies truncated into info['time_outs']. Learners use done & ~time_outs to decide whether the transition is terminal, so this combination incorrectly bootstraps a value beyond an actual terminal state.

Changes

Mark a transition as a timeout only when it is truncated and not terminated. Apply the same precedence to native vector and manual backends, including a timeout flag supplied by a manually wrapped environment. Preserve timeout-only bootstrapping and existing explicit false timeout overrides.

Regression tests cover all termination/truncation combinations, synchronous and asynchronous native vector environments, single/multiple actors, manually wrapped multi-agent environments, and supplied timeout metadata. An actual SAC training/replay test checks the resulting terminal masks used by the learner.

Validation

On Python 3.11 and 3.14, the full suite changes from 8 failed, 433 passed, 16 skipped to 441 passed, 16 skipped. All six existing CI jobs pass, including lock, lint, and Python 3.11–3.14 tests.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@9c0b3a0). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #416   +/-   ##
=========================================
  Coverage          ?   58.22%           
=========================================
  Files             ?       70           
  Lines             ?     8865           
  Branches          ?        0           
=========================================
  Hits              ?     5162           
  Misses            ?     3703           
  Partials          ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Denys88 Denys88 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Correct: time_outs must be truncated & ~terminated, otherwise a true terminal state at the time limit gets bootstrapped. Matches the convention adopted in #395.

@Denys88
Denys88 merged commit ff60662 into Denys88:master Nov 19, 2026
6 checks passed
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.

3 participants