Answer the third round: show the judge loop-claude's prompts, one records answer per cycle through an interrupt, name the answer's two sources apart
This commit is contained in:
@@ -4,13 +4,13 @@ import typing
|
||||
|
||||
from loop_claude.claude_code.entries import hit_limit, limit_said, parse_entry, structured_output
|
||||
from loop_claude.cycle.retry import retried
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, Recorded, Unfinished, Verdict
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
# About 100,000 tokens, leaving a 200,000-token context room for the rest of the prompt; the largest session rendered here was 364,000 characters on 2026-10-03.
|
||||
# About 100,000 tokens, half a 200,000-token context; the largest session rendered here was 364,000 characters on 2026-10-03.
|
||||
JUDGED_TRANSCRIPT_TAIL = 400000
|
||||
|
||||
JUDGE_RULES = (
|
||||
@@ -27,7 +27,9 @@ JUDGE_RULES = (
|
||||
"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 "
|
||||
"is still open, never a question they already answered there.\n"
|
||||
"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 project's records; a question it answered "
|
||||
"is no longer open.\n"
|
||||
"Where the agent asked or flagged something itself, the question is that one, in the agent's own "
|
||||
"wording; never construct another from facts it stated.\n"
|
||||
"Where README.md or the project's records answer that question, quote the passage that answers it "
|
||||
@@ -85,8 +87,8 @@ def run_judge(root: str, args: list[str], prompt: str, rendered_transcript: str,
|
||||
if isinstance(verdict, Failure):
|
||||
return Failure(f"{verdict.reason}; it replied: {proc.stdout.strip() or 'nothing'}")
|
||||
if not grounded(verdict.evidence, rendered_transcript):
|
||||
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 | Recorded) else ""))
|
||||
if isinstance(verdict, Recorded) and not grounded(verdict.answer, recorded):
|
||||
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 | AnsweredFromRecords) else ""))
|
||||
if isinstance(verdict, AnsweredFromRecords) and not grounded(verdict.answer, recorded):
|
||||
return Failure(f"the judge answered {verdict.question!r} with {verdict.answer!r}, which README.md and the project's records do not hold")
|
||||
return verdict
|
||||
|
||||
@@ -97,7 +99,7 @@ def judge_prompt(task: str, premises: str, records: str, rendered_transcript: st
|
||||
f"The project's records, its working rules and decisions:\n{records or 'none'}\n\n"
|
||||
f"The task an agent was given:\n{task}\n\n"
|
||||
# The tail, where an interrupt or a finish lands; the session's transcript grows cycle over cycle.
|
||||
f"What the agent did and said, and what the human typed on [human] lines, latest last:\n{rendered_transcript[-JUDGED_TRANSCRIPT_TAIL:]}\n\n"
|
||||
f"What the agent did and said, what the human typed on [human] lines and what loop-claude told it on [loop] lines, latest last:\n{rendered_transcript[-JUDGED_TRANSCRIPT_TAIL:]}\n\n"
|
||||
f"{JUDGE_RULES}"
|
||||
)
|
||||
|
||||
@@ -108,14 +110,14 @@ def verdict_from(output: object) -> Verdict | Failure:
|
||||
for name, kind in REPLY_TYPES.items():
|
||||
if not isinstance(output.get(name), kind):
|
||||
return Failure(f"the judge's reply has no {name} of type {JSON_TYPES[kind]}")
|
||||
# An interrupt outranks finished: the human answers before the chunk can close.
|
||||
if output["answer"].strip() and not output["interrupt"]:
|
||||
return Failure("the judge answered without interrupting")
|
||||
# An interrupt outranks finished: the human answers before the chunk can close.
|
||||
if output["interrupt"]:
|
||||
if not output["question"].strip():
|
||||
return Failure("the judge interrupted without a question")
|
||||
if output["answer"].strip():
|
||||
return Recorded(output["evidence"], output["question"], output["answer"])
|
||||
return AnsweredFromRecords(output["evidence"], output["question"], output["answer"])
|
||||
return Interrupt(output["evidence"], output["question"])
|
||||
return Finished(output["evidence"]) if output["finished"] else Unfinished(output["evidence"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user