From ccc6b8adb2b6b88d737f985f35be3574da78faea Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 22:11:42 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20let=20one=20trigger=20buy?= =?UTF-8?q?=20one=20step,=20list=20run=5Fjudge's=20three=20quote=20checks?= =?UTF-8?q?=20in=20one=20place,=20rename=20floor=20to=20kept=5Frung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/cycle/judge.py | 10 +++++++--- bin/loop_claude/cycle/prompts.py | 2 +- bin/loop_claude/routing.py | 8 ++++---- bin/loop_claude/test_loop_claude.py | 4 ++-- docs/decisions.md | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/bin/loop_claude/cycle/judge.py b/bin/loop_claude/cycle/judge.py index 2cd1598f..6ebd83cd 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -56,7 +56,7 @@ class Reply: # Routes the next cycle's worker. Counting the item the chunk was routed on is harmless: loop-claude never steps the worker down. bundled: int = dataclasses.field(metadata={"description": "The highest R + C the agent states for a todo.md item it took into this chunk; 0 when it states none."}) # Routes the next cycle's worker one rung up: docs/decisions.md → `routing: a worker that ends its run asking for a higher rung`. - escalation: str = dataclasses.field(metadata={"description": "Where the chunk is unfinished and the agent's run ends asking for a higher rung, citing an escalation trigger: a verbatim quote, without elisions, of an earlier transcript passage that shows that trigger fired, such as a review round's commit title or the agent's report of the finding or the failing test; never the request itself. Empty otherwise."}) + escalation: str = dataclasses.field(metadata={"description": "Where the chunk is unfinished and the agent's run ends asking for a higher rung, citing an escalation trigger: a verbatim quote, without elisions, of an earlier transcript passage that shows that trigger fired since any earlier request for a higher rung, such as a review round's commit title or the agent's report of the finding or the failing test; never the request itself. Empty otherwise."}) 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 agent'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."}) @@ -147,6 +147,12 @@ def judge_args(rung: Rung) -> list[str]: def run_judge(root: str, args: list[str], prompt: str, shown: str, quotable: str, effects: Effects) -> Verdict | Failure | Limited: + """One judge run, its three quotes each checked against what they quote: + - evidence, against shown, its fragments in order: a misquote is a Failure, which judge retries; + - a quoted answer, against quotable, word for word: a misquote puts the question to the human; + - an escalation, against shown, word for word: a misquote drops it, so the worker's rung holds. + A misquoted answer or escalation is no Failure, which would otherwise exit an unattended loop. Neither may be elided, since stitched fragments can say what the records or the transcript do not. + """ reply = claude_reply(effects.claude, args, root, prompt, "the judge") if isinstance(reply, Failure | Limited): return reply @@ -155,8 +161,6 @@ def run_judge(root: str, args: list[str], prompt: str, shown: str, quotable: str return Failure(f"{verdict.reason}; it replied: {json.dumps(reply, ensure_ascii=False)}") if not grounded(verdict.evidence, shown): 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 "")) - # A misquoted answer or escalation is no Failure, which would otherwise exit an unattended loop: the question goes to the human, and the worker's rung holds. - # Never elided: stitched fragments can say what the records or the transcript do not. if isinstance(verdict, QuotedAnswer) and not verbatim(verdict.answer, quotable): return Interrupt(verdict.evidence, verdict.question) if isinstance(verdict, Unfinished) and verdict.escalation and not verbatim(verdict.escalation, shown): diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index a16b1510..eebb3ba2 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -47,7 +47,7 @@ def escalation(route: Route, anchor: Rung | None) -> str: if not rungs: return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand the hard part of a task to a subagent with the Agent tool set to `{climbed(route.rung, 1).agent_args()}`, one rung above yours, only once the human agrees.{marked}" further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else "" - resumed_higher = f" Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming the trigger that fired: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to {rungs[-1]}." + resumed_higher = f" Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming a trigger that fired since your last such request: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to {rungs[-1]}." return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}{resumed_higher}" diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 2b25f094..eae38f87 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -32,10 +32,10 @@ def first_route(anchor: Rung, item: Item | None) -> Route: def kept(route: Route, anchor: Rung) -> bool: """Whether a chunk keeps route: its rung is on the ladder and at or above item_rung.""" - return floor(anchor, route) == route.rung + return kept_rung(anchor, route) == route.rung -def floor(anchor: Rung, route: Route) -> Rung: +def kept_rung(anchor: Rung, route: Route) -> Rung: """The route's rung, raised to item_rung where it is lower or off the ladder; kept and stepped both hold a route to it.""" return highest(route.rung, item_rung(anchor, route)) @@ -77,8 +77,8 @@ def stepped(anchor: Rung, route: Route, bundled: int, escalated: bool) -> Route: def taken_in(anchor: Rung, route: Route, bundled: int) -> Rung: - """floor, raised to the rung bundled picks from anchor; bundled is the highest R + C the judge saw the worker take into the chunk, 0 for none.""" - return highest(floor(anchor, route), picked(anchor, bundled)) if bundled else floor(anchor, route) + """kept_rung, raised to the rung bundled picks from anchor; bundled is the highest R + C the judge saw the worker take into the chunk, 0 for none.""" + return highest(kept_rung(anchor, route), picked(anchor, bundled)) if bundled else kept_rung(anchor, route) def judge_rung(judge_model: str, route: Route) -> Rung: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 41ce4d1f..18e4afeb 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -677,11 +677,11 @@ class WorkerArgs(unittest.TestCase): self.assertIn("hand the hard part of the task to a subagent with the Agent tool set to `model fable, effort max`, one rung above yours;", prompts.resumed("", Route(Rung("claude-opus-5-5", "max"), 3, 13), opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 9), opus)) - self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number. Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming the trigger that fired: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `model opus, effort xhigh`. A reviewer", prompts.fresh("Do it.", "## Goals", Route(opus), opus)) + self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number. Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming a trigger that fired since your last such request: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `model opus, effort xhigh`. A reviewer", prompts.fresh("Do it.", "## Goals", Route(opus), opus)) def test_offers_the_worker_a_higher_rung_for_the_rest_of_the_chunk_up_to_the_escalation_cap(self): opus = Rung("claude-opus-5-5", "medium") - offer = " Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming the trigger that fired: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `model opus, effort xhigh`." + offer = " Where the hard part is the rest of the chunk, end your run instead, asking for a higher rung and naming a trigger that fired since your last such request: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `model opus, effort xhigh`." self.assertIn(f"`Escalation trigger :`, n the trigger's number.{offer}", prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus)) self.assertIn(f"`Escalation trigger :`, n the trigger's number.{offer}", prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus)) self.assertNotIn("Where the hard part", prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus)) diff --git a/docs/decisions.md b/docs/decisions.md index 3aabcea8..f8b3cfdf 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -222,7 +222,7 @@ Valid while the ladder orders its rungs by competence. 2026-10-15, lilleman asked for it. Serves goals 1.1 and 1.4: when the hard part is the rest of the chunk, handing it to subagents piece by piece leaves the worker, which reads and checks each of their diffs, on a rung that proved too low. The worker climbs only once its run records a trigger. -loop-claude's prompt offers the step beside the escalated subagent of `routing: a worker hands a task one rung up`, while a rung opens to that subagent without the human's yes. The worker then ends its run asking for a higher rung and naming the trigger. The judge quotes an earlier passage that shows the trigger fired, such as a review round's commit title or the worker's report of the failing test, never the request itself. The judge sees the worker's text and tool calls but no tool results, so the quote shows that the run recorded the trigger, not that a tool's output bears it out. loop-claude checks the quote word for word, as it checks a quoted answer, since stitched fragments can make up a trigger. Without such a quote, the rung holds. A misquote is no failure, since holding the rung is safe and three failures stop an unattended loop. The next prompt names the worker's rung, so the worker learns whether the step went through. +loop-claude's prompt offers the step beside the escalated subagent of `routing: a worker hands a task one rung up`, while a rung opens to that subagent without the human's yes. The worker then ends its run asking for a higher rung and naming the trigger. The judge quotes an earlier passage that shows the trigger fired, such as a review round's commit title or the worker's report of the failing test, never the request itself. The trigger must have fired since any earlier such request, so one trigger buys one step. The judge sees the worker's text and tool calls but no tool results, so the quote shows that the run recorded the trigger, not that a tool's output bears it out. loop-claude checks the quote word for word, as it checks a quoted answer, since stitched fragments can make up a trigger. Without such a quote, the rung holds. A misquote is no failure, since holding the rung is safe and three failures stop an unattended loop. The next prompt names the worker's rung, so the worker learns whether the step went through. The step is one rung, taken from the rung any item the judge saw taken in picks, and it restarts the count towards the step every second unfinished verdict takes; when both fall on one verdict, the worker steps once. It stops at the limit escalated subagents stop at, two rungs above the rung the chunk started on. Past that limit the rung holds: loop-claude takes no yes from the human between cycles, so a worker there asks the human for an escalated subagent instead. The judge keeps its rung, as `routing: on a model judge-replay covered` says.