Repository navigation
Open a new OpenEnv client per game in the Wordle and multi-env examples - #8129
Merged
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
albertvillanova
left a comment
Member
There was a problem hiding this comment.
Thanks, this matches the Sudoku pattern and the .sync() change is right for multi-env too. A few nits:
docs/source/openenv.md: theWordleEnvsnippet in the Wordle section (~L270) still keeps one client for the whole run. Could it get the samereset()change, so it matches the script?grpo_wordle.py/notebookreset(): Sudoku has a one-line comment linking to https://huggingface.co/docs/trl/openenv#long-runs-against-a-space. Could Wordle use the same comment, so the copies stay aligned?- Notebook and
openenv.mdsayMAX_CONCURRENT_ENVS=96with no reason. The script, plus the Sudoku notebook and README, explain it (64 games plus the sessions being closed). Worth the same short note?
albertvillanova
left a comment
Member
There was a problem hiding this comment.
Thanks for adding the comment! Two points from my previous review are still open:
docs/source/openenv.md: theWordleEnvsnippet (L258) still keeps one client for the whole run, so it doesn't match the script.- Notebook and
openenv.md:MAX_CONCURRENT_ENVS=96still has no reason (64 games plus the sessions being closed).
albertvillanova
approved these changes
Nov 10, 2026
albertvillanova
left a comment
Member
There was a problem hiding this comment.
Thanks, all addressed!
# Conflicts: # examples/grpo_wordle/grpo_wordle.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
grpo_wordle.pyand its notebook keep one OpenEnv client for the whole run. A Space closes WebSockets that stay open for hours (about every 2 hours in our runs), and the Wordle run takes about 2 hours 15 minutes. If the drop hits a game in progress, the clients up to OpenEnv 0.11.0 reconnect to a new session and the nextstep()plays on a board that was never reset, with no error. Since 0.12.0 they raiseSessionLostErrorinstead, so the game fails and counts as a loss.This PR opens a new client at the start of every game, as the Sudoku example does (#8097), so no connection lives long enough to be dropped. The client is
.sync(), soclose()really closes the previous one. Without it,close()on the async client returns a result that is never run and each game leaves a connection and an event-loop thread open (4 resets leave 5 threads on 0.10.0, 1 with.sync()).grpo_multi_env.py(and its snippet inopenenv.md) already opened a new client per game, but without.sync(), so itsclose()left the event-loop thread behind. It now uses.sync()as well.Follow-up from Albert's review of #8097. The same change for the OpenEnv Wordle tutorial script is in openenv/OpenEnv#1560.
Before submitting
Note
Low Risk
Example and documentation changes for remote client lifecycle; no changes to TRL training core or auth flows.
Overview
OpenEnv Wordle and multi-environment GRPO examples now close and recreate a synchronous client on every
reset(), matching the Sudoku pattern and the documented “long runs against a Space” guidance so WebSocket idle drops don’t break games mid-episode.TextArenaEnvandOpenSpielEnvclients use.sync()soclose()actually tears down connections and event-loop threads instead of leaking them when cycling clients between games.Docs and run instructions recommend
MAX_CONCURRENT_ENVS=96(up from 64) to cover 64 parallel games plus sessions that are still closing asynchronously.Reviewed by Cursor Bugbot for commit 00bec7f. Bugbot is set up for automated code reviews on this repo. Configure here.