Skip to content

fix(textarena_env): end the episode at max_turns - #1740

Open
Aafimalek wants to merge 1 commit into
openenv:mainfrom
Aafimalek:fix/textarena-max-turns
Open

Aafimalek wants to merge 1 commit into
openenv:mainfrom
Aafimalek:fix/textarena-max-turns

Conversation

@Aafimalek

@Aafimalek Aafimalek commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

max_turns (and TEXTARENA_MAX_TURNS) was stored in the state but never ended an episode. With TicTacToe-v0, num_players=2, max_turns=2, four valid moves all returned done=False. The README documents it as "Maximum turns per episode". step() now sets done once step_count reaches max_turns.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • New environment
  • Refactoring

Alignment Checklist

Before submitting, verify:

  • I have read .claude/docs/PRINCIPLES.md and this PR aligns with our principles
  • I have checked .claude/docs/INVARIANTS.md and no invariants are violated
  • I have run /pre-submit-pr (or bash .claude/hooks/lint.sh and tests) and addressed all issues

RFC Status

  • Not required (bug fix, docs, minor refactoring)
  • RFC exists: #___
  • RFC needed (will create before merge)

Test Plan

  • New test_max_turns_ends_the_episode in tests/envs/test_textarena_environment.py. The existing fake_textarena fixture now forwards kwargs, so the test runs without textarena. On main: 1 failed, 31 passed. With the fix: 32 passed (WSL, Python 3.12).
  • bash .claude/hooks/lint.sh passes.
  • Not run: the full test suite.

Claude Code Review

Alignment review by Opus 5.5, in the format of .claude/skills/alignment-review/SKILL.md.

Automated Checks

  • Lint: PASS, bash .claude/hooks/lint.sh
  • Debug code: CLEAN

Tier 1: Fixes Required

None.

Tier 2: Alignment Discussion

None.


Note

Low Risk
Small behavioral fix in episode termination; aligns behavior with documented config and is covered by a targeted test.

Overview
TextArena episodes now honor max_turns (and TEXTARENA_MAX_TURNS): after each step(), observation.done is true when the wrapped game ends or when a limit is set and step_count has reached it—previously the limit lived in state but never terminated the episode.

A new unit test drives two steps with max_turns=2 and expects done on the second step. The fake_textarena fixture forwards constructor kwargs so that test runs without the optional TextArena dependency.

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

max_turns / TEXTARENA_MAX_TURNS was stored but never ended an episode.
Report done once step_count reaches it.

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