Skip to content

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

Open
sergiopaniego wants to merge 4 commits into
openenv:mainfrom
sergiopaniego:wordle-client-per-game
Open

sergiopaniego wants to merge 4 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
Changes affect example GRPO training scripts, test doubles, and documentation only—not production services or security-sensitive paths.

Overview
Wordle GRPO now matches the Sudoku training pattern: it uses a synchronous TextArenaEnv client and closes and recreates the connection on every reset(), so Hugging Face Space WebSocket timeouts (~2h) cannot cut a game off mid-episode during long runs.

Docs and READMEs update MAX_CONCURRENT_ENVS from 64 to 96 for Wordle (and clarify the same headroom in Sudoku comments), because each game starts a new session before the server has finished releasing the old one. The Sudoku tutorial also ties SessionLostError to OpenEnv 0.12.0 alongside PR #1536.

tests/scripts/test_wordle_training.py extends the fake env client with sync() and close() so tests still pass. Sudoku/Wordle grpo.py files mostly drop or tighten redundant comments (token header, constant LR rationale).

Reviewed by Cursor Bugbot for commit da8d6a8. 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

This branch has not been deployed

No deployments
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.

1 participant