Fix under the floor's Shape: interrupt means only the human, QuotedAnswer names the verdict, one owner for the record files, Limited beside its cycle
This commit is contained in:
@@ -3,20 +3,20 @@ import json
|
||||
import typing
|
||||
|
||||
from loop_claude.claude_code.entries import hit_limit, limit_said, parse_entry, structured_output
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.cycle.retry import retried
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
# At 3 to 4 characters a token, 100,000 to 133,000 tokens, which leaves a 200,000-token context room for the reply; the largest session rendered here was 364,000 characters on 2026-10-03.
|
||||
JUDGE_PROMPT_CHARS = 400000
|
||||
|
||||
JUDGE_RULES = (
|
||||
"Decide whether the agent has something open that the human must answer, or that README.md or the "
|
||||
"project's records answer. interrupt=true when any of these appear:\n"
|
||||
"- the agent asks the human anything, seeks approval, or says a decision is the human's\n"
|
||||
"Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n"
|
||||
"- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither "
|
||||
"README.md nor the project's records answer it\n"
|
||||
"- it carried on under an assumption that decides the deliverable, that the human could "
|
||||
"reasonably reject and that neither README.md nor the project's records settle; a caveat about "
|
||||
"transient state it then handled is not one\n"
|
||||
@@ -29,11 +29,12 @@ JUDGE_RULES = (
|
||||
"where a note goes - is not on its own a reason to interrupt. The human may have replied inside the transcript, on a [human] line: judge only what "
|
||||
"is still open, never a question they already answered there. A [loop] line is what loop-claude told "
|
||||
"the agent, such as an answer quoted from README.md or the project's records. A question a [loop] "
|
||||
"line answered is no longer open. If the agent asks it again, put it to the human, with answer empty.\n"
|
||||
"line answered is no longer open. If the agent asks it again, interrupt with that question.\n"
|
||||
"Where the agent asked or flagged something itself, the question is that one, in the agent's own "
|
||||
"wording; never construct another from facts it stated.\n"
|
||||
"Where README.md or the project's records answer that question, quote the passage that answers it "
|
||||
"in answer, verbatim, with interrupt=true; the agent is then given that passage in place of the human's reply.\n"
|
||||
"Where README.md or the project's records answer the agent's own question, set interrupt=false, put "
|
||||
"that question in question and quote the passage that answers it in answer, verbatim; the agent is "
|
||||
"then given that passage in place of the human's reply.\n"
|
||||
"finished=true when the chunk is complete: merged, or nothing remains that the agent could do on "
|
||||
"its own. finished=false when work remains that a further run can continue: an open PR, a review "
|
||||
"not yet run, CI not yet reported."
|
||||
@@ -41,11 +42,11 @@ JUDGE_RULES = (
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Reply:
|
||||
answer: str = dataclasses.field(metadata={"description": "The passage of README.md or the project's records that answers the agent's question, quoted verbatim. Empty when nothing there answers it, or when interrupt is false."})
|
||||
answer: str = dataclasses.field(metadata={"description": "With interrupt false, the passage of README.md or the project's records that answers the agent's question, quoted verbatim. Empty otherwise."})
|
||||
evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the transcript line the verdict rests on: what triggers the interrupt, else what shows the chunk finished or the work remaining."})
|
||||
finished: bool
|
||||
interrupt: bool
|
||||
question: str = dataclasses.field(metadata={"description": "The single question to put to the human. Empty when interrupt is false."})
|
||||
question: str = dataclasses.field(metadata={"description": "The single question to put to the human, or the agent's question that answer answers. Empty otherwise."})
|
||||
|
||||
|
||||
REPLY_TYPES = typing.get_type_hints(Reply)
|
||||
@@ -87,9 +88,9 @@ def run_judge(root: str, args: list[str], prompt: str, rendered_transcript: str,
|
||||
if isinstance(verdict, Failure):
|
||||
return Failure(f"{verdict.reason}; it replied: {proc.stdout.strip() or 'nothing'}")
|
||||
if not grounded(verdict.evidence, rendered_transcript):
|
||||
return Failure(f"the judge quoted {verdict.evidence!r}, which is not in the transcript" + (f", for the question: {verdict.question}" if isinstance(verdict, Interrupt | AnsweredFromRecords) else ""))
|
||||
return Failure(f"the judge quoted {verdict.evidence!r}, which is not in the transcript" + (f", for the question: {verdict.question}" if isinstance(verdict, Interrupt | QuotedAnswer) else ""))
|
||||
# Not a Failure: a misquote would otherwise exit an unattended loop.
|
||||
if isinstance(verdict, AnsweredFromRecords) and not grounded(verdict.answer, recorded):
|
||||
if isinstance(verdict, QuotedAnswer) and not grounded(verdict.answer, recorded):
|
||||
return Interrupt(verdict.evidence, verdict.question)
|
||||
return verdict
|
||||
|
||||
@@ -112,13 +113,13 @@ def verdict_from(output: object) -> Verdict | Failure:
|
||||
for name, kind in REPLY_TYPES.items():
|
||||
if not isinstance(output.get(name), kind):
|
||||
return Failure(f"the judge's reply has no {name} of type {JSON_TYPES[kind]}")
|
||||
# An interrupt outranks finished: the human answers before the chunk can close.
|
||||
# An interrupt outranks a quoted answer and finished: the human answers before the chunk can close.
|
||||
if output["interrupt"]:
|
||||
if not output["question"].strip():
|
||||
return Failure("the judge interrupted without a question")
|
||||
if output["answer"].strip():
|
||||
return AnsweredFromRecords(output["evidence"], output["question"], output["answer"])
|
||||
return Interrupt(output["evidence"], output["question"])
|
||||
if output["answer"].strip() and output["question"].strip():
|
||||
return QuotedAnswer(output["evidence"], output["question"], output["answer"])
|
||||
return Finished(output["evidence"]) if output["finished"] else Unfinished(output["evidence"])
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
T = typing.TypeVar("T")
|
||||
|
||||
@@ -8,12 +8,13 @@ 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 AnsweredFromRecords, Finished, Unfinished
|
||||
from loop_claude.cycle.verdicts import Finished, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle.worker import run_worker, worker_args
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.project.model_choice import Models
|
||||
from loop_claude.project.records import QUOTE_SOURCES
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -64,9 +65,9 @@ def step(cycle: Cycle, state: Active) -> Event | Stop:
|
||||
typing.assert_never(state)
|
||||
|
||||
|
||||
def work(cycle: Cycle, answered: AnsweredFromRecords | None) -> WorkerRan | Stop:
|
||||
def work(cycle: Cycle, answered: QuotedAnswer | None) -> WorkerRan | Stop:
|
||||
if answered is not None:
|
||||
print(f"\n=== README.md, AGENTS.md or docs/decisions.md answered: {answered.question} ===\n{answered.answer}", flush=True)
|
||||
print(f"\n=== {QUOTE_SOURCES} 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), answered), cycle.effects), cycle.effects):
|
||||
return stop
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
import dataclasses
|
||||
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.project.records import QUOTE_SOURCES
|
||||
|
||||
# A backstop for what the judge misses, such as a reworded repeat, so the worker cannot loop unattended on answers quoted from README.md or the records.
|
||||
RECORDS_ANSWERS_PER_CYCLE = 3
|
||||
QUOTED_ANSWERS_PER_CYCLE = 3
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Working:
|
||||
"""The worker runs, resumed with an answer quoted from README.md or the records when there is one."""
|
||||
answered: AnsweredFromRecords | None = None
|
||||
records_answers: int = 0
|
||||
answered: QuotedAnswer | None = None
|
||||
quoted_answers: int = 0
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Judging:
|
||||
"""The judge rules; records_answers counts the questions README.md or the records answered this cycle."""
|
||||
"""The judge rules; quoted_answers counts the questions README.md or the records answered this cycle."""
|
||||
transcript_path: str
|
||||
records_answers: int = 0
|
||||
quoted_answers: int = 0
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Interrupting:
|
||||
transcript_path: str
|
||||
question: str
|
||||
records_answers: int = 0
|
||||
quoted_answers: int = 0
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -67,19 +68,19 @@ Event = WorkerRan | Ruled | HumanAnswered | Archived
|
||||
|
||||
def transition(state: State, event: Event) -> State:
|
||||
match state, event:
|
||||
case Working(_, records_answers), WorkerRan(transcript_path):
|
||||
return Judging(transcript_path, records_answers)
|
||||
case Judging(_, records_answers), Ruled(AnsweredFromRecords() as answered) if records_answers < RECORDS_ANSWERS_PER_CYCLE:
|
||||
return Working(answered, records_answers + 1)
|
||||
case Judging(transcript_path, records_answers), Ruled(AnsweredFromRecords(question=question, answer=answer)):
|
||||
return Interrupting(transcript_path, f"{question}\n\nREADME.md, AGENTS.md or docs/decisions.md say:\n{answer}\n\nThey answered {records_answers} questions this cycle, so this one comes to you.", records_answers)
|
||||
case Judging(transcript_path, records_answers), Ruled(Interrupt(question=question)):
|
||||
return Interrupting(transcript_path, question, records_answers)
|
||||
case Working(_, quoted_answers), WorkerRan(transcript_path):
|
||||
return Judging(transcript_path, quoted_answers)
|
||||
case Judging(_, quoted_answers), Ruled(QuotedAnswer() as answered) if quoted_answers < QUOTED_ANSWERS_PER_CYCLE:
|
||||
return Working(answered, quoted_answers + 1)
|
||||
case Judging(transcript_path, quoted_answers), Ruled(QuotedAnswer(question=question, answer=answer)):
|
||||
return Interrupting(transcript_path, f"{question}\n\n{QUOTE_SOURCES} says:\n{answer}\n\nThey answered {quoted_answers} questions this cycle, so this one comes to you.", quoted_answers)
|
||||
case Judging(transcript_path, quoted_answers), Ruled(Interrupt(question=question)):
|
||||
return Interrupting(transcript_path, question, quoted_answers)
|
||||
case Judging(transcript_path, _), Ruled(Finished() | Unfinished() as verdict):
|
||||
return Closing(transcript_path, verdict)
|
||||
# The human works in the interrupt's claude session, so the judge rules again on the transcript it leaves.
|
||||
case Interrupting(transcript_path, _, records_answers), HumanAnswered():
|
||||
return Judging(transcript_path, records_answers)
|
||||
case Interrupting(transcript_path, _, quoted_answers), HumanAnswered():
|
||||
return Judging(transcript_path, quoted_answers)
|
||||
case Closing(), Archived():
|
||||
return Ended()
|
||||
raise ValueError(f"no transition from {state} on {event}")
|
||||
|
||||
@@ -8,7 +8,7 @@ class Interrupt:
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class AnsweredFromRecords:
|
||||
class QuotedAnswer:
|
||||
"""The agent asked a question that README.md or the project's records answer, quoted in answer."""
|
||||
evidence: str
|
||||
question: str
|
||||
@@ -25,4 +25,4 @@ class Unfinished:
|
||||
evidence: str
|
||||
|
||||
|
||||
Verdict = Interrupt | AnsweredFromRecords | Finished | Unfinished
|
||||
Verdict = Interrupt | QuotedAnswer | Finished | Unfinished
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until
|
||||
from loop_claude.claude_code.session import Session
|
||||
from loop_claude.claude_code.transcript import part_line
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.cycle.verdicts import QuotedAnswer
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.project.records import QUOTE_SOURCES
|
||||
|
||||
PRINTED_TOOL_INPUT = 160
|
||||
|
||||
@@ -38,9 +39,9 @@ def worker_outcome(code: int, result: dict | None, resets: list[int]) -> Failure
|
||||
return None if result is not None else Failure("claude exited 0 without a result event")
|
||||
|
||||
|
||||
def worker_args(task: str, session: Session, model: str, resuming: bool, answered: AnsweredFromRecords | None = None) -> list[str]:
|
||||
def worker_args(task: str, session: Session, model: str, resuming: bool, answered: QuotedAnswer | None = None) -> list[str]:
|
||||
if answered is not None:
|
||||
start = ["-p", f"Your question: {answered.question}\n\nREADME.md, AGENTS.md or docs/decisions.md answer it:\n\n{answered.answer}\n\nContinue the task.", "--resume", str(session.id)]
|
||||
start = ["-p", f"Your question: {answered.question}\n\n{QUOTE_SOURCES} answers it:\n\n{answered.answer}\n\nContinue the task.", "--resume", str(session.id)]
|
||||
elif resuming:
|
||||
start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session.id)]
|
||||
else:
|
||||
|
||||
@@ -3,11 +3,15 @@ import pathlib
|
||||
from loop_claude.project.checkout import read_checkout_file
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
RECORD_FILES = ("AGENTS.md", "docs/decisions.md")
|
||||
# Where an answer the judge quotes comes from, as the human and the worker read it.
|
||||
QUOTE_SOURCES = "README.md, " + " or ".join(RECORD_FILES)
|
||||
|
||||
|
||||
def read_records(root: str) -> str | Stop:
|
||||
"""AGENTS.md and docs/decisions.md, each headed by its path; a file the project lacks is left out."""
|
||||
records = []
|
||||
for name in ("AGENTS.md", "docs/decisions.md"):
|
||||
for name in RECORD_FILES:
|
||||
if not pathlib.Path(root, name).exists():
|
||||
continue
|
||||
text = read_checkout_file(root, name, "the judge cannot read the project's records")
|
||||
|
||||
+16
-15
@@ -19,10 +19,10 @@ 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 AnsweredFromRecords, Finished, Interrupt, Unfinished
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.loop import main, reload
|
||||
from loop_claude.project import checkout, model_choice, premises, records
|
||||
from loop_claude.stop import Stop
|
||||
@@ -92,7 +92,7 @@ def ran(stdout="", code=0, stderr=""):
|
||||
|
||||
|
||||
def judged(verdict, evidence="working", answer=""):
|
||||
reply = {"answer": answer, "evidence": evidence, "finished": verdict == "finished", "interrupt": verdict == "interrupt", "question": "Which one?" if verdict == "interrupt" else ""}
|
||||
reply = {"answer": answer, "evidence": evidence, "finished": verdict == "finished", "interrupt": verdict == "interrupt", "question": "Which one?" if verdict in ("interrupt", "quoted") else ""}
|
||||
return ran(json.dumps({"structured_output": reply}))
|
||||
|
||||
|
||||
@@ -127,15 +127,15 @@ class Streamed:
|
||||
|
||||
class Transitions(unittest.TestCase):
|
||||
def test_each_state_moves_on_its_events_and_only_on_them(self):
|
||||
answered = states.Ruled(AnsweredFromRecords("e", "Which one?", "A."))
|
||||
answered = states.Ruled(QuotedAnswer("e", "Which one?", "A."))
|
||||
legal = (
|
||||
(states.Working(), states.WorkerRan("/t"), states.Judging("/t")),
|
||||
(states.Working(AnsweredFromRecords("e", "Which one?", "A."), 3), states.WorkerRan("/t"), states.Judging("/t", 3)),
|
||||
(states.Working(QuotedAnswer("e", "Which one?", "A."), 3), states.WorkerRan("/t"), states.Judging("/t", 3)),
|
||||
(states.Judging("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?")),
|
||||
(states.Judging("/t", 3), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", 3)),
|
||||
(states.Judging("/t"), answered, states.Working(AnsweredFromRecords("e", "Which one?", "A."), 1)),
|
||||
(states.Judging("/t", 2), answered, states.Working(AnsweredFromRecords("e", "Which one?", "A."), 3)),
|
||||
(states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md say:\nA.\n\nThey answered 3 questions this cycle, so this one comes to you.", 3)),
|
||||
(states.Judging("/t"), answered, states.Working(QuotedAnswer("e", "Which one?", "A."), 1)),
|
||||
(states.Judging("/t", 2), answered, states.Working(QuotedAnswer("e", "Which one?", "A."), 3)),
|
||||
(states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md says:\nA.\n\nThey answered 3 questions this cycle, so this one comes to you.", 3)),
|
||||
(states.Judging("/t"), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
|
||||
(states.Judging("/t", 3), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
|
||||
(states.Judging("/t"), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
|
||||
@@ -147,7 +147,7 @@ class Transitions(unittest.TestCase):
|
||||
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(AnsweredFromRecords("e", "Which one?", "A."), 3), states.Judging("/t"), states.Judging("/t", 3), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", 3), states.Closing("/t", Finished("e")), states.Ended())
|
||||
every_state = (states.Working(), states.Working(QuotedAnswer("e", "Which one?", "A."), 3), states.Judging("/t"), states.Judging("/t", 3), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", 3), states.Closing("/t", Finished("e")), states.Ended())
|
||||
every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), answered, states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.HumanAnswered(), states.Archived())
|
||||
for state in every_state:
|
||||
for event in every_event:
|
||||
@@ -245,18 +245,18 @@ class Cycles(unittest.TestCase):
|
||||
self.assertIn("[human] the second", prompts[1])
|
||||
|
||||
def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_three_times_a_cycle(self):
|
||||
answered = judged("interrupt", answer="Use *A*.")
|
||||
answered = judged("quoted", answer="Use *A*.")
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 4, claude=[answered] * 4, on_terminal_claude=[0], git=[ran()])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()) as printed:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed"))
|
||||
resumed = fake.made("stream_claude")[1]
|
||||
self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md answer it:\n\nUse *A*.\n\nContinue the task.")
|
||||
self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md answers it:\n\nUse *A*.\n\nContinue the task.")
|
||||
self.assertEqual(len(fake.made("stream_claude")), 4)
|
||||
self.assertEqual(printed.getvalue().count("=== README.md, AGENTS.md or docs/decisions.md answered: Which one? ===\nUse *A*."), 3)
|
||||
self.assertIn("Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md say:\nUse *A*.\n\nThey answered 3 questions this cycle", said.getvalue())
|
||||
self.assertIn("Which one?\n\nREADME.md, AGENTS.md or docs/decisions.md says:\nUse *A*.\n\nThey answered 3 questions this cycle", said.getvalue())
|
||||
|
||||
def test_an_answer_the_records_do_not_hold_is_dropped_and_the_question_goes_to_the_human(self):
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt", answer="Use B.")], on_terminal_claude=[0], git=[ran()])
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("quoted", answer="Use B.")], on_terminal_claude=[0], git=[ran()])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed"))
|
||||
self.assertEqual(len(fake.made("stream_claude")), 1)
|
||||
@@ -502,7 +502,8 @@ 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?"}), AnsweredFromRecords("e", "Which one?", "A."))
|
||||
self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": False, "evidence": "e", "finished": False, "question": "Which one?"}), QuotedAnswer("e", "Which one?", "A."))
|
||||
self.assertEqual(judge.verdict_from({"answer": "A.", "interrupt": True, "evidence": "e", "finished": False, "question": "Which one?"}), Interrupt("e", "Which one?"))
|
||||
self.assertEqual(judge.verdict_from({"answer": "ignored", "interrupt": False, "evidence": "e", "finished": False, "question": ""}), Unfinished("e"))
|
||||
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"))
|
||||
@@ -534,7 +535,7 @@ class LoopRuns(unittest.TestCase):
|
||||
|
||||
class HelpLimits(unittest.TestCase):
|
||||
def test_help_states_the_limits_the_code_holds(self):
|
||||
self.assertIn(f"The {['second', 'third', 'fourth', 'fifth'][states.RECORDS_ANSWERS_PER_CYCLE - 1]} question they answer in one cycle", main.__doc__.replace("\n", " "))
|
||||
self.assertIn(f"The {['second', 'third', 'fourth', 'fifth'][states.QUOTED_ANSWERS_PER_CYCLE - 1]} question they answer in one cycle", main.__doc__.replace("\n", " "))
|
||||
|
||||
|
||||
class ExitContract(unittest.TestCase):
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable.
|
||||
|
||||
2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: when README.md or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 4.4); the fourth question README.md or those files answer in one cycle goes to the human with the judge's quote, so the cost is one interrupt.
|
||||
2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: when README.md or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 4.4); the fourth question that README.md or those files answer in one cycle goes to the human with the judge's quote, so the cost is one interrupt.
|
||||
|
||||
## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
|
||||
|
||||
|
||||
Reference in New Issue
Block a user