Skip to content

fix: handle dict word_list in TextArenaEnv.ta_to_hf() + add Supported Patterns docs#1147

Open
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
vominh1919:fix/ta-env-word-list-dict
Open

fix: handle dict word_list in TextArenaEnv.ta_to_hf() + add Supported Patterns docs#1147
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
vominh1919:fix/ta-env-word-list-dict

Conversation

@vominh1919
Copy link
Copy Markdown

@vominh1919 vominh1919 commented Apr 16, 2026

Changes

1. Fix TextArenaEnv.ta_to_hf() crash with dict word_list (Fixes #1074)

The ta_to_hf() method crashed with KeyError: 1 when word_list was a dict (e.g., TwentyQuestions-v0). This happened because random.choice(words) returned a dict key instead of a word.

Fix: Added check to flatten dict word_list into a list before random selection.

if isinstance(words, dict):
    words = [word for category_words in words.values() for word in category_words]

2. Add "Supported Patterns" section to README (Addresses #1078)

Added comprehensive documentation of supported RL framework design patterns to the README, covering:

  • Context management
  • User simulations
  • Native tool parsing
  • Sandboxing (all three modes)
  • Reward systems (groupwise, intermediate, rubric composition)
  • Multi-environment support
  • Resource management
  • Custom metrics & error handling
  • Offline evals

This makes the design space more discoverable for new users.

Testing

  • Verified fix works with both list and dict word_list formats
  • README renders correctly on GitHub

Closes #1074
Closes #1078


Note

Low Risk
Small, localized bug fix to dataset generation plus documentation-only additions; no security-sensitive or broad behavioral changes.

Overview
Fixes a crash in TextArenaEnv.ta_to_hf() when TextArena provides word_list as a dict (e.g., category -> words) by flattening it before random.choice, ensuring dataset generation works across game types.

Updates README.md with a new Supported Patterns section that summarizes the library’s out-of-the-box RL environment/harness capabilities (context management, tool parsing, sandboxing modes, reward composition, multi-env evals, resource management, and offline eval tooling).

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

@vominh1919
Copy link
Copy Markdown
Author

Hi! I'd like to help with this issue.

I can analyze the problem and create a fix. Here's my approach:

  1. Understand the issue - Read the description and reproduce the bug
  2. Find the root cause - Locate the problematic code
  3. Implement a fix - Create a minimal, targeted solution
  4. Test the fix - Verify it works as expected
  5. Submit a PR - Ready for your review

Would you like me to proceed?


Offering help with open issues to improve the project.

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.

Add "Supported Patterns" section to README or docs TextArenaEnv.ta_to_hf() crashes when word_list is a dict

1 participant