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
@@ -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)},
|
||||
|
||||
Reference in new issue
Block a user