Bench a model step's handoff: resume, compact or a fresh session with a brief
This commit is contained in:
@@ -146,19 +146,25 @@ def run(work, name):
|
||||
"--no-session-persistence", "--output-format", "stream-json", "--verbose"],
|
||||
cwd=clone, stdout=out, stderr=subprocess.STDOUT)
|
||||
read_result((work / f"{name}.jsonl").read_text().splitlines())
|
||||
git(clone, "add", "--all")
|
||||
(work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base))
|
||||
changed = [*git(clone, "diff", "--cached", "--name-only", base).split(), *git(REPO, "diff", "--name-only", base, CASES[case][1]).split()]
|
||||
targets = [target for target in suite_targets(changed) if (clone / target).exists()] or ["bin"]
|
||||
tests = subprocess.run([str(RUN_HEAVY), *SUITE, *targets], cwd=clone, capture_output=True, text=True)
|
||||
(work / f"{name}.tests").write_text(f"exit {tests.returncode}\n{tests.stdout[-1500:]}")
|
||||
save_change(work, name, clone, CASES[case])
|
||||
return f"{name}: ran"
|
||||
|
||||
|
||||
def grade(work, name):
|
||||
"""Have the judge rule on one run's diff, blind to its arm, and save the verdict beside it."""
|
||||
def save_change(work, name, clone, commits):
|
||||
"""Save the clone's change since the case's start commit as <name>.diff, and the result of the tests of the packages that it or the merged change touches as <name>.tests."""
|
||||
base, merged = commits
|
||||
git(clone, "add", "--all")
|
||||
(work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base))
|
||||
changed = [*git(clone, "diff", "--cached", "--name-only", base).split(), *git(REPO, "diff", "--name-only", base, merged).split()]
|
||||
targets = [target for target in suite_targets(changed) if (clone / target).exists()] or ["bin"]
|
||||
tests = subprocess.run([str(RUN_HEAVY), *SUITE, *targets], cwd=clone, capture_output=True, text=True)
|
||||
(work / f"{name}.tests").write_text(f"exit {tests.returncode}\n{tests.stdout[-1500:]}")
|
||||
|
||||
|
||||
def grade(work, name, cases=None):
|
||||
"""Have the judge rule on one run's diff, blind to its arm, and save the verdict beside it. cases stands in for CASES where another bench grades its own."""
|
||||
case = split_name(name)[0]
|
||||
base, merged = CASES[case]
|
||||
base, merged = (cases or CASES)[case]
|
||||
prompt = (BENCH / "advisor-judge-prompt.md").read_text().format(
|
||||
text=item_text(git(REPO, "show", f"{base}:todo.md"), case), reference=git(REPO, "diff", base, merged, "--", ".", ":!todo.md", ":!docs", ":!CHANGELOG.md"),
|
||||
diff=(work / f"{name}.diff").read_text(), tests=(work / f"{name}.tests").read_text())
|
||||
|
||||
Reference in New Issue
Block a user