"""One live Beam judge call, to measure fit and cost before anything else spends. HF_TOKEN=... python scripts/probe.py --live [--sample-id 2608.08037-s003] Uses the eval row's own Beam trajectory content as the completion to grade, so no policy sampling is needed. Refuses to run without --live. """ from __future__ import annotations import argparse import glob import json import sys from pathlib import Path from foresightbench_env import prompt from foresightbench_env.data import load_split from foresightbench_env.judge import BeamJudge, JudgeCache, SpendMeter, load_rubric ROOT = Path(__file__).resolve().parents[1] def main() -> None: ap = argparse.ArgumentParser() ap.add_argument("--live", action="store_true") ap.add_argument("--sample-id", default=None) ap.add_argument("--trajectories", type=Path, default=ROOT.parent / "data" / "trajectories") ap.add_argument("--cache-dir", type=Path, default=ROOT / ".cache") a = ap.parse_args() if not a.live: sys.exit("refusing: this script spends Beam budget; pass --live to run it") rows = {r["sample_id"]: r for r in load_split("eval")} sid = a.sample_id or next(iter(rows)) files = glob.glob(str(a.trajectories / f"*beam-1.0-501b-a23b_{sid}.json")) if not files: sys.exit(f"no Beam trajectory for {sid}") traj = json.loads(Path(files[0]).read_text(encoding="utf-8")) completion = traj["response"]["choices"][0]["message"]["content"] meter = SpendMeter(a.cache_dir / "spend.json", 20.0, (0.40, 1.20)) judge = BeamJudge(load_rubric("v0"), meter, JudgeCache(a.cache_dir / "judge")) res = judge.score(prompt.messages(rows[sid]), completion) print(json.dumps({"ok": res.ok, "error": res.error, "cached": res.cached, "usage": res.usage, "cost_usd": round(res.cost, 5), "scores": res.scores, "notes": res.notes, "reasoning_chars": len(res.reasoning), "spend_total_usd": round(meter.total, 5)}, indent=1)) if __name__ == "__main__": main()