SEED_MAX is `2 ^ 32` (XOR), so all random seeds fall in range(34)
SEED_MAX in browsergym/experiments/loop.py is written as 2 ^ 32. In Python ^ is XOR, so it's 34, not 2**32:
https://github.com/ServiceNow/BrowserGym/blob/27a90ce815098f43414e93491e06907af468e45b/browsergym/experiments/src/browsergym/experiments/loop.py#L35
It's used in two places:
ExpArgs.prepare()whentask_seedis None (loop.py#L349)make_env_args_list_from_repeat_tasks()(benchmark/utils.py#L62), which builds the defaultminiwobbenchmark with 5 seeds per task
So every generated seed is between 0 and 33, and the miniwob benchmark ends up repeating seeds within a task:
from collections import defaultdict
from browsergym.experiments.benchmark.configs import DEFAULT_BENCHMARKS
from browsergym.experiments.loop import SEED_MAX
print("SEED_MAX:", SEED_MAX)
seeds = defaultdict(list)
for env_args in DEFAULT_BENCHMARKS["miniwob"]().env_args_list:
seeds[env_args.task_name].append(env_args.task_seed)
print("distinct seeds:", len({s for v in seeds.values() for s in v}))
print("tasks with a repeated seed:", sum(len(set(v)) < len(v) for v in seeds.values()), "/", len(seeds))
print("miniwob.bisect-angle:", seeds["miniwob.bisect-angle"])
SEED_MAX: 34
distinct seeds: 34
tasks with a repeated seed: 33 / 125
miniwob.bisect-angle: [22, 10, 10, 23, 23]
Expected: seeds drawn from a large range, as the comment intends ("arbitrary max value (exclusive), seems large enough").
Actual: only 34 possible seeds. 35 of the 625 miniwob episodes repeat a (task, seed) pair that's already in the list. The seed fixes the MiniWoB instance (I checked that goal and DOM match for the same seed on bisect-angle and click-collapsible-2-nodelay), so those 33 tasks run on fewer than 5 distinct instances. Benchmarks built with n_repeats=1 (the WebArena ones) get no duplicates, but their seeds still come from range(34).
Proposed fix:
SEED_MAX = 2**32
I'd also pass dtype=np.int64 to the two randint calls. Core allows numpy>=1.14, and on Windows numpy 1.x defaults to int32, which can't take high=2**32. With that change the miniwob config gets 625 distinct seeds and no repeats. A small test in tests/experiments/test_benchmark.py would cover it.
One thing to decide first: this changes the seed list of the default miniwob benchmark, and of any seeds drawn with task_seed=None. New MiniWoB runs won't match older ones seed for seed. #195 shows stable seeds have mattered before, so I wanted to check how you'd like to handle it: fix it outright, or keep the old list under a separate config. AgentLab has the same line in src/agentlab/experiments/loop.py.
Happy to open a PR once you're OK with the approach.