From 1f380af695af85e0d6f51d2a7a5895a2d0fc968a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 23:41:59 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20drop=20keys=20typed=20befor?= =?UTF-8?q?e=20the=20question=20when=20a=20release=20ready=20to=20cut=20op?= =?UTF-8?q?ens=20claude=20too,=20and=20say=20where=20item=20182's=20paste?= =?UTF-8?q?=20ends?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/cycle/interrupt.py | 4 ++-- bin/loop_claude/test_loop_claude.py | 13 +++++++------ todo.md | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/loop_claude/cycle/interrupt.py b/bin/loop_claude/cycle/interrupt.py index d73820f9..619d7927 100644 --- a/bin/loop_claude/cycle/interrupt.py +++ b/bin/loop_claude/cycle/interrupt.py @@ -27,10 +27,10 @@ def put_question(question: str, answer_here: bool, effects: Effects) -> str | Ta print(f"\n{question}", file=sys.stderr) if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()): return stop + # Keys typed while the worker ran wait on the terminal, so they would answer a question no one has read, here or in claude's session, which reads them too. 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() 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: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 23346e03..668d1780 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -388,7 +388,7 @@ class Cycles(unittest.TestCase): resumed = fake.made("stream_claude")[1] self.assertEqual(resumed[resumed.index("--resume") + 1], str(self.session.id)) typed = resumed[resumed.index("-p") + 1] - self.assertEqual(prompts.typed_answer(typed)[1], "Use B.") + self.assertEqual(prompts.typed_answer(typed).answer, "Use B.") self.assertIn("Which one?", typed) self.assertIn("Continue the task. The chunk is finished only once every answer the human typed in it", typed) judge_prompts = [stdin for args, stdin in fake.made("claude")] @@ -552,6 +552,7 @@ class Interrupts(unittest.TestCase): fake = FakeEffects(inputs=typed) self.assertEqual(self.put(fake, answer_here)[0], interrupt.Talk()) self.assertEqual(len(fake.made("input")), len(typed)) + self.assertEqual(fake.calls[0], ("discard_typed", None)) def test_stops_on_an_empty_answer_or_the_inputs_end(self): for typed, why, said in ((" ", "nothing was typed", ""), (EOFError(), "the input ended", "\n")): @@ -987,11 +988,11 @@ class TypedAnswers(unittest.TestCase): def test_splits_the_prompt_handing_over_the_answer_into_the_answer_on_the_line_after_its_marker_and_the_rest_and_no_other_prompt(self): route = Route(Rung("worker-model")) marked = "The human answered your question at loop-claude's terminal:\nB" - rest, answer = prompts.typed_answer(prompts.typed("Which one?", "Use B.", route, None, False)) - self.assertEqual(answer, "Use B.") - self.assertTrue(rest.startswith("Your question was: Which one?\n\nContinue the task.")) - self.assertEqual(prompts.typed_answer(prompts.typed(f"Which one?\n{marked}", "Use B.", route, None, False))[1], "Use B.") - self.assertEqual(prompts.typed_answer(prompts.typed("Which one?", "Use B.", Route(Routing.SONNET, 179, 2, 5), Routing.OPUS, True))[1], "Use B.") + typed = prompts.typed_answer(prompts.typed("Which one?", "Use B.", route, None, False)) + self.assertEqual(typed.answer, "Use B.") + self.assertTrue(typed.loop_words.startswith("Your question was: Which one?\n\nContinue the task.")) + self.assertEqual(prompts.typed_answer(prompts.typed(f"Which one?\n{marked}", "Use B.", route, None, False)).answer, "Use B.") + self.assertEqual(prompts.typed_answer(prompts.typed("Which one?", "Use B.", Route(Routing.SONNET, 179, 2, 5), Routing.OPUS, True)).answer, "Use B.") self.assertIsNone(prompts.typed_answer(prompts.answered("Which one?", marked, route, None, False))) self.assertIsNone(prompts.typed_answer(prompts.resumed(marked, route, None))) diff --git a/todo.md b/todo.md index a6a023ed..dd66f407 100644 --- a/todo.md +++ b/todo.md @@ -233,7 +233,7 @@ Raised by PR #302's paired ruling, where two of four seats read the project as w ### 182. Give the answer line of loop-claude's interrupts line editing, so an arrow key moves the cursor instead of typing an escape code into the human's answer. -`bin/loop_claude/cycle/interrupt.py`'s `put_question` reads the answer with `input()`, and nothing under `bin/` imports `readline`, so Left types `^[[D` into the answer the worker gets. Importing `readline` gives line editing, but it writes the prompt to stdout rather than stderr, and its bracketed paste can return several lines, which `prompts.typed_answer` reads only the first of. Raised by the product-owner review of PR #308. +`bin/loop_claude/cycle/interrupt.py`'s `put_question` reads the answer with `input()`, and nothing under `bin/` imports `readline`, so Left types `^[[D` into the answer the worker gets. Importing `readline` gives line editing, but it writes the prompt to stdout rather than stderr, and its bracketed paste can return several lines, while `prompts.typed_answer` ends the answer at its first blank line and shows the judge what follows as loop-claude's words. Raised by the product-owner review of PR #308. ### 171. Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.