diff --git a/bin/agent_cycle/judge.py b/bin/agent_cycle/judge.py index 2243075a..a80eae93 100644 --- a/bin/agent_cycle/judge.py +++ b/bin/agent_cycle/judge.py @@ -74,7 +74,7 @@ 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. +# Between the task and the tail that quotes_checked searches, so that no fragment of a quote runs across the join. plain() keeps it, and the judge's quotes hold no NUL. PASSAGE_BREAK = "\x00" @@ -257,13 +257,13 @@ def quotes_checked(verdict: Verdict, grounds: Grounds) -> Verdict | Failure: return escalation_mark.checked(verdict, after=grounds.after_mark, shown=grounds.shown) -def grounded(evidence: str, rendered_transcript: str) -> bool: - """Whether the transcript holds the evidence word for word, once emphasis marks are stripped and whitespace is reflowed in both. The judge joins passages with an ellipsis though told to quote one, so each fragment between ellipses must come after the one before it.""" - transcript = plain(rendered_transcript) +def grounded(evidence: str, searched: str) -> bool: + """Whether the searched text holds the evidence word for word, once emphasis marks are stripped and whitespace is reflowed in both. The judge joins passages with an ellipsis though told to quote one, so each fragment between ellipses must come after the one before it.""" + searched = plain(searched) fragments = [fragment.strip() for fragment in re.split(r"\.\.\.|…", plain(evidence)) if fragment.strip()] after = 0 for fragment in fragments: - at = transcript.find(fragment, after) + at = searched.find(fragment, after) if at < 0: return False after = at + len(fragment) diff --git a/bin/agent_cycle/test_judge.py b/bin/agent_cycle/test_judge.py index cd132525..2239d010 100644 --- a/bin/agent_cycle/test_judge.py +++ b/bin/agent_cycle/test_judge.py @@ -124,7 +124,7 @@ class Verdict(unittest.TestCase): verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", "the project's decisions", "the plan or a comment", kinds(*entries), 1, "loop-claude"), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence="round 2: 🔴")]).effects()) self.assertEqual(verdict, Unfinished("round 2: 🔴", entries_read=2)) - def test_takes_the_task_as_evidence_where_the_tail_it_shows_cuts_off_the_workers_first_prompt(self): + def test_takes_the_task_as_evidence_where_the_tail_it_shows_cuts_off_the_workers_first_prompt_but_no_quote_across_the_join(self): entries = [human("Do the next chunk. " + "x" * judge.JUDGE_PROMPT_CHARS), assistant({"type": "text", "text": "Merged."})] def judged_on(evidence): return judge.judge_once("/r", judge.Brief("Do the next chunk.", "## Goals", "", "the project's decisions", "the plan or a comment", kinds(*entries), 0, "loop-claude"), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence=evidence)] * 3).effects()) diff --git a/bin/judge_replay/archived_prompt.py b/bin/judge_replay/archived_prompt.py index b6d40a3b..af1fccf4 100644 --- a/bin/judge_replay/archived_prompt.py +++ b/bin/judge_replay/archived_prompt.py @@ -9,7 +9,7 @@ from agent_cycle.worker_prompts import typed_answer def grounds_of(prompt: str, entries: list[Entry]) -> Grounds | Failure: - """What the quotes of a judge run on prompt are checked against, as judge_prompt would have made it for the transcript's entries: the premises and the records before the task are quotable, the transcript the judge was shown comes before the rules. The prompt is split on the headings judge_prompt writes, at the first of each; a Failure where it lacks one. Rules of an earlier wording stay part of the transcript, a slack that lets an evidence quote them pass.""" + """What the quotes of a judge run on prompt are checked against, as judge_prompt would have made it for the transcript's entries: the premises and the records before the task are quotable, the task is quotable as the evidence, and the transcript the judge was shown comes before the rules. The prompt is split on the headings judge_prompt writes, at the first of each; a Failure where it lacks one. Rules of an earlier wording stay part of the transcript, a slack that lets an evidence quote them pass.""" before_task, task_heading, after_task = prompt.partition(f"\n\n{TASK_HEADING}") heading = transcript_heading(LOOP_CLAUDE) task, found_heading, shown = after_task.partition(heading) diff --git a/bin/loop_claude/loop/usage.py b/bin/loop_claude/loop/usage.py index 2dd26fb9..46e4d7ec 100644 --- a/bin/loop_claude/loop/usage.py +++ b/bin/loop_claude/loop/usage.py @@ -184,7 +184,8 @@ Exit 1, saying why, when: 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 that - neither the task nor the transcript holds; it holds an elided passage when each fragment appears in order. + neither the task nor the transcript holds, where each fragment of an elided quote must appear in + order, in the task then the transcript. 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