"""Summarize the agent runs: 10 tasks, 3 engines, 2 runs each, Claude Opus 5.5 driving agent-browser.
Each answer is checked against what the page showed on October 28, 2026."""
import json, re, statistics as S

EXPECT = {
    "allbirds-price": r"\$50", "trueclassic-28L": r"sold out", "pydocs-taskgroup": r"3\.11",
    "mdn-abort": r"abort\(\)", "stripe-amount": r"required.*smallest|smallest.*required",
    "gh-playwright-release": r"1\.64\.1.*(14 Oct|Oct\w* 14)", "pypi-httpx": r"0\.28\.1.*Dec\w* 6, 2024",
    "hf-top-downloads": r"all-MiniLM-L6-v2", "wiki-follow-link": r"1994", "github-search-repo": r"44\.7k",
}
ALL = json.load(open("agent-runs.json"))
print(f"{'':<11} {'correct':>8} {'input tokens':>13} {'browser time':>13} {'failed calls':>13}")
print(f"{'':<11} {'':>8} {'(all 20 runs)':>13} {'(median run)':>13}")
for e in ("chrome", "lightpanda", "obscura"):
    runs = [d for d in ALL if d["engine"] == e]
    ok = sum(bool(re.search(EXPECT[d["task"]], d["final"], re.I | re.S)) for d in runs)
    calls = [c for d in runs for c in d["tool_calls"]]
    print(f"{e:<11} {ok:>4} / {len(runs)} {sum(d['totals']['input_all'] for d in runs):>13,}"
          f" {S.median(sum(c['secs'] for c in d['tool_calls']) for d in runs):>12.1f}s {sum(c['error'] for c in calls):>6} of {len(calls)}")
