Skip to content

Commit 1233828

Browse files
authored
Merge pull request #29 from Samurai007AK/fix/26-no-web-web-are-inverted-by-the-public
fix(benchmarks): stop inverting --web/--no-web in the public runner
2 parents ce4dd2d + 2f12692 commit 1233828

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎benchmarks/public/runner/run_subprocess.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,20 @@ async def run_eval(
222222
# Both names are set because the toggle is read per workflow — stateful
223223
# reads REACT_NO_WEB, agent-team reads SWARM_NO_WEB — and a benchmark should
224224
# get the same policy whichever workflow runs it.
225+
# --web/--no-web are open-book flags; resolve_closed_book's override is the
226+
# closed-book decision, returned verbatim. Negate, or both flags do the
227+
# reverse of their help text. None falls through to the benchmark's own
228+
# declaration.
225229
from benchmarks.public.sandbox_profiles import resolve_closed_book
226-
closed = resolve_closed_book(args.benchmark, getattr(args, "web", None))
230+
231+
web = getattr(args, "web", None)
232+
closed = resolve_closed_book(
233+
args.benchmark,
234+
None if web is None else not web,
235+
)
227236
os.environ["REACT_NO_WEB"] = "1" if closed else "0"
228237
os.environ["SWARM_NO_WEB"] = "1" if closed else "0"
229-
source = "--web/--no-web" if getattr(args, "web", None) is not None else "benchmark default"
238+
source = "--web/--no-web" if web is not None else "benchmark default"
230239
logger.info(
231240
"Book policy: %s (%s) — web tools %s",
232241
"closed-book" if closed else "open-book", source,

‎tests/test_benchmark_sandbox_profiles.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,41 @@ def test_book_policy_override_wins_both_ways():
9292
assert resolve_closed_book("browsecomp", True) is True # --no-web
9393

9494

95+
async def test_runner_does_not_invert_the_web_flags(
96+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
97+
) -> None:
98+
"""``--no-web`` must reach ``resolve_closed_book`` as closed-book, and vice versa.
99+
100+
``resolve_closed_book`` is polarity-correct on its own, so its unit tests
101+
above stay green even when the runner hands it an un-negated *open-book*
102+
flag. That is exactly how the flags shipped inverted, so the regression has
103+
to be pinned on the handoff inside ``run_eval``.
104+
"""
105+
import argparse
106+
107+
from benchmarks.public import sandbox_profiles
108+
from benchmarks.public.runner import run_subprocess
109+
110+
class _Stop(Exception):
111+
"""Sentinel: end the run once the override has been observed."""
112+
113+
seen: list[bool | None] = []
114+
115+
def _spy(benchmark: str, override: bool | None = None) -> bool:
116+
seen.append(override)
117+
raise _Stop
118+
119+
monkeypatch.setattr(sandbox_profiles, "resolve_closed_book", _spy)
120+
121+
for web in (True, False, None):
122+
args = argparse.Namespace(benchmark="browsecomp", pipeline=None, web=web)
123+
with pytest.raises(_Stop):
124+
await run_subprocess.run_eval(args, out_dir=tmp_path, seed=0)
125+
126+
# --web is open-book, --no-web is closed-book, no flag defers to the benchmark.
127+
assert seen == [False, True, None]
128+
129+
95130
class _FakeResourceManager:
96131
"""Minimal stand-in exposing only what the tool resolvers touch."""
97132

0 commit comments

Comments
 (0)