Refuse a compact arm whose compaction failed, and state the bench as it ran

This commit is contained in:
2026-11-17 03:56:25 +01:00
parent 24800c156b
commit b4490b4a8c
4 changed files with 30 additions and 14 deletions
+14 -6
View File
@@ -6,7 +6,8 @@ best? Each case is an archived chunk of this repo, as in advisor_bench.py, whose
- `start` runs WEAK on the item in the clone <work dir>/<case>-<n> until it has spent START_BUDGET, which
stands in for a run that ends asking for a higher rung. A worker that finishes within the budget leaves no
handoff, so `start` fails on it. It saves the change so far (<case>-start-<n>.diff), and a copy of the clone
(.tree) and of the session's transcript (.session.jsonl), which every arm starts from.
(.tree), which every arm starts from, and a copy of the session's transcript (.session.jsonl), which the resume
and compact arms continue.
- `run` puts the clone and the session back as `start` left them, then continues on STRONG, one arm of a case at a
time. The resume arm resumes WEAK's session with handoff-resume-prompt.md. The compact arm does the same once WEAK
has compacted the session with `/compact`, whose stream it saves as <name>.compact.jsonl. The brief arm starts a
@@ -48,7 +49,7 @@ CASES = {
"239": ("d583f8d48", "47a40757"),
}
# Dollars WEAK may spend before the handoff. In a trial, $0.36 stopped Sonnet 5.5 on items 163 and 227 after 11 to 14
# turns, with about 250 lines of diff.
# turns, as the result line's `num_turns` counts them, with about 250 lines of diff.
START_BUDGET = 0.36
CLAUDE_FLAGS = ["--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]
@@ -60,7 +61,7 @@ def stopped_at_budget(lines):
entry = json.loads(line)
except ValueError:
continue
if entry.get("type") == "result":
if isinstance(entry, dict) and entry.get("type") == "result":
return entry.get("subtype") == "error_max_budget_usd"
return False
@@ -122,6 +123,7 @@ def run(work, name):
resumed = ["--resume", transcript.stem]
if arm == "compact":
claude("/compact", [*WEAK.flags(), *resumed], clone, work / f"{name}.compact.jsonl")
finished(work / f"{name}.compact.jsonl")
if arm == "brief":
claude(run_prompt(case) + "\n" + (BENCH / "handoff-brief-prompt.md").read_text(), [*STRONG.flags(), "--no-session-persistence"], clone, stream)
else:
@@ -145,12 +147,18 @@ def results(stream):
return found
def finished(stream):
"""The result lines of a run that ended well; a run without one, or whose last one is an error, raises."""
ran = results(stream)
if not ran or ran[-1].get("is_error"):
raise ValueError(f"the run ended in an error: {ran[-1].get('result')}" if ran else "the stream has no result line")
return ran
def outcome(work, name):
"""The cost and seconds of an arm's run, its compaction included. A resumed session's cost counts from the session's start, so the start's cost comes off it."""
case, arm, number = advisor_bench.split_name(name)
ran = results(work / f"{name}.jsonl")
if not ran or ran[-1].get("is_error"):
raise ValueError(f"the run ended in an error: {ran[-1].get('result')}" if ran else "the stream has no result line")
ran = finished(work / f"{name}.jsonl")
compacted = results(work / f"{name}.compact.jsonl") if arm == "compact" else []
before = 0 if arm == "brief" else results(work / f"{case}-start-{number}.jsonl")[-1]["total_cost_usd"]
return {"cost": ran[-1]["total_cost_usd"] - before, "seconds": sum(entry["duration_ms"] for entry in [*compacted, *ran]) / 1000}