eval: Track B repair metrics from transcripts, ajieval summary, authoring prompts
- native runs derive toolchain invocations, failed verifier/test cycles, first check and first public test from the transcript's shell commands (exit codes, per-language diagnostic patterns in the profiles) - ajieval summary: shareable PASS/FAIL matrix per task, per-cell metrics (verified, first attempt, repair cycles, tool calls, time, unique bundle, context via tools, provider cached/uncached, classification, caught by) and aggregates by language and agent - benchmark-authoring.md: owner's prompts for the benchmark author and the per-language reference implementers, order of work, re-gate rule, no commits to this repository between freeze and the 18th run, what comes back to the language developer
This commit is contained in:
1 parent
8b7911669d
commit
93cf553a77
9 files changed
+298
-33
No files matched your search
@@ -177,6 +177,10 @@ def main(argv=None):
|
||||
rp.add_argument("--json", action="store_true")
|
||||
rp.set_defaults(fn=lambda a: report.print_report(a.paths, a.json))
|
||||
|
||||
sm = sub.add_parser("summary", help="shareable summary: PASS/FAIL matrix, per-cell metrics, aggregates by language and agent")
|
||||
sm.add_argument("paths", nargs="+")
|
||||
sm.set_defaults(fn=lambda a: print(report.summary(a.paths)))
|
||||
|
||||
c = sub.add_parser("classify", help="record the primary failure category of a run (protocol §27)")
|
||||
c.add_argument("run")
|
||||
c.add_argument("category", choices=CATEGORIES)
|
||||
|
||||
@@ -28,6 +28,7 @@ networkless.
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -289,6 +290,74 @@ def sandbox_argv(workspace, home, binds, path_dirs, docs, env):
|
||||
return a
|
||||
|
||||
|
||||
def command_events(agent_name, transcript_path):
|
||||
"""(command, exit code, output) for every shell command in a transcript."""
|
||||
out = []
|
||||
pending = {}
|
||||
for line in open(transcript_path, encoding="utf-8", errors="replace"):
|
||||
line = line.strip()
|
||||
if not line.startswith("{"):
|
||||
continue
|
||||
try:
|
||||
e = json.loads(line)
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
if agent_name == "codex":
|
||||
item = e.get("item") or {}
|
||||
if e.get("type") == "item.completed" and item.get("type") == "command_execution":
|
||||
out.append((item.get("command") or "", item.get("exit_code"), item.get("aggregated_output") or ""))
|
||||
elif agent_name == "claude":
|
||||
msg = e.get("message") or {}
|
||||
for b in msg.get("content", []) if isinstance(msg.get("content"), list) else []:
|
||||
if b.get("type") == "tool_use" and b.get("name") == "Bash":
|
||||
pending[b.get("id")] = (b.get("input") or {}).get("command", "")
|
||||
elif b.get("type") == "tool_result" and b.get("tool_use_id") in pending:
|
||||
c = b.get("content")
|
||||
text = c if isinstance(c, str) else "\n".join(x.get("text", "") for x in (c or []) if isinstance(x, dict))
|
||||
m = re.match(r"Exit code (\d+)", text)
|
||||
code = int(m.group(1)) if m else (1 if b.get("is_error") else 0)
|
||||
out.append((pending.pop(b.get("tool_use_id")), code, text))
|
||||
elif agent_name == "opencode":
|
||||
part = e.get("part") or {}
|
||||
if e.get("type") == "tool_use" and part.get("tool") == "bash":
|
||||
st = part.get("state") or {}
|
||||
meta = st.get("metadata") or {}
|
||||
out.append(((st.get("input") or {}).get("command", ""), meta.get("exit"), st.get("output") or meta.get("output") or ""))
|
||||
return out
|
||||
|
||||
|
||||
def cycles(profile, test_command, commands):
|
||||
"""Repair-loop metrics (protocol §14, §15) derived from shell commands.
|
||||
A command counts as a toolchain invocation if it contains a verifier,
|
||||
compiler or test command of the language profile, or the task's public
|
||||
test command. A failing invocation whose output carries a diagnostic of
|
||||
the language is a failed verifier cycle; any other failing invocation
|
||||
with a test is a failed test cycle."""
|
||||
pat = re.compile(profile.get("diagnostic_pattern") or "$^")
|
||||
cls = profile.get("classify", {})
|
||||
checks = [p for k in ("check", "build") for p in cls.get(k, [])]
|
||||
tests = list(cls.get("test", [])) + ([test_command] if test_command else [])
|
||||
m = {"toolchain_invocations": 0, "failed_verifier_cycles": 0, "failed_test_cycles": 0,
|
||||
"first_check_accepted": None, "first_public_test_passed": None}
|
||||
for cmd, code, output in commands:
|
||||
has_check = any(p in cmd for p in checks)
|
||||
has_test = any(p in cmd for p in tests)
|
||||
if not (has_check or has_test):
|
||||
continue
|
||||
m["toolchain_invocations"] += 1
|
||||
diag = bool(pat.search(output or ""))
|
||||
failed = code not in (0, None) or diag
|
||||
if has_check and m["first_check_accepted"] is None:
|
||||
m["first_check_accepted"] = not diag and code in (0, None)
|
||||
if has_test and test_command and test_command in cmd and m["first_public_test_passed"] is None:
|
||||
m["first_public_test_passed"] = not failed
|
||||
if failed and diag:
|
||||
m["failed_verifier_cycles"] += 1
|
||||
elif failed and has_test:
|
||||
m["failed_test_cycles"] += 1
|
||||
return m
|
||||
|
||||
|
||||
def normalize_usage(u):
|
||||
"""Input (including cached), output and cached-input tokens from the
|
||||
differently named usage fields of the CLIs; None when not reported."""
|
||||
@@ -383,6 +452,7 @@ def run_native(task_dir, lang_name, agent_name, model, out_dir, effort=None, see
|
||||
facts = ag.parse(transcript)
|
||||
tokens = normalize_usage(facts.get("usage") or {})
|
||||
ctx = context.metrics(context.tool_events_native(agent_name, transcript), message, docs, tokens)
|
||||
cyc = cycles(profile, lang.get("test"), command_events(agent_name, transcript))
|
||||
with open(os.path.join(run_dir, "patch.diff"), "w") as f:
|
||||
f.write(diff_tree(pristine, workspace))
|
||||
verdict = record.evaluate(evaluator, workspace, lang_name, task.dir, lim["command_timeout"] * 4) if evaluator else None
|
||||
@@ -408,8 +478,11 @@ def run_native(task_dir, lang_name, agent_name, model, out_dir, effort=None, see
|
||||
"seed": seed,
|
||||
"metrics": {"elapsed_seconds": elapsed, "exit_code": code, "termination": termination, "tool_calls": facts.get("tool_calls"),
|
||||
"usage": facts.get("usage"), "agent_facts": {k: v for k, v in facts.items() if k not in ("usage", "tool_calls", "model")},
|
||||
"input_tokens": tokens["input"], "output_tokens": tokens["output"], "cached_input_tokens": tokens["cached_input"], "context": ctx, "failed_verifier_cycles": None, "failed_test_cycles": None,
|
||||
"first_check_accepted": None, "first_build_accepted": None},
|
||||
"input_tokens": tokens["input"], "output_tokens": tokens["output"], "cached_input_tokens": tokens["cached_input"], "context": ctx,
|
||||
"toolchain_invocations": cyc["toolchain_invocations"],
|
||||
"failed_verifier_cycles": cyc["failed_verifier_cycles"], "failed_test_cycles": cyc["failed_test_cycles"],
|
||||
"first_check_accepted": cyc["first_check_accepted"], "first_build_accepted": None,
|
||||
"first_public_test_passed": cyc["first_public_test_passed"], "cycles_source": "derived from transcript"},
|
||||
"transcript": "transcript.jsonl",
|
||||
"patch": "patch.diff",
|
||||
"final_repository": {"path": "workspace", "files": record.file_hashes(workspace)},
|
||||
|
||||
@@ -78,3 +78,60 @@ def markdown(rows):
|
||||
def print_report(paths, as_json=False):
|
||||
rows = aggregate(load(paths))
|
||||
print(json.dumps(rows, indent=2) if as_json else markdown(rows))
|
||||
|
||||
|
||||
def _agent_key(r):
|
||||
if r.get("track") == "B":
|
||||
return (r["agent"].get("label") or "") + " " + r["agent"]["name"]
|
||||
return (r["model"].get("class") or "") + " " + r["model"]["id"]
|
||||
|
||||
|
||||
def summary(paths):
|
||||
"""The shareable summary of an experiment (no task details beyond task
|
||||
IDs): the PASS/FAIL matrix per task, per-cell metrics, and aggregates
|
||||
by language and by agent/model."""
|
||||
runs = load(paths)
|
||||
langs = sorted({r["language"]["name"] for r in runs})
|
||||
agents = sorted({_agent_key(r) for r in runs})
|
||||
tasks = sorted({r["task"]["id"] for r in runs})
|
||||
out = []
|
||||
for t in tasks:
|
||||
out.append(f"### {t}\n")
|
||||
out.append("| agent | " + " | ".join(langs) + " |")
|
||||
out.append("|---|" + "---|" * len(langs))
|
||||
for a in agents:
|
||||
cells = []
|
||||
for lang in langs:
|
||||
rs = [r for r in runs if r["task"]["id"] == t and r["language"]["name"] == lang and _agent_key(r) == a]
|
||||
cells.append(" ".join("PASS" if r.get("accepted") else ("FAIL" if r.get("accepted") is False else "?") for r in rs) or "-")
|
||||
out.append(f"| {a} | " + " | ".join(cells) + " |")
|
||||
out.append("")
|
||||
head = ["task", "language", "agent", "verified", "first attempt", "repair cycles", "tool calls", "seconds",
|
||||
"unique bundle", "context via tools", "provider input cached/uncached", "classification", "caught by"]
|
||||
out.append("### Cells\n")
|
||||
out.append("| " + " | ".join(head) + " |")
|
||||
out.append("|" + "---|" * len(head))
|
||||
for r in sorted(runs, key=lambda r: (r["task"]["id"], r["language"]["name"], _agent_key(r))):
|
||||
m = r["metrics"]
|
||||
ctx = m.get("context") or {}
|
||||
pin = ctx.get("provider_input_tokens") or {}
|
||||
cyc = None if m.get("failed_verifier_cycles") is None else m["failed_verifier_cycles"] + (m.get("failed_test_cycles") or 0)
|
||||
cl = r.get("classification") or {}
|
||||
out.append("| " + " | ".join(str(x) for x in [
|
||||
r["task"]["id"], r["language"]["name"], _agent_key(r), "PASS" if r.get("accepted") else "FAIL",
|
||||
m.get("first_public_test_passed"), cyc, m.get("tool_calls"), m.get("elapsed_seconds"),
|
||||
ctx.get("unique_reference_tokens"), ctx.get("cumulative_context_tokens"), f"{pin.get('cached')}/{pin.get('uncached')}",
|
||||
cl.get("category", "-" if r.get("accepted") else "unclassified"), cl.get("caught_by") or "-"]) + " |")
|
||||
out.append("")
|
||||
for title, keyf in (("language", lambda r: r["language"]["name"]), ("agent", _agent_key)):
|
||||
out.append(f"### By {title}\n")
|
||||
out.append(f"| {title} | runs | accepted | VSR | mean repair cycles | mean tool calls | mean seconds | mean uncached input |")
|
||||
out.append("|---|---|---|---|---|---|---|---|")
|
||||
for k in sorted({keyf(r) for r in runs}):
|
||||
rs = [r for r in runs if keyf(r) == k]
|
||||
acc = sum(1 for r in rs if r.get("accepted"))
|
||||
cyc = [r["metrics"]["failed_verifier_cycles"] + (r["metrics"].get("failed_test_cycles") or 0) for r in rs if r["metrics"].get("failed_verifier_cycles") is not None]
|
||||
unc = [((r["metrics"].get("context") or {}).get("provider_input_tokens") or {}).get("uncached") for r in rs]
|
||||
out.append(f"| {k} | {len(rs)} | {acc} | {round(acc / len(rs), 3)} | {mean(cyc)} | {mean([r['metrics'].get('tool_calls') for r in rs])} | {mean([r['metrics'].get('elapsed_seconds') for r in rs])} | {mean(unc)} |")
|
||||
out.append("")
|
||||
return "\n".join(out)
|
||||
Reference in new issue
Block a user