Answer architecture round 1: 3 🔴, 8 🟡; have the judge quote the worker's record of the trigger word for word, name the worker's rung on resume, give kept and stepped one floor and name stepped's two conditions

This commit is contained in:
2026-10-15 22:04:13 +02:00
parent 2f5d7a469d
commit aa7529b03f
6 changed files with 47 additions and 34 deletions
+7 -10
View File
@@ -30,7 +30,8 @@ JUDGE_RULES = (
"- it chose between alternatives that neither README.md nor the records discriminate "
"between - neither rules the rejected one out - and the choice materially changes the deliverable\n"
"interrupt=false otherwise. Bookkeeping the agent settled silently - what to document, wording, "
"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 "
"where a note goes - is not on its own a reason to interrupt, nor is a run ending with a request for a higher rung, "
"which is for loop-claude. 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 records.\n\n"
"Where the agent asked or flagged something itself, the question is that one, in the agent's own "
@@ -45,11 +46,7 @@ JUDGE_RULES = (
f"where README.md or the records above hold it, {', '.join(HUMAN_RULE_NAMES)} included. It also counts where "
f"the transcript shows the agent writing it into {ANSWER_DESTINATIONS}; writing it into "
f"{either(HUMAN_RULE_NAMES)} does not count. finished=false when work remains that a further run can "
"continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded.\n\n"
"The agent may end its run asking for a higher rung, citing an escalation trigger that ~/.claude/CLAUDE.md lists. "
"That request is for loop-claude, not a question for the human. Where the chunk is unfinished, quote in "
"escalation the passage that shows the trigger fired, such as the finding or the failing test. Leave "
"escalation empty where the agent asks for no higher rung, or where only its own claim shows the trigger."
"continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded."
)
@@ -59,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 the transcript passage that shows that trigger fired, other than the agent's own claim. 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, 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."})
@@ -158,11 +155,11 @@ 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 ""))
# Not a Failure: a misquote would otherwise exit an unattended loop. Never elided: stitched fragments can say what the records do not.
# 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)
# Not a Failure either: the worker's rung then holds, which is safe.
if isinstance(verdict, Unfinished) and verdict.escalation and not grounded(verdict.escalation, shown):
if isinstance(verdict, Unfinished) and verdict.escalation and not verbatim(verdict.escalation, shown):
return dataclasses.replace(verdict, escalation="")
return verdict
+7 -5
View File
@@ -1,6 +1,6 @@
from model_routing.ladder import climbed, highest, LADDER, Rung
from loop_claude.routing import escalation_cap, escalation_rungs
from model_routing.route import ESCALATION_MARKER, Route
from loop_claude.routing import escalation_rungs
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from markdown_text import quoted
@@ -38,7 +38,8 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str:
def escalation(route: Route, anchor: Rung | None) -> str:
"""The prompt's escalation sentences: the rungs escalation_rungs opens, the marker, and while a rung opens, the offer to resume the worker higher; empty off the ladder or on its top rung."""
"""The prompt's escalation sentences, the marker's among them. Empty off the ladder or on its top rung. Where escalation_rungs opens none, the worker escalates only with the human's yes.
Else they name the rungs it opens to a subagent, and offer to resume the worker one rung up for the rest of the chunk, up to the same rung."""
if anchor is None or route.rung not in LADDER[:-1]:
return ""
marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} <n>:`, n the trigger's number."
@@ -46,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 {escalation_cap(anchor, route)}."
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]}."
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}"
@@ -65,9 +66,10 @@ def reruns(route: Route, anchor: Rung | None) -> str:
def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str:
"""Names the project's rung again, since a step-up between cycles may have taken the worker above it."""
"""Names the worker's rung and the project's again, since a step-up between cycles may have taken the worker above the project's, and the worker learns whether its request for a higher rung went through."""
on = f" loop-claude runs you on {route.rung}." if anchor else ""
ruled = f" A judge ruled the chunk unfinished, quoting this passage of your transcript as the work remaining:\n\n{quoted(unfinished_evidence)}\n\n" if unfinished_evidence else " "
return f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.{off_the_projects_rung(route, anchor)}{escalation(route, anchor)}{reruns(route, anchor)}"
return f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.{on}{off_the_projects_rung(route, anchor)}{escalation(route, anchor)}{reruns(route, anchor)}"
def answered(question: str, answer: str) -> str: