Answer the stability and product passes: print each records answer, name its question, drop a misquote to an interrupt, budget the whole prompt
This commit is contained in:
@@ -8,7 +8,7 @@ from loop_claude.cycle.interrupt import interrupt
|
||||
from loop_claude.cycle.judge import judge
|
||||
from loop_claude.cycle.retry import retried
|
||||
from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanAnswered, Interrupting, Judging, Ruled, State, WorkerRan, Working, transition
|
||||
from loop_claude.cycle.verdicts import Finished, Unfinished
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Unfinished
|
||||
from loop_claude.cycle.worker import run_worker, worker_args
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
@@ -52,8 +52,8 @@ def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
|
||||
|
||||
def step(cycle: Cycle, state: Active) -> Event | Stop:
|
||||
match state:
|
||||
case Working(answer, _):
|
||||
return work(cycle, answer)
|
||||
case Working(answered, _):
|
||||
return work(cycle, answered)
|
||||
case Judging(transcript_path, _):
|
||||
return rule(cycle, transcript_path)
|
||||
case Interrupting(transcript_path, question, _):
|
||||
@@ -64,9 +64,11 @@ def step(cycle: Cycle, state: Active) -> Event | Stop:
|
||||
typing.assert_never(state)
|
||||
|
||||
|
||||
def work(cycle: Cycle, answer: str | None) -> WorkerRan | Stop:
|
||||
def work(cycle: Cycle, answered: AnsweredFromRecords | None) -> WorkerRan | Stop:
|
||||
if answered is not None:
|
||||
print(f"\n=== the records answered: {answered.question} ===\n{answered.answer}", flush=True)
|
||||
# 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), answer), 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.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}")
|
||||
|
||||
Reference in New Issue
Block a user