From d954fb002628f891e0b1269c51a457bd3b638bcf Mon Sep 17 00:00:00 2001 From: Lilleman Date: Thu, 19 Nov 2026 22:24:24 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20keep=20a=20?= =?UTF-8?q?judge's=20evidence=20quote=20from=20running=20across=20the=20ta?= =?UTF-8?q?sk=20and=20the=20tail,=20and=20name=20the=20task=20in=20the=20s?= =?UTF-8?q?chema=20and=20the=20rejection=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/agent_cycle/judge.py | 8 +++++--- bin/agent_cycle/test_judge.py | 1 + bin/agent_cycle/test_run.py | 2 +- bin/loop_claude/loop/test_usage.py | 4 ++-- bin/loop_claude/loop/usage.py | 4 ++-- bin/loop_claude/test_black_box.py | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/agent_cycle/judge.py b/bin/agent_cycle/judge.py index c1edb597..2243075a 100644 --- a/bin/agent_cycle/judge.py +++ b/bin/agent_cycle/judge.py @@ -74,6 +74,8 @@ def judge_rules(answer_destinations: str, driver: str) -> str: # Open the task and the transcript in the prompt; the premises and the records come before the task, the rules after the transcript. # judge_replay.archived_prompt splits each archived prompt on them, so rewording one makes every run archived before it replay as failed. TASK_HEADING = "The task the worker was given:\n" +# Between the task and the tail that quotes_checked searches, so that no quote runs across the join: plain() keeps it, and a quote has none. +PASSAGE_BREAK = "\x00" def transcript_heading(driver: str) -> str: @@ -85,7 +87,7 @@ class Reply: answer: str = dataclasses.field(metadata={"description": "With interrupt false, the passage of the premises or the records that answers the worker's question, quoted verbatim, without elisions. Empty otherwise."}) # Routes the worker one rung up, as the judge interrupts or quotes an answer, or on the next cycle: agent_cycle/escalation_mark.py. escalation: str = dataclasses.field(metadata={"description": "Empty unless the chunk is unfinished, interrupt is true or answer quotes a passage, and the worker's run ends {asks_higher_rung}, citing an escalation trigger. Then: a verbatim quote, without elisions, of the transcript passage where the trigger fired, such as a review round's commit title or the worker's report of the finding or failing test. {quote_after_step} Never a later mention of the trigger, and never the request itself."}) - evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the one transcript passage the verdict rests on, without elisions: what triggers the interrupt; for a quoted answer, the worker's question; else what shows the chunk finished or the work remaining."}) + evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the one passage of the task or the transcript the verdict rests on, without elisions: what triggers the interrupt; for a quoted answer, the worker's question; else what shows the chunk finished or the work remaining."}) finished: bool = dataclasses.field(metadata={"description": "Whether the chunk is finished."}) interrupt: bool = dataclasses.field(metadata={"description": "Whether the human must now be interrupted."}) answered_before: str = dataclasses.field(metadata={"description": "With interrupt true, a [human] line from earlier in the chunk that answered the question the worker asks now, quoted verbatim, without elisions. Empty otherwise."}) @@ -248,7 +250,7 @@ def quotes_checked(verdict: Verdict, grounds: Grounds) -> Verdict | Failure: Only a misquoted evidence fails. A Failure for any other would exit an unattended loop, so each changes the verdict instead. """ - if not grounded(verdict.evidence, f"{grounds.task}\n\n{grounds.shown}"): + if not grounded(verdict.evidence, f"{grounds.task}{PASSAGE_BREAK}{grounds.shown}"): return misquoted_evidence(verdict) verdict = re_ask_checked(verdict, grounds.shown) verdict = answer_checked(verdict, grounds.quotable) @@ -271,7 +273,7 @@ def grounded(evidence: str, rendered_transcript: str) -> bool: def misquoted_evidence(verdict: Verdict) -> Failure: asked = f", for the question: {verdict.question}" if isinstance(verdict, Interrupt | QuotedAnswer) else "" - return Failure(f"the judge quoted {verdict.evidence!r}, which is not in the transcript{asked}") + return Failure(f"the judge quoted {verdict.evidence!r}, which is not in the task or the transcript{asked}") def re_ask_checked(verdict: Verdict, shown: str) -> Verdict: diff --git a/bin/agent_cycle/test_judge.py b/bin/agent_cycle/test_judge.py index 780feece..cd132525 100644 --- a/bin/agent_cycle/test_judge.py +++ b/bin/agent_cycle/test_judge.py @@ -131,6 +131,7 @@ class Verdict(unittest.TestCase): self.assertEqual(judged_on("Do the next chunk."), Unfinished("Do the next chunk.", entries_read=2)) self.assertEqual(judged_on("Do the next chunk. ... Merged."), Unfinished("Do the next chunk. ... Merged.", entries_read=2)) self.assertIsInstance(judged_on("Do the next release."), Failure) + self.assertIsInstance(judged_on("next chunk. xxx"), Failure) class JudgePrompt(unittest.TestCase): diff --git a/bin/agent_cycle/test_run.py b/bin/agent_cycle/test_run.py index 99f2320a..e8be0e83 100644 --- a/bin/agent_cycle/test_run.py +++ b/bin/agent_cycle/test_run.py @@ -188,7 +188,7 @@ Worker: {OFF_LADDER} self.assertEqual(self.archived_outcomes(), [ "Task: Do it.\n\n" f"{stamp} Judge reply rejected: the judge's reply has no answer of type string\n\nReply:\n> {unfilled.stdout}\n\nJudge: judge-model\n\n" - f"{stamp} Judge reply rejected: the judge quoted 'never said', which is not in the transcript\n\nReply:\n> {misquoted.stdout}\n\nJudge: judge-model\n\n" + f"{stamp} Judge reply rejected: the judge quoted 'never said', which is not in the task or the transcript\n\nReply:\n> {misquoted.stdout}\n\nJudge: judge-model\n\n" f"{stamp} Verdict: finished\n\nEvidence:\n> working\n\nConfig: {CONFIG}\nJudge: judge-model\nWorker: {OFF_LADDER}\n"]) def test_archives_each_judge_runs_prompt_and_reply_beside_the_rejection_interrupt_and_verdict_it_gave(self): diff --git a/bin/loop_claude/loop/test_usage.py b/bin/loop_claude/loop/test_usage.py index af996f1d..1bb4148c 100644 --- a/bin/loop_claude/loop/test_usage.py +++ b/bin/loop_claude/loop/test_usage.py @@ -99,8 +99,8 @@ class JudgeFailures(unittest.TestCase): ("verdict_from", "'the judge interrupted without a question'", unasked), ("verdict_from", "'the judge quoted an answer without a question'", unasked), ("run_judge", "verdict.reason", field), - ("run_judge", "checked.reason", "quotes a passage the transcript does not hold"), - ("misquoted_evidence", "f'the judge quoted {verdict.evidence!r}, which is not in the transcript", "quotes a passage the transcript does not hold"), + ("run_judge", "checked.reason", "quotes a passage that neither the task nor the transcript holds"), + ("misquoted_evidence", "f'the judge quoted {verdict.evidence!r}, which is not in the task or the transcript", "quotes a passage that neither the task nor the transcript holds"), ("claude_reply", "f'could not start claude:", started), ("claude_reply", "proc.stderr.strip() or f'{who} exited", exited), ("claude_reply", 'f"{who} printed no json reply', unparsed), diff --git a/bin/loop_claude/loop/usage.py b/bin/loop_claude/loop/usage.py index 0b73d47f..2dd26fb9 100644 --- a/bin/loop_claude/loop/usage.py +++ b/bin/loop_claude/loop/usage.py @@ -183,8 +183,8 @@ Exit 1, saying why, when: - the worker or the judge fails three times running, retried a minute apart within the cycle. A worker fails when claude cannot start, exits non-zero, is killed, or ends without a result event; a judge when claude cannot start, exits non-zero or prints no json reply, or its reply misses or - mistypes a field, interrupts or quotes an answer without a question, or quotes a passage the - transcript does not hold; it holds an elided passage when each fragment appears in order. + mistypes a field, interrupts or quotes an answer without a question, or quotes a passage that + neither the task nor the transcript holds; it holds an elided passage when each fragment appears in order. A usage limit is not a failure, and restarts the count of three: the worker or the judge is retried 2 minutes after the limit resets, or every 10 minutes when the reset time is unknown or more than 2 minutes past. The judge's reply gives its reset time only as text, so the judge is diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index 020098ed..7b0d0ab8 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -726,8 +726,8 @@ class Cycles(unittest.TestCase): self.assertEqual(run.code, 130) self.assertEqual(run.roles(), ["worker", "judge", "judge", "judge", "worker", "judge"]) self.assertEqual(run.sleeps, [60, 60]) - self.assertIn("the judge quoted 'never said', which is not in the transcript, for the question: A or B?", run.stderr) - self.assertIn("retrying the judge in a minute: the judge quoted '', which is not in the transcript\n", run.stderr) + self.assertIn("the judge quoted 'never said', which is not in the task or the transcript, for the question: A or B?", run.stderr) + self.assertIn("retrying the judge in a minute: the judge quoted '', which is not in the task or the transcript\n", run.stderr) def test_retries_a_judge_claude_cannot_start(self): checkout = Checkout(self)