Refuse a compact arm whose compaction failed, and state the bench as it ran
This commit is contained in:
@@ -25,7 +25,7 @@ class StoppedAtBudget(unittest.TestCase):
|
||||
self.assertFalse(handoff_bench.stopped_at_budget([result_line()]))
|
||||
|
||||
def test_fails_where_the_stream_has_no_result(self):
|
||||
self.assertFalse(handoff_bench.stopped_at_budget(['{"type": "assistant"}']))
|
||||
self.assertFalse(handoff_bench.stopped_at_budget(['{"type": "assistant"}', "[]"]))
|
||||
|
||||
|
||||
class Summary(unittest.TestCase):
|
||||
@@ -61,7 +61,7 @@ class Orchestration(unittest.TestCase):
|
||||
self.commit({"bin/other/o.py": "o = 2\n"})
|
||||
self.calls, self.heavy = [], []
|
||||
self.start_result = {"subtype": "error_max_budget_usd", "is_error": True, "total_cost_usd": 1.0}
|
||||
self.strong_result = {}
|
||||
self.compact_result, self.strong_result = {}, {}
|
||||
real_run = subprocess.run
|
||||
for patch in (
|
||||
unittest.mock.patch.object(advisor_bench, "REPO", self.repo),
|
||||
@@ -100,7 +100,7 @@ class Orchestration(unittest.TestCase):
|
||||
kwargs["stdout"].write(result_line(**self.start_result) + "\n")
|
||||
elif args[2] == "/compact":
|
||||
self.transcript.write_text(self.transcript.read_text() + "compacted\n")
|
||||
kwargs["stdout"].write(result_line(total_cost_usd=1.25, duration_ms=3000) + "\n")
|
||||
kwargs["stdout"].write(result_line(**self.compact_result, total_cost_usd=1.25, duration_ms=3000) + "\n")
|
||||
else:
|
||||
if "--resume" in args:
|
||||
self.transcript.write_text(self.transcript.read_text() + "strong\n")
|
||||
@@ -193,8 +193,8 @@ class Orchestration(unittest.TestCase):
|
||||
self.assertEqual(claude[:2] + claude[3:], [
|
||||
"claude", "-p", *handoff_bench.STRONG.flags(), "--no-session-persistence", "--setting-sources", "project",
|
||||
"--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"])
|
||||
self.assertEqual(claude[2], handoff_bench.run_prompt("7") + "\n" + (handoff_bench.BENCH / "handoff-brief-prompt.md").read_text())
|
||||
self.assertIn("## Handoff", claude[2])
|
||||
self.assertIn("### 7. Do the seventh thing.", claude[2])
|
||||
self.assertTrue(claude[2].endswith("- End with a two-line summary of what you changed.\n\n\n## Handoff\n\n" + (handoff_bench.BENCH / "handoff-brief-prompt.md").read_text().split("## Handoff\n\n")[1]), claude[2][-400:])
|
||||
self.assertIn("+++ b/bin/pkg/done_1.py", (self.work / "7-brief-1.diff").read_text())
|
||||
|
||||
def test_each_arm_begins_on_the_tree_and_the_session_that_start_left(self):
|
||||
@@ -225,6 +225,14 @@ class Orchestration(unittest.TestCase):
|
||||
handoff_bench.run(self.work, "7-brief-1")
|
||||
save_change.assert_not_called()
|
||||
|
||||
def test_run_refuses_a_compact_arm_whose_compaction_failed_before_the_strong_model_runs(self):
|
||||
self.started()
|
||||
self.compact_result = {"is_error": True, "result": "no conversation to compact"}
|
||||
with self.assertRaisesRegex(ValueError, "^the run ended in an error: no conversation to compact$"):
|
||||
handoff_bench.run(self.work, "7-compact-1")
|
||||
self.assertEqual([args[2] for args, _, _ in self.calls], ["/compact"])
|
||||
self.assertFalse((self.work / "7-compact-1.jsonl").exists())
|
||||
|
||||
def test_outcome_refuses_a_stream_with_no_result_line(self):
|
||||
self.started()
|
||||
(self.work / "7-brief-1.jsonl").write_text("not json\n[]\n")
|
||||
|
||||
Reference in New Issue
Block a user