18 lines
1.4 KiB
Python
18 lines
1.4 KiB
Python
from loop_claude.cycle.prompts import ANSWER_DESTINATIONS, DRIVER
|
|
from claude_code.entries import Entry
|
|
from agent_cycle import escalation_mark
|
|
from failure import Failure
|
|
from agent_cycle.judge import Grounds, judge_rules, TASK_HEADING, transcript_heading
|
|
from claude_code.transcript import human_answers
|
|
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."""
|
|
before_task, task_heading, after_task = prompt.partition(f"\n\n{TASK_HEADING}")
|
|
heading = transcript_heading(DRIVER)
|
|
_, found_heading, shown = after_task.partition(heading)
|
|
if not (task_heading and found_heading):
|
|
return Failure(f"the archived prompt lacks the heading {TASK_HEADING.strip()!r} or {heading.strip()!r}, which judge_prompt writes")
|
|
return Grounds(shown.removesuffix(f"\n\n{judge_rules(ANSWER_DESTINATIONS, DRIVER)}"), escalation_mark.after_mark(entries, 0), before_task, tuple(human_answers(entries, typed_answer)))
|