Pin that an unquoted verdict retries like a failed one and three of either exit 1
This commit is contained in:
+12
-9
@@ -166,7 +166,8 @@ if "--json-schema" in args:
|
||||
open(os.environ["STUB_VERDICTS"], "w").write(" ".join(plan[1:]))
|
||||
if plan[0] == "fail":
|
||||
sys.exit(1)
|
||||
print(json.dumps({"structured_output": {"ask": False, "evidence": "", "finished": plan[0] == "finished", "question": ""}}))
|
||||
unquoted = plan[0] == "unquoted"
|
||||
print(json.dumps({"structured_output": {"ask": unquoted, "evidence": "invented" if unquoted else "", "finished": plan[0] == "finished", "question": "q?" if unquoted else ""}}))
|
||||
else:
|
||||
flag = "--session-id" if "--session-id" in args else "--resume"
|
||||
folder = os.path.expanduser("~/.claude/projects/p")
|
||||
@@ -177,26 +178,28 @@ else:
|
||||
|
||||
|
||||
class RunCycle(unittest.TestCase):
|
||||
def test_resumes_until_the_judge_calls_the_chunk_finished_and_rejudges_a_judge_failure(self):
|
||||
def test_resumes_until_the_judge_calls_the_chunk_finished_and_rejudges_a_failed_or_unquoted_verdict(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
stub = os.path.join(home, "claude")
|
||||
open(stub, "w").write(STUB_CLAUDE)
|
||||
os.chmod(stub, 0o700)
|
||||
calls, verdicts = os.path.join(home, "calls"), os.path.join(home, "verdicts")
|
||||
open(verdicts, "w").write("fail continue finished continue")
|
||||
open(verdicts, "w").write("fail continue finished unquoted continue")
|
||||
loop.ARCHIVE = os.path.join(home, "archive")
|
||||
environment = {"HOME": home, "PATH": f"{home}:{os.environ['PATH']}", "STUB_CALLS": calls, "STUB_VERDICTS": verdicts}
|
||||
with unittest.mock.patch.dict(os.environ, environment), unittest.mock.patch("time.sleep") as sleep:
|
||||
for _ in range(3):
|
||||
self.assertTrue(loop.run_cycle("task", "premises", "A name", SESSION_ID))
|
||||
open(verdicts, "w").write("fail fail fail")
|
||||
with self.assertRaises(SystemExit):
|
||||
loop.run_cycle("task", "premises", "A name", SESSION_ID)
|
||||
for plan in ("fail fail fail", "unquoted unquoted unquoted"):
|
||||
open(verdicts, "w").write(plan)
|
||||
with self.assertRaises(SystemExit) as stopped:
|
||||
loop.run_cycle("task", "premises", "A name", SESSION_ID)
|
||||
self.assertNotEqual(stopped.exception.code, 2)
|
||||
self.assertEqual(open(verdicts).read(), "")
|
||||
starts = [args[args.index("-p") + 1:][:3] for args in map(json.loads, open(calls)) if "--json-schema" not in args]
|
||||
self.assertEqual([start[1] for start in starts], ["--name", "--resume", "--name", "--resume"])
|
||||
self.assertEqual([start[1] for start in starts], ["--name", "--resume", "--name", "--resume", "--resume"])
|
||||
self.assertEqual(starts[1][2], SESSION_ID)
|
||||
self.assertEqual(sleep.call_count, 3)
|
||||
self.assertEqual(open(verdicts).read(), "")
|
||||
self.assertEqual(sleep.call_count, 6)
|
||||
[copy] = [name for _, _, names in os.walk(loop.ARCHIVE) for name in names]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user