Resume an unfinished chunk with the judge's quote of the work remaining

This commit is contained in:
2026-10-04 17:09:28 +02:00
parent f807bc8bd5
commit edbe3af024
9 changed files with 52 additions and 39 deletions
+5 -3
View File
@@ -26,12 +26,14 @@ class Cycle:
premises: str
project_key: str
records: str
# The evidence of the previous cycle's unfinished verdict, empty after any other.
remaining: str
root: str
session: Session
task: str
def run_cycle(cycle: Cycle) -> Stop | None:
def run_cycle(cycle: Cycle) -> Stop | Finished | Unfinished:
state: State = Working()
try:
while not isinstance(state, Ended):
@@ -41,7 +43,7 @@ def run_cycle(cycle: Cycle) -> Stop | None:
state = transition(state, event)
except KeyboardInterrupt:
return stopped(cycle, Stop(130, ""), "Ctrl-C")
return None
return state.verdict
def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
@@ -71,7 +73,7 @@ def work(cycle: Cycle, answered: QuotedAnswer | None) -> WorkerRan | Stop:
if stop := keep_answer(cycle, answered):
return stop
# session_open runs inside the lambda: a failed attempt may have opened the session.
if stop := retried("worker", lambda: run_worker(cycle.root, worker_args(cycle.task, cycle.session, cycle.models.worker, session_open(cycle.session), answered), cycle.effects), cycle.effects):
if stop := retried("worker", lambda: run_worker(cycle.root, worker_args(cycle.task, cycle.session, cycle.models.worker, session_open(cycle.session), answered, cycle.remaining), cycle.effects), cycle.effects):
return stop
path = transcript_file(cycle.session)
return WorkerRan(path) if path is not None else Stop(1, f"claude left no transcript for session {cycle.session.id}")