The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(bench): update SWE-bench grading and instance list
Steven Enamakel51b117610a4a
diff --git a/bench/harnesses/swebench/grade.mjs b/bench/harnesses/swebench/grade.mjsnew file mode 100644index 0000000000..ac02a2bfb9--- /dev/null+++ b/bench/harnesses/swebench/grade.mjs@@ -0,0 +1,66 @@+#!/usr/bin/env node+// grade.mjs — score a finished run with the official SWE-bench evaluator.+// node swebench/grade.mjs --run-id ID --harness openhuman [--workers 2]+// Collects each task's patch.diff into predictions.jsonl, runs+// swebench.harness.run_evaluation, and writes grade.json {instance_id: resolved}.+// The official grader is the only source of "resolved"; nothing here re-scores.++import { spawnSync } from "node:child_process";+import fs from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";++const here = path.dirname(fileURLToPath(import.meta.url));+const root = path.resolve(here, "..");+const args = process.argv.slice(2);+const opt = (k, d) => (args.includes(k) ? args[args.indexOf(k) + 1] : d);+const runId = opt("--run-id");+const harness = opt("--harness");+const workers = opt("--workers", "2");+if (!runId || !harness) throw new Error("--run-id and --harness are required");++const dir = path.join(root, "results", runId, harness);+const preds = [];+for (const task of fs.readdirSync(dir)) {+ const patch = path.join(dir, task, "patch.diff");+ if (!fs.existsSync(patch)) continue;+ preds.push({+ instance_id: task.replace(/#r\d+$/, ""),+ model_name_or_path: harness,+ model_patch: fs.readFileSync(patch, "utf8"),+ });+}+const predPath = path.join(dir, "predictions.jsonl");+fs.writeFileSync(predPath, preds.map((p) => JSON.stringify(p)).join("\n") + "\n");++const py = path.join(root, ".cache", "swebench-venv", "bin", "python");+const r = spawnSync(+ py,+ [+ "-m", "swebench.harness.run_evaluation",+ "--dataset_name", "princeton-nlp/SWE-bench_Verified",+ "--predictions_path", predPath,+ "--max_workers", workers,+ "--run_id", `${runId}-${harness}`,+ "--namespace", "swebench",+ "--cache_level", "instance",+ ],+ { cwd: dir, stdio: "inherit" },+);+if (r.status !== 0) process.exit(r.status ?? 1);++// The evaluator writes <model>.<run_id>.json next to the cwd.+const reportFile = fs.readdirSync(dir).find((f) => f.endsWith(`${runId}-${harness}.json`));+if (!reportFile) throw new Error("evaluator produced no report file");+const report = JSON.parse(fs.readFileSync(path.join(dir, reportFile), "utf8"));+const resolved = new Set(report.resolved_ids ?? []);+const empty = new Set(report.empty_patch_ids ?? []);+const errored = new Set(report.error_ids ?? []);+const out = Object.fromEntries(+ preds.map((p) => [+ p.instance_id,+ { resolved: resolved.has(p.instance_id), empty_patch: empty.has(p.instance_id), error: errored.has(p.instance_id) },+ ]),+);+fs.writeFileSync(path.join(dir, "grade.json"), JSON.stringify(out, null, 2));+console.log(`graded ${preds.length}: resolved ${resolved.size}`);diff --git a/bench/harnesses/swebench/instances-10.txt b/bench/harnesses/swebench/instances-10.txtnew file mode 100644index 0000000000..675b04b519--- /dev/null+++ b/bench/harnesses/swebench/instances-10.txt@@ -0,0 +1,11 @@+# princeton-nlp/SWE-bench_Verified revision=default seed=20261001+django__django-13569+django__django-14672+django__django-15277+django__django-15572+matplotlib__matplotlib-24570+psf__requests-5414+pylint-dev__pylint-4970+scikit-learn__scikit-learn-14141+sympy__sympy-13031+sympy__sympy-16766diff --git a/bench/harnesses/swebench/prepare.py b/bench/harnesses/swebench/prepare.pynew file mode 100644index 0000000000..d26543854c--- /dev/null+++ b/bench/harnesses/swebench/prepare.py@@ -0,0 +1,81 @@+#!/usr/bin/env python3+"""Select a pinned, seeded subset of SWE-bench Verified and write a task suite.++ .cache/swebench-venv/bin/python swebench/prepare.py --n 10 --seed 20261001 \+ --out tasks/generated/swe [--pull]++Writes <out>/tasks.json plus one dir per instance holding prompt.txt, and+instances-<n>.txt next to this file (commit it: it is the fixed task list every+harness sees). Instances are sorted before sampling so the pick depends only on+the seed and the dataset revision, not on dataset row order.+"""+import argparse+import json+import pathlib+import random+import subprocess++from datasets import load_dataset++DATASET = "princeton-nlp/SWE-bench_Verified"+# Pin so "the same 10 tasks" stays true if the dataset is later edited.+REVISION = None # set by --revision; recorded in instances-<n>.txt header++# Identical for every harness. No hints about tests or the harness's own tools.+WRAPPER = """You are working in a git checkout of the repository at {workdir}. Resolve the following issue by editing the source code in place.++Do not modify or add test files unless the issue requires it. Make the smallest correct change. When you are done, stop; your changes are collected from the working tree.++<issue>+{problem_statement}+</issue>+"""+++def image_for(instance_id: str) -> str:+ # Official naming: django__django-11099 -> django_1776_django-11099+ return "swebench/sweb.eval.x86_64." + instance_id.replace("__", "_1776_").lower() + ":latest"+++def main() -> None:+ ap = argparse.ArgumentParser()+ ap.add_argument("--n", type=int, default=10)+ ap.add_argument("--seed", type=int, default=20261001)+ ap.add_argument("--out", default="tasks/generated/swe")+ ap.add_argument("--revision", default=None)+ ap.add_argument("--pull", action="store_true")+ args = ap.parse_args()++ ds = load_dataset(DATASET, split="test", revision=args.revision)+ rows = sorted(ds, key=lambda r: r["instance_id"])+ picked = random.Random(args.seed).sample(rows, args.n)+ picked.sort(key=lambda r: r["instance_id"])++ out = pathlib.Path(args.out).resolve()+ tasks = []+ for row in picked:+ d = out / row["instance_id"]+ d.mkdir(parents=True, exist_ok=True)+ (d / "prompt.txt").write_text(+ WRAPPER.format(workdir="/testbed", problem_statement=row["problem_statement"].strip())+ )+ tasks.append(+ {"id": row["instance_id"], "image": image_for(row["instance_id"]), "workdir": "/testbed", "dir": str(d)}+ )+ (out / "tasks.json").write_text(json.dumps(tasks, indent=2))++ here = pathlib.Path(__file__).parent+ (here / f"instances-{args.n}.txt").write_text(+ f"# {DATASET} revision={args.revision or 'default'} seed={args.seed}\n"+ + "\n".join(r["instance_id"] for r in picked)+ + "\n"+ )+ print(f"selected {len(picked)} instances -> {out}")+ if args.pull:+ for t in tasks:+ print("pull", t["image"])+ subprocess.run(["docker", "pull", t["image"]], check=True)+++if __name__ == "__main__":+ main()