Retry the judge under one rule: an unquoted verdict fails like an incomplete one
This commit is contained in:
+13
-18
@@ -10,7 +10,8 @@ unfinished chunk resumes the same session next cycle; a finished one starts a fr
|
||||
continue until that interrupt or Ctrl-C.
|
||||
|
||||
Exit 1: no task, no premises, claude leaves no transcript, or the worker or the judge fails three
|
||||
times running. Exit 2: the human is needed and no terminal is attached, or the interrupt ended
|
||||
times running; a verdict missing a field or quoting nothing in the transcript is a judge failure.
|
||||
Exit 2: the human is needed and no terminal is attached, or the interrupt ended
|
||||
without them typing anything. Before an interrupt every worktree is marked trusted in ~/.claude.json.
|
||||
|
||||
Each project has one session, "A ~/code/<path> auto-mode" (the absolute path outside ~/code),
|
||||
@@ -285,25 +286,19 @@ def judge(task, premises, transcript):
|
||||
"--permission-mode", "bypassPermissions",
|
||||
"--tools", "",
|
||||
]
|
||||
for attempt in range(2):
|
||||
proc = subprocess.run(["claude", *args], capture_output=True, input=judge_prompt(task, premises, transcript), text=True)
|
||||
prompt = judge_prompt(task, premises, transcript)
|
||||
for attempt in range(3):
|
||||
proc = subprocess.run(["claude", *args], capture_output=True, input=prompt, text=True)
|
||||
verdict = (parse(proc.stdout) or {}).get("structured_output") if proc.returncode == 0 else None
|
||||
if not complete(verdict):
|
||||
print(proc.stderr.strip() or "the judge returned no verdict", file=sys.stderr)
|
||||
return {}
|
||||
if grounded(verdict, transcript):
|
||||
return verdict
|
||||
print("the judge quoted nothing in the transcript twice - interrupting anyway", file=sys.stderr)
|
||||
return verdict
|
||||
|
||||
|
||||
def verdict_on(task, premises, path):
|
||||
for attempt in range(3):
|
||||
if verdict := judge(task, premises, render(entries(path))):
|
||||
failure = proc.stderr.strip() or "the judge returned no verdict"
|
||||
elif not grounded(verdict, transcript):
|
||||
failure = "the judge quoted nothing in the transcript"
|
||||
else:
|
||||
return verdict
|
||||
if attempt == 2:
|
||||
sys.exit("the judge failed three times running")
|
||||
print("the judge failed - retrying in a minute", file=sys.stderr)
|
||||
sys.exit(f"{failure} - the judge failed three times running")
|
||||
print(f"{failure} - retrying in a minute", file=sys.stderr)
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
@@ -324,12 +319,12 @@ def run_cycle(task, premises, name, session_id):
|
||||
path = session_file(session_id)
|
||||
if not path:
|
||||
sys.exit(f"claude left no transcript for session {session_id}")
|
||||
verdict = verdict_on(task, premises, path)
|
||||
verdict = judge(task, premises, render(entries(path)))
|
||||
while verdict["ask"]:
|
||||
archive(path, f"Task: {task}\n\nVerdict: needs input\n\n{verdict['question']}")
|
||||
if not interrupt(session_id, path, verdict["question"]):
|
||||
sys.exit(2)
|
||||
verdict = verdict_on(task, premises, path)
|
||||
verdict = judge(task, premises, render(entries(path)))
|
||||
if verdict["finished"]:
|
||||
archive(path, f"Task: {task}\n\nVerdict: finished")
|
||||
end_session(path)
|
||||
|
||||
Reference in New Issue
Block a user