fix: handle dict word_list in TextArenaEnv.ta_to_hf()#1214
Open
tashapais wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Open
fix: handle dict word_list in TextArenaEnv.ta_to_hf()#1214tashapais wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
tashapais wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Conversation
Games like TwentyQuestions-v0 expose a categorized word_list dict instead of a flat sequence, causing random.choice() to KeyError on integer indices. Flatten dict values into a list before sampling. Fixes PrimeIntellect-ai#1074 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
Author
|
@willccbb @mikasenghaas ready for review when you get a chance. |
Its fine, as long as the env gets fixed and works, thanks! |
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
TextArenaEnv.ta_to_hf()calledrandom.choice(words)assumingword_listis a sequence, but games likeTwentyQuestions-v0expose a categorized dict instead, causing aKeyErroron integer indices.Test plan
TextArenaEnv(game="TwentyQuestions-v0")and confirm noKeyErroron initWordle-v0behavior is unchanged (list word_list path unchanged)Closes #1074
Note
Low Risk
Low risk: small defensive change isolated to dataset generation logic, only altering how
word_listis normalized beforerandom.choice.Overview
Fixes
TextArenaEnv.ta_to_hf()to handle TextArena games whereword_listis a dict (e.g., categorized words) by flattening dict values into a list before sampling.This prevents sampling/index errors while keeping existing behavior unchanged when
word_listis already a sequence.Reviewed by Cursor Bugbot for commit a5e7075. Bugbot is set up for automated code reviews on this repo. Configure here.