Skip to content

Open a new client per game in the Wordle GRPO script - #1560

Merged
cursor[bot] merged 5 commits into
openenv:mainfrom
sergiopaniego:wordle-client-per-game
Nov 9, 2026
Merged

cursor[bot] merged 5 commits into
openenv:mainfrom
sergiopaniego:wordle-client-per-game

Conversation

@sergiopaniego

@sergiopaniego sergiopaniego commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

examples/wordle/grpo.py keeps one client for the whole run, and the run (about 2 hours 15 minutes) is longer than the interval at which the Space closes WebSockets (about 2 hours). This PR opens a new synchronous client per game, as examples/sudoku/grpo.py does since #1554, so a drop never lands in the middle of a game.

  • examples/wordle/grpo.py: .sync() client, closed and reopened in reset().
  • tests/scripts/test_wordle_training.py: the fake client gets sync() and close().
  • examples/sudoku/grpo.py and examples/wordle/grpo.py: drop comments that restate the code or describe our runs (the token header, the per-game connection, the constant learning rate, a token count that contradicted the one above it).
  • docs/source/tutorials/sudoku-grpo.md: SessionLostError ships in OpenEnv 0.12.0, so the sentence names the release next to Raise SessionLostError when the WebSocket drops mid-episode #1536.

Same change for the TRL example: huggingface/trl#8129.

Test plan

  • pytest tests/scripts/test_wordle_training.py tests/scripts/test_sudoku_training.py: 12 passed.
  • Ruff check and format pass on the changed files.

Note

Low Risk
Training-example and documentation changes only; behavior improves rollout reliability against remote Spaces with no auth or core-library changes.

Overview
Wordle GRPO now matches the Sudoku training pattern: WordleEnv uses a synchronous TextArenaEnv client that is closed and recreated on every reset(), so Hugging Face Space WebSocket timeouts (~2 hours) cannot cut a game mid-episode during long GRPO runs.

Documentation and inline comments are aligned with that behavior: MAX_CONCURRENT_ENVS=96 (not 64) on duplicated Wordle/Sudoku Spaces, because new sessions start before old ones finish closing asynchronously. The Sudoku tutorial also notes that SessionLostError (OpenEnv 0.12.0 / #1536) stops silent mid-episode reconnects.

The Wordle training test fake client gains sync() and close() so rollout tests still exercise the updated grpo.py entrypoint.

Reviewed by Cursor Bugbot for commit 4932efa. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1f1a26a. Configure here.

Comment thread examples/wordle/grpo.py Resolved
@cursor
cursor Bot merged commit dbdcde2 into openenv:main Nov 9, 2026
13 checks passed
@cursor cursor Bot mentioned this pull request Nov 9, 2026
2 tasks done
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.

2 participants