Give the judge what the project records and ten times more of the chunk's transcript
This commit is contained in:
@@ -10,18 +10,20 @@ from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
JUDGED_TRANSCRIPT_TAIL = 40000
|
||||
# About 100,000 tokens, so the prompt fits a 200,000-token context; the largest session rendered here was 364,000 on 2026-10-03.
|
||||
JUDGED_TRANSCRIPT_TAIL = 400000
|
||||
|
||||
JUDGE_RULES = (
|
||||
"Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n"
|
||||
"- the agent asks the human anything, seeks approval, or says a decision is the human's\n"
|
||||
"- it carried on under an assumption that decides the deliverable and that the human could "
|
||||
"reasonably reject; a caveat about transient state it then handled is not one\n"
|
||||
"- it carried on under an assumption that decides the deliverable, that the human could "
|
||||
"reasonably reject and that neither README.md nor the project's records settle; a caveat about "
|
||||
"transient state it then handled is not one\n"
|
||||
"- it is blocked on something only the human can supply: a credential, a version bump, a release "
|
||||
"ready to cut, a choice outside the repo\n"
|
||||
"- it flags that the goals, the plan or the task itself is unclear, missing or in need of change\n"
|
||||
"- it chose between alternatives the README text does not discriminate between - it does not "
|
||||
"rule the rejected one out - and the choice materially changes the deliverable\n"
|
||||
"- it chose between alternatives that neither README.md nor the project's 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 "
|
||||
"is still open, never a question they already answered there.\n"
|
||||
@@ -49,7 +51,7 @@ JUDGE_SCHEMA = {
|
||||
}
|
||||
|
||||
|
||||
def judge(root: str, task: str, premises: str, rendered_transcript: str, model: str, effects: Effects) -> Verdict | Stop:
|
||||
def judge(root: str, task: str, premises: str, records: str, rendered_transcript: str, model: str, effects: Effects) -> Verdict | Stop:
|
||||
# No tools, so the verdict rests on the transcript grounded() checks it against; no persistence, so its runs stay out of the session picker.
|
||||
args = [
|
||||
"-p",
|
||||
@@ -60,7 +62,7 @@ def judge(root: str, task: str, premises: str, rendered_transcript: str, model:
|
||||
"--permission-mode", "bypassPermissions",
|
||||
"--tools", "",
|
||||
]
|
||||
prompt = judge_prompt(task, premises, rendered_transcript)
|
||||
prompt = judge_prompt(task, premises, records, rendered_transcript)
|
||||
return retried("judge", lambda: run_judge(root, args, prompt, rendered_transcript, effects), effects)
|
||||
|
||||
|
||||
@@ -83,9 +85,10 @@ def run_judge(root: str, args: list[str], prompt: str, rendered_transcript: str,
|
||||
return verdict
|
||||
|
||||
|
||||
def judge_prompt(task: str, premises: str, rendered_transcript: str) -> str:
|
||||
def judge_prompt(task: str, premises: str, records: str, rendered_transcript: str) -> str:
|
||||
return (
|
||||
f"From README.md:\n{premises}\n\n"
|
||||
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"
|
||||
|
||||
@@ -24,6 +24,7 @@ class Cycle:
|
||||
paths: Paths
|
||||
premises: str
|
||||
project_key: str
|
||||
records: str
|
||||
root: str
|
||||
session: Session
|
||||
task: str
|
||||
@@ -75,7 +76,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
|
||||
entries = read_transcript(transcript_path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
verdict = judge(cycle.root, cycle.task, cycle.premises, render(entries), cycle.models.judge, cycle.effects)
|
||||
verdict = judge(cycle.root, cycle.task, cycle.premises, cycle.records, render(entries), cycle.models.judge, cycle.effects)
|
||||
return verdict if isinstance(verdict, Stop) else Ruled(verdict)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user