Answer stability round 1: 0 🔴, 1 🟡; test the exit 1 a rejected reply that cannot be archived causes, and tidy keep's type and docstrings
This commit is contained in:
@@ -133,9 +133,9 @@ def verdict_from(output: object) -> Verdict | Failure:
|
||||
return Unfinished(output["evidence"], bundled, output["escalation"])
|
||||
|
||||
|
||||
def judge(root: str, task: str, premises: str, records: str, rendered_transcript: str, rung: Rung, effects: Effects, keep: typing.Callable[[Failure], Stop | None]) -> Verdict | Stop:
|
||||
"""keep sees each failure of a judge run, such as a Rejected reply, before the retry."""
|
||||
return retried("judge", lambda: judge_once(root, task, premises, records, rendered_transcript, rung, effects), effects, keep)
|
||||
def judge(root: str, task: str, premises: str, records: str, rendered_transcript: str, rung: Rung, effects: Effects, keep: typing.Callable[[Rejected], Stop | None]) -> Verdict | Stop:
|
||||
"""keep sees each reply loop-claude rejected, the last of three included; a Stop from it ends the retrying."""
|
||||
return retried("judge", lambda: judge_once(root, task, premises, records, rendered_transcript, rung, effects), effects, lambda failure: keep(failure) if isinstance(failure, Rejected) else None)
|
||||
|
||||
|
||||
def judge_once(root: str, task: str, premises: str, records: str, rendered_transcript: str, rung: Rung, effects: Effects) -> Verdict | Failure | Limited:
|
||||
@@ -165,10 +165,11 @@ def run_judge(root: str, args: list[str], prompt: str, shown: str, quotable: str
|
||||
if isinstance(reply, Failure | Limited):
|
||||
return reply
|
||||
verdict = verdict_from(structured_output(reply))
|
||||
replied = json.dumps(reply, ensure_ascii=False)
|
||||
if isinstance(verdict, Failure):
|
||||
return Rejected(verdict.reason, json.dumps(reply, ensure_ascii=False))
|
||||
return Rejected(verdict.reason, replied)
|
||||
if not grounded(verdict.evidence, shown):
|
||||
return Rejected(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 ""), json.dumps(reply, ensure_ascii=False))
|
||||
return Rejected(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 ""), replied)
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user