Answer principles round 1: 0 🔴, 6 🟡; correct the interrupt's definition, show the judge the question beside the typed answer, ask in one call returning Talk, add a Talking state, give the worker its own question past the cap, assert the prompts' facts, and keep stepped_from as the step's one owner

This commit is contained in:
2026-10-17 23:32:21 +02:00
parent 44fa8a7fe6
commit 4b2d4a1734
14 changed files with 153 additions and 92 deletions
+17 -8
View File
@@ -1,3 +1,4 @@
import dataclasses
import sys
import uuid
@@ -16,20 +17,28 @@ TALK = "/talk"
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
def put_question(question: str, effects: Effects) -> Stop | None:
"""Prints question for the human; a Stop where loop-claude is off a terminal, so no one can answer it."""
@dataclasses.dataclass(frozen=True)
class Talk:
"""The human answers in the worker's claude session, which talk opens."""
def put_question(question: str, answer_here: bool, effects: Effects) -> str | Talk | Stop:
"""Prints question for the human. Where answer_here, returns the line they type at loop-claude's terminal, stripped, or Talk where they type TALK; else Talk at once. A Stop where loop-claude is off a terminal, or they type nothing, or the input ends."""
print(f"\n{question}", file=sys.stderr)
return needs_terminal(ANSWER_QUESTION, effects.on_terminal())
def read_answer(effects: Effects) -> str | Stop:
"""The line the human types at loop-claude's terminal, stripped: their answer, or TALK where they ask for claude's session; a Stop where they type nothing or the input ends."""
if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()):
return stop
if not answer_here:
return Talk()
# Keys typed while the worker ran wait on the terminal, so they would answer a question no one has read. A paste's lines after the first are dropped with them at the next question, never taken as its answer; a longer answer goes through TALK.
effects.discard_typed()
try:
answer = effects.input(ASK_ANSWER).strip()
except EOFError:
print(file=sys.stderr)
return needs_human(ANSWER_QUESTION, "the input ended")
return answer or needs_human(ANSWER_QUESTION, "nothing was typed")
if not answer:
return needs_human(ANSWER_QUESTION, "nothing was typed")
return Talk() if answer == TALK else answer
def talk(root: str, session_id: uuid.UUID, worker: Rung, path: str, paths: Paths, env: dict[str, str], effects: Effects) -> Stop | None: