Put the three-strikes rule in strike, shared by the worker and the judge
This commit is contained in:
+13
-11
@@ -44,6 +44,7 @@ Claude Code internals this rests on, observed on 2.1.282, the model catalog on 2
|
||||
"""
|
||||
import dataclasses
|
||||
import glob
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
@@ -125,12 +126,15 @@ def run_loop(argv):
|
||||
if isinstance(failure, Stop):
|
||||
return failure
|
||||
state = dataclasses.replace(state, failures=state.failures + 1 if failure else 0)
|
||||
if not failure:
|
||||
continue
|
||||
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)
|
||||
time.sleep(60)
|
||||
if failure and (stop := strike("worker", state.failures, failure)):
|
||||
return stop
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def run_cycle(root, task, premises, name, session_id, chosen):
|
||||
@@ -485,7 +489,7 @@ def judge(root, task, premises, transcript, chosen):
|
||||
"--tools", "",
|
||||
]
|
||||
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)
|
||||
verdict = (parse(proc.stdout) or {}).get("structured_output") if proc.returncode == 0 else None
|
||||
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']}"
|
||||
else:
|
||||
return verdict
|
||||
if attempt == 2:
|
||||
return Stop(1, f"the judge failed three times running: {failure}")
|
||||
print(f"retrying the judge in a minute: {failure}", file=sys.stderr)
|
||||
time.sleep(60)
|
||||
if stop := strike("judge", failures, failure):
|
||||
return stop
|
||||
|
||||
|
||||
def judge_prompt(task, premises, transcript):
|
||||
|
||||
@@ -6,7 +6,6 @@ Ships when a four-seat scoring run puts every dimension and the overall at 7.0 o
|
||||
|
||||
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`.
|
||||
- Name each clause of `typed` for the entry kind it drops, so one edit cannot silently change what both `human_turns` and `render` see.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user