Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

~11 min read2023 / 2024

SWE-bench & SWE-agent,
explained.

Writing one tidy function from a docstring — the HumanEval task — turned out to be the easy part. Real software engineering is messier: read an issue, hunt through a sprawling codebase to find the bug, change the right lines across the right files, and prove you fixed it without breaking anything else. SWE-bench turned actual resolved GitHub issues into a benchmark that demands exactly that, and early models scored a few percent. SWE-agent then asked what interface a model needs to do the job at all. Here's how the benchmark grades a fix, and why the tools you give an agent matter as much as the model.

The delta

What changes against self-contained problems: a real repository

Rungs 1 and 2 both evaluate a function written from a specification in a vacuum. This rung changes the task to something recognisably the job: a real issue from a real repository, where the model must find the relevant code among thousands of files, understand conventions it did not write, and produce a patch. Success is defined operationally and strictly — the patch must apply, the previously-failing tests must pass, and the previously-passing tests must still pass. That last clause is what makes it a software engineering benchmark rather than a coding one: no credit for a fix that breaks something else.

The agent side then produced a finding that is more useful than any score on it. Giving a capable model a shell and a repository works poorly. Giving it a small, purpose-built set of operations works dramatically better — a file viewer that shows a bounded window and remembers position, an edit command that checks syntax before accepting a change and refuses it otherwise, scoped search that returns manageable results. Same model, same task, large difference from the interface alone.

The reason is the transferable part: an agent is not a human user. A human at a terminal benefits from general power and unbounded output, and recovers from a mess by looking at the screen. A model has a limited context that unbounded output destroys, cannot see, and will confidently build on a broken edit for many turns. So the ergonomics invert — narrow operations, small outputs, and immediate error feedback at the moment of the mistake beat general-purpose tools, because the cost of an undetected error compounds.

01

Beyond one function

Benchmarks like HumanEval measure whether a model can write a small, self-contained function from a clear spec. Useful — but a poor proxy for what software engineers actually do. Real work means operating inside a large, unfamiliar codebase: interpreting a vague bug report, locating the relevant code among thousands of files, making a correct, minimal change, and confirming with the test suite that the bug is gone and nothing else broke. None of that is captured by "write this function."

SWE-bench closed the gap by building its tasks from reality. Each instance is a genuine GitHub issue that was actually resolved by a pull request in a popular open-source Python project, packaged with the repository as it was before the fix and the tests that validate the fix. The model gets the issue and the repo; it must produce a patch. It's the difference between a coding quiz and a real ticket in a real backlog.

The one-sentence version

SWE-bench grades models on resolving real GitHub issues — the patch must apply, fix the failing tests, and break nothing — and SWE-agent gives the model a purpose-built interface to do it.

02

Grading a fix

How do you score a code change objectively? By running the tests — but SWE-bench is careful about which tests. It splits them into two sets and requires both to come out right for an issue to count as resolved:

The FAIL_TO_PASS tests are the ones that failed before the fix — they prove the bug is actually fixed, not merely that the patch runs. The PASS_TO_PASS tests already passed — requiring they still pass is a regression check, so a "fix" that quietly breaks something else does not count. And the patch must apply cleanly to begin with. All three, or it's not resolved. This is a strict, execution-based grade with no partial credit — exactly the honesty you want for real engineering. The runnable version below encodes this rule and the regression trap.

03

The Agent-Computer Interface

SWE-bench sets the task; SWE-agent asks how a model can actually do it. A language model can't magically edit a repo — it needs a way to look around and act. The naive approach is to hand it a normal shell. The paper's key finding is that this is a mistake: interfaces built for humans serve models poorly. Models get lost in verbose output, mangle multi-line edits, and waste turns on malformed commands.

The fix is a purpose-built Agent-Computer Interface (ACI) — a small set of commands designed for how a language model reads and writes:

Commands built for the model, not the human
SearchFind files and symbols with concise, summarized results — no wall of grep output.
Open / scrollView a file in bounded windows, so context stays readable and cheap.
Edit + lintMake edits through a command that lint-checks and rejects malformed changes on the spot.
Run scriptsNo special command — tests and scripts run through the ordinary shell, and empty output is reported explicitly; the result is the agent's feedback loop.

The result was measurable: a well-designed ACI raised the resolve rate substantially over a plain shell, holding the model fixed. The lesson generalized far beyond this paper — how you let an agent act, not just how smart the model is, is a first-class design variable. Guardrails (like the edit linter) that catch mistakes before they compound turned out to matter enormously.

04

The agent loop

With the ACI in place, SWE-agent runs the familiar agent loop — the same reason-then-act cycle, specialized for coding. The model observes, decides on a command, runs it, reads the result, and repeats until it submits a patch:

observe → think → run a command → read output → … → submit patch

It might search for the error message, open the offending file, scroll to the function, edit it (the linter catching a botched edit before it lands), run the tests, see two still failing, adjust, and finally submit. Every step is a turn where the model reasons about what it sees and picks the next action. The whole trajectory is bounded — limited turns and cost — so the agent must localize and fix efficiently. When it submits, SWE-bench applies the strict three-part grade from section 02.

How it works

How SWE-bench was built and how SWE-agent works an issue

The page covers two papers: SWE-bench (Jimenez and colleagues, 2023), which defines the task, and SWE-agent (Yang and colleagues, 2024), which builds an agent for it. The benchmark came out of three filtering stages, and the agent works through a purpose-built command set.

SWE-agent loop tests fail: edit again reproduce localize edit run tests submit create repro.py python repro.py find_file search_dir edit 41:47 lint gate pytest read the result submit diff → patch bad syntax: edit refused SWE-bench graded: fail→pass and pass→pass tests
The agent issues one command per turn; the linter rejects broken edits on the spot, failing tests send it back to editing, and SWE-bench grades only the final diff.

Building SWE-bench

  1. Scrape pull requests. About 90,000 pull requests from 12 popular open-source Python repositories, including django, sympy, scikit-learn, matplotlib, pytest, sphinx and astropy.
  2. Filter by attributes. Keep merged pull requests that resolve a linked GitHub issue and that change the repository's tests, since those tests are what will check a fix.
  3. Filter by execution. Install each repository at the pull request's base commit, apply the pull request's test changes, and run the tests before and after its code changes. Keep an instance only if at least one test goes from failing to passing and nothing errors during installation or running. 2,294 task instances survive.
  4. Pose the task. The model sees the issue text and the repository at the base commit, and must return a patch. Grading applies the patch and runs the fail-to-pass and pass-to-pass tests.

The original paper's baselines wrote a patch in one shot. Retrieval chose which files went into the context: BM25 over the repository, filling a budget of up to about 50,000 tokens, or an "oracle" that supplied exactly the files the reference patch edited. The authors also fine-tuned CodeLlama-Python 7B and 13B into SWE-Llama on about 19,000 issue and pull-request pairs from 37 other repositories.

How SWE-agent works an issue

  1. Search with bounded output. find_file, search_file and search_dir return a summary of matching files and lines, and ask for a narrower query when there are more than 50 results.
  2. View a window, not a file. open shows 100 lines with line numbers and a header stating the file and the position; scroll_up, scroll_down and goto move the window.
  3. Edit with a guard. edit replaces a range of lines with new text, shows the result, and runs a linter first: if the change introduces a syntax error it is rejected, and the agent sees the error alongside the code before and after.
  4. Reproduce and test through the shell. Ordinary bash commands remain available, so the agent creates a reproduction script, runs it and runs the tests. A command that prints nothing returns an explicit message saying it succeeded with no output.
  5. Manage context. Each turn is a thought plus one command. Older observations are collapsed to a single line, with only the last five kept in full, and the prompt includes a demonstration trajectory.
  6. Submit. submit turns the repository's current diff into the patch that SWE-bench grades.

The SWE-agent paper distills these choices into four design principles for an agent-computer interface: commands should be simple enough to learn from a short description; important operations such as navigating and editing should take as few actions as possible; feedback should be informative but concise; and guardrails, like the edit linter, should stop errors before they compound.

The math

The SWE-bench resolve rule, written out

resolved(i) = applies(patchi) ∧ ∀t ∈ F2Pi: pass(t) ∧ ∀t ∈ P2Pi: pass(t)
% resolved = (100 / |D|) · Σi∈D resolved(i)
  • F2Pi — fail-to-pass tests: tests from the reference pull request that failed before the fix and pass after it, so passing them shows the issue is fixed.
  • P2Pi — pass-to-pass tests: tests that passed both before and after the reference fix; requiring them keeps regressions from counting as solutions.
  • D — the evaluation set: the full 2,294 tasks, the 300-task Lite subset or the 500-task Verified subset.
  • applies — the patch must apply cleanly to the repository at the base commit.

Every term is binary and there is no partial credit, so a patch that fixes the bug but breaks one unrelated test scores the same as an empty patch. At the extremes, an empty patch resolves nothing, because the fail-to-pass tests still fail, and a patch that deletes the failing functionality fails too, because those same tests check the new behavior. Because D varies, a percentage means nothing without its subset; the same system scores differently on the full set, on Lite and on Verified.

The evidence

What SWE-bench and SWE-agent measured

The SWE-bench paper evaluated single-shot, retrieval-augmented baselines on all 2,294 tasks. The SWE-agent paper ran its agent with GPT-4 Turbo and Claude 3 Opus on the full set and on SWE-bench Lite, a 300-task subset of more self-contained bug fixes, and ran its interface ablations on Lite.

SystemSet% resolved
Claude 2, BM25 retrieval, one shotfull1.96
Claude 2, oracle files, one shotfull4.8
Best earlier non-interactive systemfull3.8
SWE-agent, GPT-4 Turbofull12.47 (286 issues)
SWE-agent, GPT-4 TurboLite18.0
Same model, plain shell onlyLite11.0

Two negative results came from the benchmark paper. Even when handed the files the reference patch edits, the best model resolved under 5 percent, so finding the code is not the only hard part. And giving Claude 2 more BM25-retrieved context made it worse, not better: longer inputs distracted the model from the code that mattered.

The SWE-agent ablations isolate the interface. Holding the model fixed, the purpose-built commands beat a plain shell by 7 points on Lite. Removing the linting guard on edits cost points; showing whole files instead of a 100-line window did worse, and so did a 30-line window; and search that returned raw matches iteratively did worse than summarized search. The same interface also reached 87.7 percent on HumanEvalFix, a short bug-fixing benchmark.

Later work questioned how much of this needs an agent loop. Agentless (Xia and colleagues, 2024) used a fixed localize, repair and validate pipeline with no free-form tool use and matched or beat the open-source agents of its time on Lite at low cost. SWE-bench Verified, a 500-task subset screened by human developers for clear issues and fair tests, became the standard reporting set.

Since then

What is admitted, what is contested, and what happened next

The benchmark's own limitations are substantial and well documented, several by its authors and more by later analyses. Contamination is structural: the issues and their fixes are public and predate the models being evaluated, so exposure cannot be excluded. Tests are an imperfect oracle — a patch that passes them is not necessarily the right fix, and analyses have found instances where the tests are weak enough to admit wrong solutions or where the issue text or comments essentially give the answer away. And the tasks are drawn from a handful of Python repositories, so "real software" means one language and one ecosystem's conventions.

A practical consequence worth flagging: filtered subsets and variants proliferated, and results reported on different subsets with different scaffolds are routinely compared as though they were the same number. When a model is claimed to score some percentage here, the subset and the harness are part of the claim.

How it held up: it became the standard agentic coding benchmark, which is both its success and the source of its problems — a benchmark this influential is optimised against. The interface finding is the durable contribution, and it generalises past coding to every agent on the agents ladder: how much capability you get out of a model depends on the tools you hand it at least as much as on the model, and designing those tools for a reader that cannot see is a distinct skill.

SOLVE IT YOURSELF

The strict resolution rule

SWE-bench's grade is a three-way AND you can hold in your hand. A patch resolves an issue only if it applies, makes the FAIL_TO_PASS tests pass, and keeps the PASS_TO_PASS tests passing — so a fix that introduces a regression fails, and a patch that doesn't even apply fails. This encodes that rule, computes a resolve rate over a set of issues, and prices the Agent-Computer Interface: a well-designed ACL produces more well-formed commands (90% vs 50%), which is what lifts the agent's success. Flip any condition and watch the verdict change.

YOUR TASK

Write the body of aci_success. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. Resolution needs apply AND fail-to-pass AND pass-to-pass
  2. A fix that breaks a passing test is a regression, not resolved
  3. A patch that does not apply is not resolved
  4. Resolve rate = resolved / total
  5. A better ACI produces more well-formed commands
CPython · WebAssembly
06

What it drives

SWE-bench and SWE-agent set the agenda for the coding-agent era. The benchmark is now the headline metric quoted for every serious coding model and agent, and its verified subset is a trusted standard. SWE-agent's ACI insight — design the interface for the model — shaped how agent frameworks are built across the industry, well beyond code.

Its deepest contribution is a reframing of what "coding AI" is measured on. HumanEval asked "can it write code?"; SWE-bench asked "can it engineer?" — navigate, localize, edit, and verify in a real repository, graded by whether the software actually works afterward. That execution-grounded, whole-task evaluation is far closer to the real job, and it turned agent design (interfaces, guardrails, verification loops) into a research frontier alongside the models themselves. When a coding agent reports a SWE-bench score today, it's speaking the language this work created.

Worth knowing

SWE-bench builds directly on the functional-correctness idea — grade by running tests — but scales it from a single function to an entire repository and a real, human-reported bug, which is why it's so much harder.

Questions

Questions people ask about SWE-bench & SWE-agent

What is the difference between SWE-bench, SWE-bench Lite and SWE-bench Verified?

SWE-bench is the full benchmark of 2,294 task instances built from real issues and their fixing pull requests in 12 Python repositories. SWE-bench Lite is a 300-task subset released by the same team to make evaluation cheaper, filtered toward self-contained bug fixes with clear descriptions, so it is easier than the full set. SWE-bench Verified is a 500-task subset in which human software developers screened candidate tasks and removed those with underspecified issues or tests that would reject valid fixes; it was released with OpenAI in 2024 and became the most commonly reported set. Scores on the three are not interchangeable, so a resolve rate is only meaningful with its subset and harness named.

How was SWE-bench built?

In three stages. First, about 90,000 pull requests were collected from 12 popular open-source Python repositories such as django, sympy and scikit-learn. Second, attribute filtering kept merged pull requests that resolve a linked GitHub issue and also modify test files. Third, execution filtering installed each repository at the pull request's base commit, ran the tests with and without the pull request's code changes, and kept only instances where at least one test went from failing to passing and nothing broke during installation or execution. That left 2,294 tasks, each with an issue, a repository snapshot, a reference patch, and its fail-to-pass and pass-to-pass tests.

What commands does SWE-agent's interface give the model?

SWE-agent adds a small set of commands on top of a bash shell. find_file, search_file and search_dir return summarized results and ask for a narrower query when there are too many matches. open shows a 100-line window of a file with line numbers and a header giving the file name and position, and scroll_up, scroll_down and goto move it. edit replaces a range of lines and runs a linter, rejecting any edit that introduces a syntax error. create makes a new file and submit turns the repository diff into the final patch. Running scripts and tests uses ordinary shell commands, and empty output is reported explicitly.

Why did SWE-agent's interface beat a plain shell?

Because a language model works through a limited context window and cannot see a screen. With a plain shell, commands like cat and grep can flood the context with thousands of lines, multi-line edits through sed are easy to mangle, and a broken edit can go unnoticed for many turns while the model builds on it. SWE-agent's commands bound every output, show files in a fixed window, and lint each edit before accepting it, so mistakes surface immediately. In the paper's ablation on SWE-bench Lite with GPT-4 Turbo, the full interface resolved 18.0 percent of issues against 11.0 percent with the shell alone, and removing individual features such as the edit linter lowered the score.

What is Agentless and how does it compare with SWE-agent?

Agentless, from Xia and colleagues in 2024, is a fixed pipeline rather than an agent. It localizes the fault hierarchically, narrowing from files to classes and functions to edit locations; it then samples several candidate patches for those locations; and it validates them with regression tests and generated reproduction tests before choosing one. There is no free-form loop in which the model decides what to do next. On SWE-bench Lite it matched or beat the open-source agent systems of its time at low cost per issue, which suggested that much of what agents gained came from structured localization and validation rather than from autonomy itself.

What retrieval baselines did the original SWE-bench paper use?

Single-shot generation with retrieval. In the sparse setting, BM25 ranked the repository's files against the issue text and filled the context up to a token budget, with budgets of up to about 50,000 tokens. In the oracle setting the model was given exactly the files the reference patch edited, an upper bound on what retrieval could provide. The best model, Claude 2, resolved 1.96 percent with BM25 and about 4.8 percent with oracle files. Two findings stood out: more retrieved context made results worse rather than better, as models were distracted by irrelevant code, and even perfect retrieval left the great majority of issues unsolved.

Check yourself

4 questions to test what you just read

Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.

SWE-agent resolved 12.47% of the full 2,294-task SWE-bench. About how many issues is that, and why should you not compare it directly with its 18.0% on Lite?

Show answer

0.1247 × 2,294 ≈ 286 issues. Lite is a different, 300-task subset chosen to be more self-contained, so it is easier, and the same system scores higher there. A resolve rate is only comparable with others measured on the same subset and harness.

A patch makes all FAIL_TO_PASS tests pass but breaks one unrelated test that passed before. Does the issue count as resolved, and which test set catches it?

Show answer

No. The PASS_TO_PASS set holds tests that passed both before and after the reference fix; one of them now fails, so the regression check rejects the patch. There is no partial credit for having fixed the bug.

Predict: would giving the agent the whole file instead of a 100-line window raise or lower its resolve rate, and why?

Show answer

Lower, and the ablation found exactly that. Whole files flood a limited context with irrelevant lines and push out earlier observations, while a too-small window (30 lines) forces many extra scrolling turns. A bounded window sized for the model's context did best.

Claude 2 resolved 1.96% with BM25 retrieval and about 4.8% when handed the exact files the fix edits. What does each number say about where the difficulty lies?

Show answer

The rise from 1.96% to 4.8% shows that finding the right code is a large part of the problem. But 4.8% with perfect retrieval shows that writing a correct, non-breaking patch is hard even once localization is solved, which is why later systems added iteration and test execution.

Where this sits

Models that write code

Completion, then competition, then a benchmark made of real GitHub issues — the point at which "can it code?" got an answer you could audit.

  1. 1Codex2021
  2. 2AlphaCode2022
  3. 3SWE-bench & SWE-agent2023

All 110 papers, in 19 ladders →

Finished this one? 0 / 110 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns