Skip to content

Commit bf6d1ff

Browse files
committed
Fix Kernel-backed Red Cross benchmark
1 parent 6efb04e commit bf6d1ff

6 files changed

Lines changed: 39 additions & 12 deletions

File tree

docs/harbor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ By default each Harbor trial runs Chromium inside its own container. Pass `--bro
116116
uv run clawbench-harbor-adapt \
117117
--output-dir ./harbor-datasets/clawbench-v2-kernel \
118118
--browser-runtime kernel \
119-
--browser-runtime-options '{"stealth": false}' \
119+
--browser-runtime-options '{"stealth": true}' \
120120
--task-ids v2-1134-chapter-finder-redcross \
121121
--overwrite
122122
```

src/clawbench/runner/run_support/browser_runtime/providers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,9 @@ def start(self, task: dict[str, Any], time_limit_s: int) -> BrowserSession:
585585
timeout_seconds = min(259200, max(10, time_limit_s + 120))
586586
payload = {
587587
**self.options,
588+
"stealth": self.options.get("stealth", True),
588589
"headless": False,
589590
"timeout_seconds": timeout_seconds,
590-
"viewport": {
591-
"width": 1920,
592-
"height": 1080,
593-
"refresh_rate": 25,
594-
},
595591
}
596592
try:
597593
result = self._request_json("POST", "/browsers", payload)

src/clawbench/runtime/harbor/kernel-browser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def _public_metadata(state: dict[str, Any]) -> dict[str, Any]:
100100
"session_id": metadata.get("session_id"),
101101
"replay_id": inner.get("replay_id") or metadata.get("replay_id"),
102102
"region": inner.get("region") or metadata.get("region"),
103-
"stealth": inner.get("stealth") or metadata.get("stealth"),
103+
"stealth": (
104+
inner["stealth"] if "stealth" in inner else metadata.get("stealth")
105+
),
104106
"timeout_seconds": (
105107
inner.get("timeout_seconds") or metadata.get("timeout_seconds")
106108
),

test-cases/v2/v2-1134-chapter-finder-redcross/task.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
},
1818
"instruction": "Find the nearest Red Cross chapter to zip code 90210 using the local chapter finder on redcross.org",
1919
"eval_schema": {
20-
"url_pattern": "redcross\\.org\\/find-your-local-chapter",
21-
"method": "GET"
20+
"url_pattern": "redcross\\.org/api/lookup/v1/region-mappings/90210(?:\\?|$)",
21+
"method": "GET",
22+
"params": {
23+
"type": "RCO"
24+
}
2225
},
2326
"time_limit": 30,
2427
"extra_info": []

tests/test_browser_runtime.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def fake_urlopen(
398398
monkeypatch.setattr(urllib.request, "urlopen", fake_urlopen)
399399
provider = KernelRuntimeProvider(
400400
api_key="kernel-secret",
401-
options={"stealth": True, "region": "us-east"},
401+
options={"region": "us-east"},
402402
replay_poll_interval_s=0,
403403
replay_poll_timeout_s=1,
404404
)
@@ -413,7 +413,6 @@ def fake_urlopen(
413413
"region": "us-east",
414414
"headless": False,
415415
"timeout_seconds": 1920,
416-
"viewport": {"width": 1920, "height": 1080, "refresh_rate": 25},
417416
}
418417
assert session.provider == "kernel"
419418
assert session.recording_mode == "provider-download"

tests/test_harbor_kernel_control.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import importlib.util
66
import json
7+
import re
78
import sys
89
import tomllib
910
from pathlib import Path
@@ -52,6 +53,27 @@ def adapted_kernel_task(tmp_path: Path) -> Path:
5253
)
5354

5455

56+
def test_redcross_task_intercepts_zip_lookup_not_chapter_finder_page() -> None:
57+
task_path = (
58+
REPO_ROOT
59+
/ "test-cases"
60+
/ "v2"
61+
/ "v2-1134-chapter-finder-redcross"
62+
/ "task.json"
63+
)
64+
schema = json.loads(task_path.read_text())["eval_schema"]
65+
66+
assert not re.search(
67+
schema["url_pattern"],
68+
"https://www.redcross.org/find-your-local-chapter.html",
69+
)
70+
assert re.search(
71+
schema["url_pattern"],
72+
"https://www.redcross.org/api/lookup/v1/region-mappings/90210?type=RCO",
73+
)
74+
assert schema["params"] == {"type": "RCO"}
75+
76+
5577
def test_kernel_runtime_selection_writes_bridge_env_and_pinned_mcp(
5678
adapted_kernel_task: Path,
5779
) -> None:
@@ -229,7 +251,11 @@ def __init__(self) -> None:
229251
cdp_url="wss://kernel.example/browser/sess-123/cdp?token=secret-token",
230252
viewer_url="https://kernel.example/live/sess-123",
231253
viewer_url_sensitive=True,
232-
metadata={"replay_id": "replay-9", "region": "us-east"},
254+
metadata={
255+
"replay_id": "replay-9",
256+
"region": "us-east",
257+
"stealth": False,
258+
},
233259
recording_mode="provider-download",
234260
)
235261

@@ -304,6 +330,7 @@ def test_start_writes_state_and_credential_free_metadata(
304330
metadata = json.loads(module.METADATA_FILE.read_text())
305331
assert metadata["session_id"] == "sess-123"
306332
assert metadata["replay_id"] == "replay-9"
333+
assert metadata["stealth"] is False
307334
assert metadata["cdp_bridge_url"] == "http://127.0.0.1:7878"
308335
blob = module.METADATA_FILE.read_text()
309336
assert "k-test-key" not in blob

0 commit comments

Comments
 (0)