Name why a verdict is incomplete, say how to proceed off a terminal, and which claude could not start
This commit was merged in pull request #99.
This commit is contained in:
@@ -10,4 +10,4 @@ def needed(to, but):
|
||||
def off_terminal(to):
|
||||
if sys.stdin.isatty() and sys.stdout.isatty():
|
||||
return None
|
||||
return needed(to, "stdin or stdout is not a terminal")
|
||||
return needed(to, "stdin or stdout is not a terminal; rerun loop-claude on a terminal")
|
||||
|
||||
@@ -22,7 +22,7 @@ def interrupt(root, session_id, model, path, question, paths):
|
||||
try:
|
||||
subprocess.run(["claude", "--model", model, "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
||||
except OSError as failure:
|
||||
return Stop(1, f"could not start claude: {failure.strerror}")
|
||||
return Stop(1, f"could not start claude for the interrupt: {failure.strerror}")
|
||||
entries = read(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
|
||||
|
||||
@@ -54,8 +54,8 @@ def judge(root, task, premises, transcript, model):
|
||||
verdict = run_judge(root, args, prompt)
|
||||
if isinstance(verdict, Failure):
|
||||
failure = verdict.reason
|
||||
elif not complete(verdict):
|
||||
failure = "the judge returned no verdict"
|
||||
elif reason := incomplete(verdict):
|
||||
failure = reason
|
||||
elif not grounded(verdict, transcript):
|
||||
failure = f"the judge quoted {verdict['evidence']!r}, nothing in the transcript" + (f", for the question: {verdict['question']}" if verdict["interrupt"] else "")
|
||||
else:
|
||||
@@ -84,11 +84,16 @@ def judge_prompt(task, premises, transcript):
|
||||
)
|
||||
|
||||
|
||||
def complete(verdict):
|
||||
typed = isinstance(verdict, dict) and all(
|
||||
isinstance(verdict.get(name), bool if JUDGE_SCHEMA["properties"][name]["type"] == "boolean" else str) for name in JUDGE_SCHEMA["required"]
|
||||
)
|
||||
return typed and not (verdict["interrupt"] and not verdict["question"].strip())
|
||||
def incomplete(verdict):
|
||||
if not isinstance(verdict, dict):
|
||||
return "the judge returned no verdict"
|
||||
for name in JUDGE_SCHEMA["required"]:
|
||||
kind = JUDGE_SCHEMA["properties"][name]["type"]
|
||||
if not isinstance(verdict.get(name), bool if kind == "boolean" else str):
|
||||
return f"the judge's verdict has no {name} of type {kind}"
|
||||
if verdict["interrupt"] and not verdict["question"].strip():
|
||||
return "the judge interrupted without a question"
|
||||
return None
|
||||
|
||||
|
||||
def grounded(verdict, transcript):
|
||||
|
||||
Reference in New Issue
Block a user