Answer the third round: show the judge loop-claude's prompts, one records answer per cycle through an interrupt, name the answer's two sources apart

This commit is contained in:
2026-10-03 00:54:16 +02:00
parent 160b1dae5f
commit 2f46a13e5d
10 changed files with 53 additions and 38 deletions
+11 -10
View File
@@ -19,7 +19,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from loop_claude import file_writes, paths
from loop_claude.claude_code import entries, session, transcript, trust
from loop_claude.cycle import archive, interrupt, judge, retry, run, states, worker
from loop_claude.cycle.verdicts import Finished, Interrupt, Recorded, Unfinished
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.limited import Limited
@@ -131,21 +131,22 @@ class Transitions(unittest.TestCase):
(states.Working(), states.WorkerRan("/t"), states.Judging("/t")),
(states.Working("A."), states.WorkerRan("/t"), states.Judging("/t", True)),
(states.Judging("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?")),
(states.Judging("/t", True), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?")),
(states.Judging("/t"), states.Ruled(Recorded("e", "Which one?", "A.")), states.Working("A.")),
(states.Judging("/t", True), states.Ruled(Recorded("e", "Which one?", "A.")), states.Interrupting("/t", "Which one?")),
(states.Judging("/t", True), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", True)),
(states.Judging("/t"), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Working("A.")),
(states.Judging("/t", True), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Interrupting("/t", "Which one?", True)),
(states.Judging("/t", True), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
(states.Judging("/t", True), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
(states.Judging("/t"), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
(states.Judging("/t"), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
(states.Interrupting("/t", "q"), states.Answered(), states.Judging("/t")),
(states.Interrupting("/t", "q"), states.HumanAnswered(), states.Judging("/t")),
(states.Interrupting("/t", "q", True), states.HumanAnswered(), states.Judging("/t", True)),
(states.Closing("/t", Finished("e")), states.Archived(), states.Ended()),
)
for state, event, after in legal:
with self.subTest(state=state, event=event):
self.assertEqual(states.transition(state, event), after)
every_state = (states.Working(), states.Working("A."), states.Judging("/t"), states.Judging("/t", True), states.Interrupting("/t", "q"), states.Closing("/t", Finished("e")), states.Ended())
every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Ruled(Recorded("e", "Which one?", "A.")), states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.Answered(), states.Archived())
every_state = (states.Working(), states.Working("A."), states.Judging("/t"), states.Judging("/t", True), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", True), states.Closing("/t", Finished("e")), states.Ended())
every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.HumanAnswered(), states.Archived())
for state in every_state:
for event in every_event:
if (state, event) not in [(state, event) for state, event, _ in legal]:
@@ -399,7 +400,7 @@ class Sections(unittest.TestCase):
class Render(unittest.TestCase):
def test_joins_assistant_text_and_tool_calls_and_human_turns_and_skips_the_rest(self):
def test_joins_assistant_text_tool_calls_human_turns_and_loop_prompts_and_skips_the_rest(self):
said = transcript.render([
human("do it"),
assistant({"type": "text", "text": "Starting."}, {"type": "tool_use", "name": "Bash", "input": {"command": "ls"}}),
@@ -411,7 +412,7 @@ class Render(unittest.TestCase):
queued("origin/main moved", "coordinator"),
{**human("Continue the task; the previous run stopped before it was finished."), "promptSource": "sdk"},
])
self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it\n\n[human] B, while you work')
self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it\n\n[human] B, while you work\n\n[loop] Continue the task; the previous run stopped before it was finished.')
class CopyFor(unittest.TestCase):
@@ -495,7 +496,7 @@ class Verdict(unittest.TestCase):
self.assertEqual(judge.verdict_from({"answer": "", "interrupt": False, "evidence": "e", "finished": True, "question": ""}), Finished("e"))
self.assertEqual(judge.verdict_from({"answer": "", "interrupt": False, "evidence": "e", "finished": False, "question": "ignored"}), Unfinished("e"))
self.assertEqual(judge.verdict_from({"answer": "", "interrupt": True, "evidence": "e", "finished": True, "question": "Which one?"}), Interrupt("e", "Which one?"))
self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": True, "evidence": "e", "finished": False, "question": "Which one?"}), Recorded("e", "Which one?", "A."))
self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": True, "evidence": "e", "finished": False, "question": "Which one?"}), AnsweredFromRecords("e", "Which one?", "A."))
self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": False, "evidence": "e", "finished": False, "question": ""}), Failure("the judge answered without interrupting"))
self.assertEqual(judge.verdict_from({"answer": "", "interrupt": "no", "evidence": "", "finished": True, "question": ""}), Failure("the judge's reply has no interrupt of type boolean"))
self.assertEqual(judge.verdict_from({"answer": "", "interrupt": False, "evidence": None, "finished": True, "question": ""}), Failure("the judge's reply has no evidence of type string"))