Repository navigation
textarena_env: parse TEXTARENA_KW_* values as JSON - #1530
Merged
sergiopaniego merged 2 commits intoOct 30, 2026
Merged
Conversation
TEXTARENA_KW_CLUES=65 reached Sudoku as the string "65" and crashed on reset (int > str in _remove_cells). Values that are not JSON stay strings.
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.
Summary
TEXTARENA_KW_*environment variables reached TextArena as strings, so numeric kwargs broke the game they configure. For example,TEXTARENA_ENV_ID=Sudoku-v0withTEXTARENA_KW_CLUES=65crashes on everyreset():_parse_env_kwargsnow reads each value as JSON and falls back to the raw string, so65is an int,truea bool, andhardstays"hard".This is needed to serve Sudoku at an easier level than the default (30 clues, about 48 empty cells) from a Space, for the Sudoku SFT + GRPO tutorial we're preparing.
Changes
envs/textarena_env/server/app.py: parseTEXTARENA_KW_*values as JSON.tests/envs/test_textarena_environment.py: one test for the parsing, one that starts Sudoku withTEXTARENA_KW_CLUES=65. Both fail without the fix (the second with theTypeErrorabove).Compatibility
Values that are not valid JSON are passed exactly as before. A value that is valid JSON but was meant as a string (for example
TEXTARENA_KW_word="null") would now change type. No Space or Dockerfile in the repo setsTEXTARENA_KW_*.Test plan
pytest tests/envs/test_textarena_environment.py: 30 passed.Note
Low Risk
Small server startup change limited to optional TextArena kwargs; non-JSON values behave as before, with a minor edge case if a value was intentionally a JSON literal string.
Overview
TEXTARENA_KW_*env vars are no longer always passed to TextArena as strings._parse_env_kwargsinserver/app.pynow runs each value throughjson.loads, with a fallback to the raw string when parsing fails, so numeric and boolean kwargs (e.g. Sudokuclues=65) reach games with the correct type instead of causing type errors onreset().Documentation in the TextArena README and docs now notes JSON parsing and gives Sudoku/
difficultyexamples. Tests cover the parser mapping (65→ int,true→ bool,hard→ str) and starting Sudoku withTEXTARENA_KW_CLUES=65.Reviewed by Cursor Bugbot for commit 746c1e7. Bugbot is set up for automated code reviews on this repo. Configure here.