How to Run SWE-bench Locally: One Gold Patch, Docker and the Report

How do you run SWE-bench locally?
To run SWE-bench locally, install its Python package, list one code change per task in a file, let it run each project’s tests in Docker, and read its report.
Running the human fix first checks your setup before you measure an agent. Invented example: if a function turns “Hello, World!” into a slug with two dashes, a fix is resolved only if its test and the other tests pass. On our MacBook Air M4 (Colima, swebench 5.0.2), SymPy task 20590’s human fix came back resolved in about nine minutes.
SWE-bench is a benchmark for AI coding agents, a fixed set of tasks with a fixed way to score answers, used in model evaluation.
Each task in the original set, Lite and Verified is a real GitHub issue from a Python repository. An agent, a program around a language model that reads code and runs commands (see agentic coding), answers with a patch: a file listing line changes.
You run the harness, the program that applies a patch, runs the tests and records the result, on the gold patch: the human fix from the issue’s pull request. A pass shows the setup works for this task; measuring an agent comes later.
How a task is graded: how SWE-bench grades a task. Which split, a named set of tasks, to use: the split guide.
Step 1: Install the swebench package
Install the package and datasets, which downloads the tasks from Hugging Face ($PY is your Python):
"$PY" -m venv venv
venv/bin/pip install -q --upgrade pip
venv/bin/pip install -q "swebench==5.0.2" datasets
Pin the version: release 5.0 changed the commands (it added swebench eval), so another release may not match this guide. The README says the old python -m swebench.harness.run_evaluation form still works.
| Piece | Our run |
|---|---|
| Python | 3.12.16 (needs 3.10 or newer) |
| swebench, datasets | 5.0.2, 5.2.0 |
Step 2: Load Lite and Verified and print one task
Both are subsets of the full set: Lite, which the docs recommend for beginners; Verified, checked by human reviewers. load.py loads both:
HF_HOME=<work>/hf-cache venv/bin/python -I load.py <out_dir>
SWE-bench/SWE-bench_Lite [test] rows=300
SWE-bench/SWE-bench_Lite [dev] rows=23
SWE-bench/SWE-bench_Verified [test] rows=500
We picked sympy__sympy-20590, the README’s smoke test (a quick setup check), in both subsets. Issue: SymPy’s Symbol objects gained an unwanted __dict__. Fields:
problem_statement: the issue text.patch: the gold patch.test_patch: tests the pull request added.FAIL_TO_PASS: tests failing before the fix, passing after: the issue is fixed.PASS_TO_PASS: tests passing before and after: nothing broke.
"FAIL_TO_PASS_count": 1,
"FAIL_TO_PASS": [
"test_immutable"
],
"PASS_TO_PASS_count": 21,
Both lists are public fields of the dataset.
Step 3: Write the predictions file
The harness reads patches from a JSONL file: one JSON object per task, with instance_id, model_name_or_path and model_patch. Our predictions.py writes a gold file and a broken one (the step numbers in its comments are from our test notes, not this guide’s steps):
"""Write predictions JSONL files for one task and check them with the harness's own loader.
Run: HF_HOME=<work>/hf-cache venv/bin/python -I predictions.py <out_dir>
Writes:
predictions-gold.jsonl the gold patch as a "model" prediction (for step 2)
predictions-broken.jsonl a patch that cannot apply (for step 3: error vs unresolved; NOT run here)
No container is started.
"""
import json
import sys
from pathlib import Path
from swebench.harness.utils import get_predictions_from_file, load_swebench_dataset
OUT = Path(sys.argv[1])
IID = "sympy__sympy-20590"
DS = "SWE-bench/SWE-bench_Verified"
inst = load_swebench_dataset(DS, "test", [IID])[0]
print("image field:", inst.get("image"))
print("eval_type:", inst.get("eval_type"), "| log_parser:", inst.get("log_parser"))
print("eval_script head:\n" + "\n".join((inst.get("eval_script") or "").splitlines()[:12]))
gold = {"instance_id": IID, "model_name_or_path": "m4-gold-file", "model_patch": inst["patch"]}
# Targets a file that does not exist in the repo: every apply method fails
# (git apply, git apply --3way, git apply --reject, patch --fuzz=5).
broken_patch = (
"diff --git a/sympy/core/no_such_file.py b/sympy/core/no_such_file.py\n"
"--- a/sympy/core/no_such_file.py\n"
"+++ b/sympy/core/no_such_file.py\n"
"@@ -1,3 +1,3 @@\n"
" line one\n"
"-line two\n"
"+line 2\n"
" line three\n"
)
broken = {"instance_id": IID, "model_name_or_path": "m4-broken-file", "model_patch": broken_patch}
for name, pred in [("predictions-gold.jsonl", gold), ("predictions-broken.jsonl", broken)]:
path = OUT / name
path.write_text(json.dumps(pred) + "\n")
loaded = get_predictions_from_file(str(path), DS, "test")
assert len(loaded) == 1 and set(loaded[0]) == {"instance_id", "model_name_or_path", "model_patch"}
print(f"{name}: {path.stat().st_size} bytes, keys {sorted(loaded[0])} -> harness loader OK")
# What --gold builds internally, to show the file matches it except for the model name.
g = get_predictions_from_file("gold", DS, "test", instance_ids=[IID])[0]
print("--gold internal prediction keys:", sorted(g), "| model_name_or_path:", g["model_name_or_path"])
print("gold file patch == --gold patch:", g["model_patch"] == gold["model_patch"])
- The top loads the task.
goldwraps the human fix;model_name_or_pathnames the report.broken_patchedits a missing file, so it cannot apply.- The loop writes each file and re-reads it with the harness’s loader.
- The end checks the file matches the
--goldflag the run uses:True.
Step 4: Start Docker on a Mac with Colima
Each task runs in a Docker container built from an image, a saved copy of the project’s environment. The docs name Docker Desktop; we used Colima, which runs Docker in a small Linux virtual machine (VM):
HOMEBREW_NO_AUTO_UPDATE=1 brew install colima docker docker-buildx
colima start --cpu 6 --memory 8 --disk 80 --vm-type vz
git clone --depth 1 https://github.com/SWE-bench/swe-bench-tasks.git ./swe-bench-tasks
venv/bin/swebench dataset check ./swe-bench-tasks
The task repository holds each task’s build recipe; on M-series Macs the README says to build from it. dataset check checks the clone. Our full setup.sh also registers Docker’s buildx build plugin.
| Docs recommend | Our run | |
|---|---|---|
| Machine | x86_64 (arm64 “experimental”) | M4, arm64 |
| CPU / RAM | 8 cores / 16 GB | 6 / 8 GB in the VM |
On our M4, “experimental” meant x86 images that qemu, an emulator Colima installs, runs on the ARM chip. The first build took 8 min 32 s.
Step 5: Run the harness on one task
From run.sh:
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
time "$W/venv/bin/swebench" eval verified --gold \
-i sympy__sympy-20590 \
--run-id m4-gold-1 \
--task-repo "$W/swe-bench-tasks" \
-j 1
DOCKER_HOST points the harness at the Colima socket. Our script sets it because the Python Docker client does not use docker contexts; we did not try a run without it. --gold uses the human fix, -i picks the task, --run-id names the run, --task-repo builds locally, -j 1 runs one task at a time.
Instances resolved: 1
Report written to gold.m4-gold-1.json
real 9m12.279s
It took about nine minutes, mostly the image build.
Step 6: Read the report
The run report gold.m4-gold-1.json lands in the folder you ran from; each task’s report.json in logs/run_evaluation/m4-gold-1/gold/sympy__sympy-20590/. read_report.py prints:
== % resolved = resolved_instances / total_instances * 100 = 1 / 1 * 100 = 100.0 %
Resolved: every FAIL_TO_PASS and PASS_TO_PASS test passed. % resolved: resolved tasks over all tasks. Then the broken file:
time "$W/venv/bin/swebench" eval verified \
-p "$HERE/../bez-dockera/predictions-broken.jsonl" \
-i sympy__sympy-20590 \
--run-id m4-broken-1 \
--task-repo "$W/swe-bench-tasks" \
-j 1
| Run report key | Gold | Broken |
|---|---|---|
resolved_instances | 1 | 0 |
unresolved_instances | 0 | 0 |
error_instances | 0 | 1 |
task’s report.json | written | missing |
The patch never applied, so no tests ran: an error, still in the denominator. Unresolved means it applied and a test failed; we had no such case.
If you only wanted to run SWE-bench once and read its report, you can stop here.
Mistakes that skew a run
- Same
--run-id, new patch: the old result is reused. - An image that does not build and has no published fallback: expect no
report.json, so an error. We saw no failed build.
What a whole split costs on a Mac
The docs give 15 to 50 minutes for all of Lite on “a typical machine” with 6 to 12 workers, depending on the machine and the cache level (their table uses the old max_workers and cache level options). They give no figure for arm64. We did not run a whole split.
Our three tasks on the M4, one at a time:
| Task | Image build | Tests | Note |
|---|---|---|---|
sympy__sympy-20590 | 8 min 32 s | 12.07 s | first build, nothing cached |
sympy__sympy-20154 | 2 min 53 s | 13.92 s | same SymPy version, reused the cached environment |
django__django-11179 | 9 min 05 s | 24.06 s | other repository, shared only the first layers |
Each image was 4.1 to 4.3 GB, but images share layers: after three tasks Docker held 10.8 GB in the VM. Memory in the VM peaked at 6,298 of 7,921 MiB with no swap, so 8 GB was enough for one task at a time.
The first build downloads the Ubuntu base image, system packages, Miniconda, the project’s repository and Python packages, as the task’s build recipe says.
swebench eval --help in 5.0.2 lists the aliases full, verified, multilingual and multimodal, not lite. For Lite, pass SWE-bench/SWE-bench_Lite. We loaded Lite with that name; we did not evaluate it.
Cloud runs: sb-cli and Modal
sb-cli is the SWE-bench team’s client that sends your predictions file to their cloud evaluation. Install it with pip install sb-cli, create a key with sb-cli gen-api-key <email>, export it as SWEBENCH_API_KEY, then run sb-cli submit <subset> <split> --predictions_path ... --run_id .... Its README says the test split is “currently only available for swe-bench_lite and swe-bench_verified”.
The mini-SWE-agent docs call the service free, with results typically within 20 minutes. We did not run sb-cli.
SWE-bench Multimodal is a set of JavaScript tasks with images. Since 1 September 2026 its 480 test tasks are open for local evaluation (README). We did not run it.
Modal is a cloud platform that runs containers. Install it with pip install modal swebench[modal], log in with modal setup, and add --modal to swebench eval. It needs Modal credentials and cannot be combined with --task-repo, because it builds images remotely. We did not run Modal.
Running an agent instead of the human fix
To measure an agent, replace the gold patch with the agent’s patches. mini-SWE-agent is a scaffold: the program around the model that decides what it sees and runs. Its only tool is bash.
swebench infer runs mini-SWE-agent on a dataset and writes preds.json plus one trajectory, the log of the agent’s steps, per task to logs/inference/<run_id>. Pass the predictions to swebench eval -p.
It calls a model through your own provider API key; MSWEA_GLOBAL_COST_LIMIT sets a cost limit. Its docs say its containers “assume an x86 Linux architecture; you might not be able to run them on other architectures”. We did not run an agent.
Report an agent’s number with split, scaffold, model, task count and date. For Verified, also say that OpenAI stopped reporting it in February 2026; why, and what took its place, is in the split guide. swebench.com still lists Verified.
Related topic pages: evaluation harnesses, agent evaluation, benchmark datasets, contamination, and scoring without tests: human evaluation (a pipeline), LLM-as-a-judge, Elo rating.
The full scripts
Every command above comes from these files, run on 3 December 2026 on a MacBook Air M4 (16 GB RAM, macOS 26.4.1). W is the work folder.
Homebrew installed colima 0.10.3, docker CLI 29.10.1 and docker-buildx 0.39.1. The README names the task repository, SWE-bench/swe-bench-tasks, and gives the M-series advice.
Install, without Docker (setup.sh, step 1):
#!/usr/bin/env bash
# Step 1 without Docker: venv + swebench + datasets in the work folder.
# Nothing is installed system-wide. The interpreter is an existing uv-managed CPython 3.12.
set -euo pipefail
W="${W:?set W to the work folder}"
PY="${PY:-$HOME/.local/share/uv/python/cpython-3.12.16-macos-aarch64-none/bin/python3.12}"
HERE="$(cd "$(dirname "$0")" && pwd)"
cd "$W"
uptime
"$PY" --version
"$PY" -m venv venv
venv/bin/pip install -q --upgrade pip
venv/bin/pip install -q "swebench==5.0.2" datasets
venv/bin/pip freeze > "$HERE/requirements.txt"
export COLUMNS=110 NO_COLOR=1 TERM=dumb
venv/bin/swebench --help > "$HERE/logs/swebench-help.txt" 2>&1
venv/bin/swebench eval --help > "$HERE/logs/eval-help.txt" 2>&1
venv/bin/swebench report --help > "$HERE/logs/report-help.txt" 2>&1
venv/bin/swebench dataset --help > "$HERE/logs/dataset-help.txt" 2>&1
Load the datasets (load.py):
"""Load SWE-bench Lite and Verified from the Hugging Face Hub, print one task, list candidates.
Run: HF_HOME=<work>/hf-cache venv/bin/python -I load.py <out_dir>
Writes <out_dir>/load-summary.json and <out_dir>/instance-<id>.json (fields of the chosen task).
"""
import json
import sys
from pathlib import Path
import datasets
from datasets import load_dataset
import swebench
from swebench.harness.utils import load_swebench_dataset
OUT = Path(sys.argv[1])
OUT.mkdir(parents=True, exist_ok=True)
CHOSEN = "sympy__sympy-20590" # the README's own v5 smoke-test task (fakty G8)
# Repos whose test suites build C/Cython extensions or need heavy native deps.
NATIVE = {"astropy/astropy", "matplotlib/matplotlib", "scikit-learn/scikit-learn",
"mwaskom/seaborn", "pydata/xarray"}
def as_list(v):
return json.loads(v) if isinstance(v, str) else list(v)
print("swebench", swebench.__version__, "| datasets", datasets.__version__)
summary = {"swebench": swebench.__version__, "datasets": datasets.__version__, "splits": {}}
loaded = {}
for ds_id, splits in [("SWE-bench/SWE-bench_Lite", ["test", "dev"]),
("SWE-bench/SWE-bench_Verified", ["test"])]:
for split in splits:
d = load_dataset(ds_id, split=split)
loaded[(ds_id, split)] = d
summary["splits"][f"{ds_id}:{split}"] = {"rows": d.num_rows, "columns": d.column_names}
print(f"{ds_id} [{split}] rows={d.num_rows}")
print("columns (Verified test):", loaded[("SWE-bench/SWE-bench_Verified", "test")].column_names)
# The harness's own loader, with the name forms the CLI passes on.
for name in ["lite", "SWE-bench/SWE-bench_Verified"]:
n = len(load_swebench_dataset(name, "test"))
summary["splits"][f"harness-loader:{name}:test"] = {"rows": n}
print(f"swebench load_swebench_dataset({name!r}, 'test') -> {n} rows")
lite = {r["instance_id"]: r for r in loaded[("SWE-bench/SWE-bench_Lite", "test")]}
ver = {r["instance_id"]: r for r in loaded[("SWE-bench/SWE-bench_Verified", "test")]}
both = sorted(set(lite) & set(ver))
print(f"in Lite test AND Verified test: {len(both)}")
summary["lite_and_verified_test"] = len(both)
cands = []
for iid in both:
r = ver[iid]
if r["repo"] in NATIVE:
continue
f2p, p2p = as_list(r["FAIL_TO_PASS"]), as_list(r["PASS_TO_PASS"])
patch_lines = sum(1 for ln in r["patch"].splitlines()
if ln[:1] in "+-" and not ln.startswith(("+++", "---")))
cands.append({"instance_id": iid, "repo": r["repo"], "difficulty": r.get("difficulty"),
"f2p": len(f2p), "p2p": len(p2p), "patch_changed_lines": patch_lines})
cands.sort(key=lambda c: (c["patch_changed_lines"], c["p2p"]))
summary["candidates_smallest_15"] = cands[:15]
print("smallest pure-Python candidates (Lite ∩ Verified):")
for c in cands[:15]:
print(" ", c)
r = ver[CHOSEN]
assert CHOSEN in lite, "chosen task must be in Lite test too"
f2p, p2p = as_list(r["FAIL_TO_PASS"]), as_list(r["PASS_TO_PASS"])
same = {k: lite[CHOSEN][k] == r[k] for k in ["base_commit", "patch", "test_patch", "problem_statement"]}
info = {
"instance_id": r["instance_id"], "repo": r["repo"], "base_commit": r["base_commit"],
"version": r["version"], "environment_setup_commit": r["environment_setup_commit"],
"created_at": r["created_at"], "difficulty": r.get("difficulty"),
"problem_statement_head": r["problem_statement"][:400],
"FAIL_TO_PASS_count": len(f2p), "FAIL_TO_PASS": f2p,
"PASS_TO_PASS_count": len(p2p),
"patch": r["patch"], "test_patch_lines": len(r["test_patch"].splitlines()),
"same_in_lite_and_verified": same,
"chosen_rank_in_candidates": next(i for i, c in enumerate(cands) if c["instance_id"] == CHOSEN) + 1,
"candidates_total": len(cands),
}
(OUT / f"instance-{CHOSEN}.json").write_text(json.dumps(info, indent=2, ensure_ascii=False))
(OUT / "load-summary.json").write_text(json.dumps(summary, indent=2, ensure_ascii=False))
print(json.dumps({k: v for k, v in info.items() if k != "patch"}, indent=2, ensure_ascii=False))
print("gold patch:\n" + r["patch"])
The gold patch it printed for the task:
diff --git a/sympy/core/_print_helpers.py b/sympy/core/_print_helpers.py
--- a/sympy/core/_print_helpers.py
+++ b/sympy/core/_print_helpers.py
@@ -17,6 +17,11 @@ class Printable:
This also adds support for LaTeX printing in jupyter notebooks.
"""
+ # Since this class is used as a mixin we set empty slots. That means that
+ # instances of any subclasses that use slots will not need to have a
+ # __dict__.
+ __slots__ = ()
+
# Note, we always use the default ordering (lex) in __str__ and __repr__,
# regardless of the global setting. See issue 5487.
def __str__(self):
Container runtime and task repository (setup.sh, step 2):
#!/usr/bin/env bash
# Step 2 setup on the MacBook Air M4 (2026-12-03): container runtime + task repo.
# The Python venv (swebench 5.0.2, datasets) is reused from step 1: ../bez-dockera/setup.sh.
set -euo pipefail
W="${W:?set W to the work folder}"
HERE="$(cd "$(dirname "$0")" && pwd)"
LOGS="$HERE/logs"
mkdir -p "$LOGS"
uptime
# 1. Colima (pulls lima as a dependency), docker CLI, docker-buildx. No Docker Desktop, no sudo.
HOMEBREW_NO_AUTO_UPDATE=1 brew install colima docker docker-buildx >> "$LOGS/setup.log" 2>&1
# 2. buildx as a docker CLI plugin, as the Homebrew caveat says.
# ~/.docker did not exist before this run; the file holds only this key.
mkdir -p ~/.docker
cat > ~/.docker/config.json <<'JSON'
{
"cliPluginsExtraDirs": [
"/opt/homebrew/lib/docker/cli-plugins"
]
}
JSON
docker buildx version
# 3. One VM: 6 CPU, 8 GiB RAM, 80 GiB disk, Apple Virtualization.framework.
# Colima home stays at ~/.colima: the work-folder path is ~120 characters and
# unix sockets under it would exceed the macOS 104-character socket path limit.
colima start --cpu 6 --memory 8 --disk 80 --vm-type vz >> "$LOGS/colima-start.log" 2>&1
{ colima status; colima list; docker context ls; docker info; } > "$LOGS/docker-info.txt" 2>&1
# 4. Task repo named in the README (G7), shallow clone, then the harness check.
cd "$W"
git clone --depth 1 https://github.com/SWE-bench/swe-bench-tasks.git ./swe-bench-tasks > "$LOGS/clone.log" 2>&1
git -C swe-bench-tasks log -1 --format='%H %cd' >> "$LOGS/clone.log"
venv/bin/swebench dataset check ./swe-bench-tasks > "$LOGS/dataset-check.log" 2>&1
The three runs (run.sh):
#!/usr/bin/env bash
# Step 2 and 3: swebench eval in Colima on one task, then the deliberately broken prediction.
# Usage: run.sh gold | broken | more
set -euo pipefail
W="${W:?set W to the work folder}"
HERE="$(cd "$(dirname "$0")" && pwd)"
MODE="${1:?gold or broken}"
# The docker Python client (docker 7.2.0) does not read docker contexts.
# Without DOCKER_HOST it looks for /var/run/docker.sock, which Colima does not create.
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
export COLUMNS=110 NO_COLOR=1 TERM=dumb
mkdir -p "$W/run"
cd "$W/run" # the harness writes logs/ and the run report relative to the working directory
uptime
case "$MODE" in
gold)
time "$W/venv/bin/swebench" eval verified --gold \
-i sympy__sympy-20590 \
--run-id m4-gold-1 \
--task-repo "$W/swe-bench-tasks" \
-j 1
;;
broken)
time "$W/venv/bin/swebench" eval verified \
-p "$HERE/../bez-dockera/predictions-broken.jsonl" \
-i sympy__sympy-20590 \
--run-id m4-broken-1 \
--task-repo "$W/swe-bench-tasks" \
-j 1
;;
more)
# 2nd and 3rd task: a second SymPy 1.7 task (does the buildx layer cache help?) and a Django task.
time "$W/venv/bin/swebench" eval verified --gold \
-i sympy__sympy-20154 \
-i django__django-11179 \
--run-id m4-gold-2 \
--task-repo "$W/swe-bench-tasks" \
-j 1
;;
*) echo "unknown mode: $MODE" >&2; exit 2 ;;
esac
Read the reports (read_report.py):
"""Read the swebench 5.0.2 run report and the per-instance report.json of one run.
Usage: python -I read_report.py <run_dir> <model_name_or_path> <run_id> <instance_id> <out_dir>
<run_dir> is the working directory the harness ran in. In 5.0.2 the run report is
<run_dir>/<model>.<run_id>.json (--report-dir default "."), the instance report is
<run_dir>/logs/run_evaluation/<run_id>/<model>/<instance_id>/report.json.
Copies the JSON files it finds to <out_dir> and prints keys, values and "% resolved".
Fails loud when the run report is missing.
"""
import json
import shutil
import sys
from pathlib import Path
run_dir, model, run_id, iid, out_dir = sys.argv[1:6]
run_dir, out_dir = Path(run_dir), Path(out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
run_report = run_dir / f"{model}.{run_id}.json"
if not run_report.is_file():
sys.exit(f"run report not found: {run_report}")
summary = json.loads(run_report.read_text())
shutil.copy(run_report, out_dir / run_report.name)
print(f"== run report {run_report.name} ({len(summary)} keys)")
for k, v in summary.items():
print(f" {k}: {json.dumps(v)}")
total = summary["total_instances"]
resolved = summary["resolved_instances"]
print(f"== % resolved = resolved_instances / total_instances * 100 = {resolved} / {total} * 100 = {resolved / total * 100:.1f} %")
inst_dir = run_dir / "logs" / "run_evaluation" / run_id / model / iid
report = inst_dir / "report.json"
print(f"== instance folder {inst_dir.relative_to(run_dir)}: {sorted(p.name for p in inst_dir.iterdir()) if inst_dir.is_dir() else 'missing'}")
if report.is_file():
data = json.loads(report.read_text())
shutil.copy(report, out_dir / f"report.{run_id}.{iid}.json")
r = data[iid]
print(f"== report.json: top key {list(data)}; instance keys {list(r)}")
for k, v in r.items():
if k == "tests_status":
for group, res in v.items():
print(f" tests_status.{group}: success={len(res['success'])} failure={len(res['failure'])}")
else:
print(f" {k}: {json.dumps(v)}")
else:
print("== report.json: missing (the harness counts this instance as an error)")
Deploy safe, Max.
Cheat sheet
The article on one page: open it full size, save it or share it.

AI-assisted content, human-reviewed. Images AI-generated. Editorial Standards · Our Editors