Return the verdict from run_cycle's judge–interrupt loop
This commit was merged in pull request #113.
This commit is contained in:
@@ -19,25 +19,29 @@ def run_cycle(root, task, premises, models, paths):
|
||||
path = transcript_file(session)
|
||||
if not path:
|
||||
return Stop(1, f"claude left no transcript for session {session.id}")
|
||||
verdict = judge_through_interrupts(root, task, premises, models, session, path, paths)
|
||||
if isinstance(verdict, Stop):
|
||||
return verdict
|
||||
if verdict["finished"]:
|
||||
if failure := archive(root, path, f"Task: {task}\n\nVerdict: finished", paths):
|
||||
return Stop(1, failure.reason)
|
||||
delete_session(session)
|
||||
return Continue()
|
||||
|
||||
|
||||
def judge_through_interrupts(root, task, premises, models, session, path, paths):
|
||||
# The interrupt appends to this transcript, so each pass judges and archives it anew.
|
||||
while True:
|
||||
entries = read(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
verdict = judge(root, task, premises, render(entries), models.judge)
|
||||
if isinstance(verdict, Stop):
|
||||
if isinstance(verdict, Stop) or not verdict["interrupt"]:
|
||||
return verdict
|
||||
if not verdict["interrupt"]:
|
||||
break
|
||||
if failure := archive(root, path, f"Task: {task}\n\nVerdict: interrupt\n\n{verdict['question']}", paths):
|
||||
return Stop(1, failure.reason)
|
||||
if stop := interrupt(root, session.id, models.worker, path, verdict["question"], paths):
|
||||
return stop
|
||||
if verdict["finished"]:
|
||||
if failure := archive(root, path, f"Task: {task}\n\nVerdict: finished", paths):
|
||||
return Stop(1, failure.reason)
|
||||
delete_session(session)
|
||||
return Continue()
|
||||
|
||||
|
||||
def archive(root, path, note, paths):
|
||||
|
||||
Reference in New Issue
Block a user