Answer stability round 1: 0 🔴, 6 🟡 (0 misread); the bench tests only the packages the clone holds, refuses a run that ended in an error, and pins a worker's committed change
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Bench the advisor tool on archived chunks: advisor_bench.py <work dir> run|grade <case>-<arm>-<n> ..., then advisor_bench.py <work dir> summary
|
||||
|
||||
Item 320's question: does a worker below the project's rung, Sonnet 5.5 with Opus 5.5 as its advisor, beat the
|
||||
same Sonnet alone, or match Opus 5.5 at medium for less? Each case is an archived L 1 or L 2 chunk of this
|
||||
repo (CASES: its todo.md item, the commit it started from, the commit it merged at). `run` clones the repo at
|
||||
the start commit, hands the arm's worker that item as loop-claude's worker would see it, and saves, beside the
|
||||
clone in <work dir>: the claude stream (.jsonl), the worker's change (.diff) and the result of the tests the worker's and the shipped change touch (.tests).
|
||||
The question: does a worker below the project's rung, Sonnet 5.5 with Opus 5.5 as its advisor, beat the same
|
||||
Sonnet alone, or match Opus 5.5 at medium for less? Each case is an archived L 1 or L 2 chunk of this repo
|
||||
(CASES holds its todo.md item, the commit it started from and the commit it merged at). `run` clones the repo at
|
||||
the start commit and hands the arm's worker the item's text from todo.md, with the bench rules of
|
||||
advisor-run-prompt.md in place of loop-claude's prompt. It saves, beside the clone in <work dir>: the claude
|
||||
stream (.jsonl), the worker's change (.diff) and the result of the tests of the packages that either change touches (.tests).
|
||||
`grade` has a judge on Opus 5.5 at medium, blind to the arm, rule on the .diff against the merged commit's change
|
||||
(.verdict); `summary` prints a table per arm.
|
||||
Run each arm of each case once; the table shows a direction, not a significance.
|
||||
@@ -21,8 +22,7 @@ import sys
|
||||
BENCH = pathlib.Path(__file__).resolve().parent
|
||||
REPO = BENCH.parent
|
||||
RUN_HEAVY = pathlib.Path.home() / ".claude/bin/run-heavy"
|
||||
SUITE = ["uvx", "--python", "/usr/bin/python3", "--with", "pytest-xdist==3.8.0", "pytest==9.2.0", "-n", "4", "-q"]
|
||||
# Each case is the item's ID, the commit its chunk started from and the commit it merged at.
|
||||
SUITE = ["uvx", "--python", sys.executable, "--with", "pytest-xdist==3.8.0", "pytest==9.2.0", "-n", "4", "-q"]
|
||||
CASES = {
|
||||
"290": ("cda45a931", "509804da0"),
|
||||
"251": ("b74322892", "d13c4fb0d"),
|
||||
@@ -55,7 +55,6 @@ JUDGE = Arm("claude-opus-5-5", "medium")
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Outcome:
|
||||
cost: float
|
||||
turns: int
|
||||
seconds: float
|
||||
advisor_calls: int
|
||||
|
||||
@@ -69,16 +68,18 @@ def item_text(todo, item):
|
||||
|
||||
|
||||
def read_result(lines):
|
||||
"""The cost, turns, seconds and advisor calls of a claude stream's first result line, the worker's own: a background task's notification makes later ones. Its cost counts the advisor's tokens."""
|
||||
"""The cost, seconds and advisor calls of a claude stream's first result line, which is the worker's: a background task's notification makes the later ones. The cost counts the advisor's tokens."""
|
||||
for line in lines:
|
||||
try:
|
||||
entry = json.loads(line)
|
||||
except ValueError:
|
||||
continue
|
||||
if entry.get("type") == "result":
|
||||
if entry.get("is_error"):
|
||||
raise ValueError(f"the run ended in an error: {entry.get('result')}")
|
||||
iterations = entry.get("usage", {}).get("iterations", [])
|
||||
return Outcome(
|
||||
cost=entry["total_cost_usd"], turns=entry["num_turns"], seconds=entry["duration_ms"] / 1000,
|
||||
cost=entry["total_cost_usd"], seconds=entry["duration_ms"] / 1000,
|
||||
advisor_calls=sum(1 for each in iterations if each.get("type") == "advisor_message"))
|
||||
raise ValueError("the stream has no result line")
|
||||
|
||||
@@ -144,10 +145,12 @@ def run(work, name):
|
||||
["claude", "-p", prompt, *ARMS[arm].flags(), "--setting-sources", "project", "--permission-mode", "bypassPermissions",
|
||||
"--no-session-persistence", "--output-format", "stream-json", "--verbose"],
|
||||
cwd=clone, stdout=out, stderr=subprocess.STDOUT)
|
||||
read_result((work / f"{name}.jsonl").read_text().splitlines())
|
||||
git(clone, "add", "--all")
|
||||
(work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base))
|
||||
changed = [*git(clone, "diff", "--cached", "--name-only", base).split(), *git(REPO, "diff", "--name-only", base, CASES[case][1]).split()]
|
||||
tests = subprocess.run([str(RUN_HEAVY), *SUITE, *suite_targets(changed)], cwd=clone, capture_output=True, text=True)
|
||||
targets = [target for target in suite_targets(changed) if (clone / target).exists()] or ["bin"]
|
||||
tests = subprocess.run([str(RUN_HEAVY), *SUITE, *targets], cwd=clone, capture_output=True, text=True)
|
||||
(work / f"{name}.tests").write_text(f"exit {tests.returncode}\n{tests.stdout[-1500:]}")
|
||||
return f"{name}: ran"
|
||||
|
||||
@@ -179,7 +182,10 @@ def rows_of(work):
|
||||
rows = []
|
||||
for verdict_file in sorted(work.glob("*.verdict")):
|
||||
name = verdict_file.stem
|
||||
outcome = read_result((work / f"{name}.jsonl").read_text().splitlines())
|
||||
try:
|
||||
outcome = read_result((work / f"{name}.jsonl").read_text().splitlines())
|
||||
except ValueError as failure:
|
||||
raise ValueError(f"{name}: {failure}") from failure
|
||||
rows.append({"arm": split_name(name)[1], "verdict": json.loads(verdict_file.read_text())["verdict"], **dataclasses.asdict(outcome)})
|
||||
return rows
|
||||
|
||||
|
||||
Reference in New Issue
Block a user