From 66c0bf58b04c7f4f9f69bbbe53c24c5f5c23aca2 Mon Sep 17 00:00:00 2001 From: Caio Theodoro <48462974+caiotheodoro@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:12:42 -0400 Subject: [PATCH] fix(textarena): forward seed to underlying TextArena env on reset TextArenaEnvironment.reset() accepted a seed parameter but never passed it to the wrapped TextArena env's reset(), so repeated resets with the same seed drew a different secret word every time. TextArena's own reset() already accepts seed, it was just being dropped. Fixes #1102 --- envs/textarena_env/server/environment.py | 2 +- tests/envs/test_textarena_environment.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/envs/textarena_env/server/environment.py b/envs/textarena_env/server/environment.py index 5591f41ad1..5568bd0129 100644 --- a/envs/textarena_env/server/environment.py +++ b/envs/textarena_env/server/environment.py @@ -188,7 +188,7 @@ def reset( if hasattr(env, "full_observations"): env.full_observations = {} - self._ta_env.reset(num_players=self.num_players) + self._ta_env.reset(num_players=self.num_players, seed=seed) for provider in self._reward_providers: provider.reset() diff --git a/tests/envs/test_textarena_environment.py b/tests/envs/test_textarena_environment.py index 673a3d6673..3f714bce7a 100644 --- a/tests/envs/test_textarena_environment.py +++ b/tests/envs/test_textarena_environment.py @@ -65,3 +65,21 @@ def test_wordle_reset_clears_accumulated_state(): # Verify the prompts are actually the same content assert obs1.prompt == obs2.prompt assert obs2.prompt == obs3.prompt + + +def test_reset_seed_is_forwarded_to_textarena(): + """`reset(seed=...)` must reach the underlying TextArena env. + + Regression test: the seed was previously accepted but discarded, so two + resets with the same seed drew two different secret words. + """ + pytest.importorskip("textarena", reason="textarena not installed") + env = TextArenaEnvironment(env_id="Wordle-v0", num_players=1) + + env.reset(seed=1234) + first_word = env._ta_env.state.game_state["secret_word"] + + env.reset(seed=1234) + second_word = env._ta_env.state.game_state["secret_word"] + + assert first_word == second_word