Put the three-strikes rule in strike, shared by the worker and the judge

This commit is contained in:
2026-09-27 16:56:06 +02:00
parent 5280ef2800
commit 6628d33987
2 changed files with 13 additions and 12 deletions
+12 -10
View File
@@ -44,6 +44,7 @@ Claude Code internals this rests on, observed on 2.1.282, the model catalog on 2
""" """
import dataclasses import dataclasses
import glob import glob
import itertools
import json import json
import os import os
import shutil import shutil
@@ -125,11 +126,14 @@ def run_loop(argv):
if isinstance(failure, Stop): if isinstance(failure, Stop):
return failure return failure
state = dataclasses.replace(state, failures=state.failures + 1 if failure else 0) state = dataclasses.replace(state, failures=state.failures + 1 if failure else 0)
if not failure: if failure and (stop := strike("worker", state.failures, failure)):
continue return stop
if state.failures == 3:
return Stop(1, f"the worker failed three times running: {failure}")
print(f"retrying the worker in a minute: {failure}", file=sys.stderr) def strike(who, failures, failure):
if failures == 3:
return Stop(1, f"the {who} failed three times running: {failure}")
print(f"retrying the {who} in a minute: {failure}", file=sys.stderr)
time.sleep(60) time.sleep(60)
@@ -485,7 +489,7 @@ def judge(root, task, premises, transcript, chosen):
"--tools", "", "--tools", "",
] ]
prompt = judge_prompt(task, premises, transcript) prompt = judge_prompt(task, premises, transcript)
for attempt in range(3): for failures in itertools.count(1):
proc = subprocess.run(["claude", *args], capture_output=True, cwd=root, input=prompt, text=True) proc = subprocess.run(["claude", *args], capture_output=True, cwd=root, input=prompt, text=True)
verdict = (parse(proc.stdout) or {}).get("structured_output") if proc.returncode == 0 else None verdict = (parse(proc.stdout) or {}).get("structured_output") if proc.returncode == 0 else None
if not complete(verdict): if not complete(verdict):
@@ -494,10 +498,8 @@ def judge(root, task, premises, transcript, chosen):
failure = f"the judge quoted {verdict['evidence']!r}, nothing in the transcript, asking: {verdict['question']}" failure = f"the judge quoted {verdict['evidence']!r}, nothing in the transcript, asking: {verdict['question']}"
else: else:
return verdict return verdict
if attempt == 2: if stop := strike("judge", failures, failure):
return Stop(1, f"the judge failed three times running: {failure}") return stop
print(f"retrying the judge in a minute: {failure}", file=sys.stderr)
time.sleep(60)
def judge_prompt(task, premises, transcript): def judge_prompt(task, premises, transcript):
-1
View File
@@ -6,7 +6,6 @@ Ships when a four-seat scoring run puts every dimension and the overall at 7.0 o
Locality, 6.25: Locality, 6.25:
- Put the three-strikes rule in one place, today `main` for the worker and `judge` for the judge.
- Say in `run_cycle` that the interrupt appends to the transcript under the loop and that `archive` skips a stamp already written, today inferred from `archive`. - Say in `run_cycle` that the interrupt appends to the transcript under the loop and that `archive` skips a stamp already written, today inferred from `archive`.
- Name each clause of `typed` for the entry kind it drops, so one edit cannot silently change what both `human_turns` and `render` see. - Name each clause of `typed` for the entry kind it drops, so one edit cannot silently change what both `human_turns` and `render` see.