Coding agents: interfaces, fixed pipelines and choosing a patch by tests
编程智能体
How repository-level coding agents localize, edit and validate; what SWE-agent's interface ablations and Agentless's pipeline show; and why passing generated tests does not prove a fix.
coding-agentsFrom an issue to a patch that the tests accept
A coding agent is a language-model system that changes a code repository to satisfy a request, typically an issue: fix this bug, add that option. Unlike generating a function from a specification, as in program synthesis, the agent must first find where the problem is in a large codebase, then edit existing files without breaking anything else. It can also run code and tests and respond to the results. The output is a patch. In benchmarks such as SWE-bench, whose construction is described in agent evaluation, the patch counts as a resolution only if it applies and the evaluation tests pass.
Two designs dominate the papers covered here. SWE-agent puts the model in an interactive loop, in the style of ReAct agents, and argues that the commands given to the model matter as much as the model itself. It calls that layer the agent-computer interface (ACI). ACI Agentless takes the opposite position: a fixed three-phase process (localize, repair, validate) in which the model never chooses its next action or operates complex tools. Agentless This contrast is an example of the choice between open agents and fixed workflows discussed in agent workflows.
Both designs end in the same place: several candidate patches and a decision about which one to submit. Tests make that decision, though they are incomplete. This article follows both papers through localization, editing and selection, then runs an original synthetic pipeline in which nine hand-written “sampled” patches for a tiny three-file repository are filtered and voted on. No model is called.
Interfaces, pipelines and selection rules
What is being measured
Both papers report the resolve rate on a set of N task instances:
Everything a system uses to pick a patch before evaluation (existing tests, tests it wrote itself, its own judgement) is at best a proxy for the evaluation tests.
The agent-computer interface
SWE-agent’s premise is that language-model agents are a new kind of end user and benefit from interfaces built for them. The ACI specifies which commands exist and how feedback and history are formatted into the model’s input. The authors keep the model fixed and change only the interface, designing it by inspecting behaviour on a development set and a grid search over configurations. Design method They state four principles: actions should be simple to understand; actions should be compact and efficient; feedback should be informative but concise; and guardrails should reduce error propagation and speed recovery. Principles
The concrete commands follow these principles. Commands
- Search (
find_file,search_file,search_dir) returns at most 50 results. If a query matches more, the results are withheld and the agent is told to make the query more specific. - The file viewer shows at most 100 lines with line numbers, the file path, the total number of lines and how many lines are hidden above and below;
scroll_up,scroll_downandgotomove the window. editreplaces a line range with new text in the open file and shows the updated window. A linter checks the edit; an edit that introduces errors is discarded, the error is shown and the agent is asked to retry.- Context management collapses observations older than the last five to a single line. Malformed output triggers an error and a retry, with all but the first error message later omitted. An empty output is replaced by an explicit message that the command ran successfully and produced no output.
What the interface ablations show
With GPT-4 Turbo, SWE-agent resolved 12.47% (286 of 2,294) of full SWE-bench and 18.00% (54 of 300) of SWE-bench Lite; with Claude 3 Opus, 10.46% and 13.00%. Non-interactive retrieval baselines resolved 1.31% (GPT-4 Turbo) and 3.79% (Claude 3 Opus) of full SWE-bench, and a shell-only agent with GPT-4 Turbo resolved 11.00% of Lite. The budget was 4 dollars per instance. Table 1 The authors describe theirs, to the best of their knowledge, as the first work on language agents for end-to-end software engineering; that is their claim.
The ablations on Lite (Table 3, baseline 18.0%) are the most useful part for a designer. Table 3
| Change to the interface | Lite resolved (%) |
|---|---|
| Full SWE-agent interface | 18.0 |
| No edit command | 10.3 |
| Edit without linting | 15.0 |
| Iterative search (one result at a time) | 12.0 |
| No search tools at all | 15.7 |
| File window of 30 lines | 14.3 |
| Whole file shown | 12.7 |
| Full history instead of last five observations | 15.0 |
| No demonstration | 16.3 |
Iterative search did worse than no search tools at all because agents stepped through every result with next until the budget or context ran out. Behaviour analysis Showing the whole file did worse than a 100-line window. Both results support the principle that compact, bounded feedback beats complete feedback.
How the loop behaves
Trajectories usually start either with reproduction (create a file, edit it, run it with Python) or with localization (find a file, search a directory); later turns are dominated by edit-then-execute loops. Failed edits are common: 1,185 of 2,294 (51.7%) GPT-4 Turbo trajectories had at least one failed edit. The paper reports that an edit attempt eventually succeeds with probability 90.5%, falling to 57.2% after one failed edit. Edits
The authors summarise outcomes as “succeed quickly, fail slowly”. Resolved runs finished at a median of 1.21 dollars and 12 steps; for unresolved ones the paper reports 2.52 dollars and 21 steps, calling that a mean. The sentence mixes a median with a mean, so the two pairs are not strictly comparable, although the direction is clear. 93.0% of resolved instances were submitted before exhausting the budget, against 69.0% overall, so the authors doubt that larger budgets would help much. Cost and steps Of 248 unresolved Lite trajectories, labelled automatically by GPT-4o (87% agreement with the authors on a hand-labelled set), 52.0% were incorrect or overly specific implementations and 23.4% were cascading failed edits. Failure modes On the HumanEvalFix benchmark, Table 2 gives pass@1 of 87.7 (Python), 89.7 (JavaScript) and 87.9 (Java); the abstract quotes 87.7%, while the results text says 88.3%. Table 2
A pipeline without an agent
Agentless motivates its design with three weaknesses its authors see in agents: complex tool design and usage, lack of control over decision planning (runs of 30 to 40 turns that are hard to debug), and limited ability to self-reflect, so that early errors propagate. Motivation Its three phases are fixed. Method
Localization is hierarchical. The model sees a tree of the repository and ranks the top N suspicious files, combined with embedding retrieval over code chunks after the model excludes irrelevant folders. It then sees a skeleton of class and function signatures for those files and names related elements, then the full code of those elements and names concrete edit locations.
Repair takes a context window around each set of edit locations and samples several patches in a Search/Replace format: an original snippet and its replacement, rather than a rewritten file. The authors say this is cheaper and less prone to hallucination.
Validation has two kinds of tests. The model writes reproduction tests that print “Issue reproduced”, “Issue resolved” or “Other issues”; tests that do not reproduce the issue on the original repository are dropped and the most frequent normalized test is kept. Regression tests are the repository’s existing passing tests, minus those the model marks as expected to change.
Patch selection then proceeds in order: keep the patches with the fewest regression failures; among them keep those whose reproduction test prints “Issue resolved” (falling back to the regression-only set if none do); finally take a majority vote over patches normalized by parsing to an abstract syntax tree, unparsing with docstrings removed, and diffing. Selection Written as sets, with candidate set C, regression failures F(c), reproduction verdict R(c) in 0 or 1 and normalization n:
This formula is our restatement of the paper’s prose description, not an equation printed in the paper. Majority voting over normalized outputs is the same idea as self-consistency, applied to patches.
The configuration used GPT-4o (2024-05-13), the top three files, four samples of edit locations times ten patches each (one greedy, nine at temperature 0.8), so 40 patches per issue, plus or minus ten lines of context, and 40 reproduction-test samples. Implementation Agentless reports 32.00% (96 of 300) on SWE-bench Lite at an average cost of 0.70 dollars, the highest among the open-source approaches it compared against. Result This number and SWE-agent’s 18.00% come from different models and dates, so they are not a like-for-like ranking of the two designs.
Nine patches, three filters, one vote
The program is an original synthetic pipeline. The repository is three in-memory files. apply_discount(total, percent) in shop/pricing.py returns a negative total when the percent exceeds 100; the issue asks for the percent to be clamped to the range 0 to 100. Nine hand-written Search/Replace candidates stand in for sampled patches. Localization counts issue words that match function names and their parts, a stand-in for model-based and retrieval-based localization. A compile() call plays the role of SWE-agent’s lint guardrail. Three regression tests and one reproduction test drive selection; four hidden tests play the role of the benchmark’s evaluation tests.
"""Original synthetic coding-agent pipeline. No model is called: the 'sampled' patches are a fixed,
hand-written list, and the repository is three tiny in-memory Python files."""
import ast
import json
import re
from collections import Counter
REPO = {
'shop/pricing.py': (
'def apply_discount(total, percent):\n'
' return total - total * percent / 100\n'
'\n'
'def add_tax(total, rate):\n'
' return round(total * (1 + rate), 2)\n'),
'shop/cart.py': (
'def cart_total(prices):\n'
' return sum(prices)\n'
'\n'
'def checkout(prices, percent, rate):\n'
' return add_tax(apply_discount(cart_total(prices), percent), rate)\n'),
'shop/report.py': (
'def format_money(value):\n'
' return f"{value:.2f}"\n'),
}
ISSUE = ('apply_discount gives a negative total when the discount percent is above 100. '
'A percent outside 0 to 100 should be clamped, so 150 percent gives a total of 0.')
BAD = ' return total - total * percent / 100\n'
CANDIDATES = {
'c1': (BAD, ' return max(0.0, total - total * percent / 100)\n'),
'c2': (BAD, ' percent = min(max(percent, 0), 100)\n return total - total * percent / 100\n'),
'c3': (BAD, ' percent = min(max(percent,0),100) # clamp\n\n return total - total*percent/100\n'),
'c4': (BAD, ' p = max(0, min(100, percent))\n return total - total * p / 100\n'),
'c5': (BAD, ' return max(0.0, total - total * percent / 100\n'),
'c6': (BAD, ' if percent == 150:\n return 0.0\n return total - total * percent / 100\n'),
'c7': (BAD, ' return 0.0 if percent > 0 else total\n'),
'c8': (BAD, ' """Clamp percent."""\n percent = min(max(percent, 0), 100)\n'
' return total - total * percent / 100\n'),
'c9': (' return total - total * pct / 100\n', ' return max(0.0, total - total * pct / 100)\n'),
}
def localize(repo, issue):
"""Rank files, then functions, by how many issue words match identifiers (a stand-in for LLM/IR localization)."""
words = set(re.findall(r'[a-z_]+', issue.lower()))
ranking = []
for path, src in repo.items():
names = {n.name for n in ast.walk(ast.parse(src)) if isinstance(n, ast.FunctionDef)}
idents = {t for name in names for t in name.split('_')} | names
ranking.append((-len(words & idents), path, sorted(names & words)))
return [(path, -score, hits) for score, path, hits in sorted(ranking)]
def apply_search_replace(src, search, replace):
if src.count(search) != 1:
return None
return src.replace(search, replace)
def load(repo):
namespace = {}
for path in ('shop/report.py', 'shop/pricing.py', 'shop/cart.py'):
exec(compile(repo[path], path, 'exec'), namespace)
return namespace
REGRESSION = {
'discount_25': lambda ns: ns['apply_discount'](80, 25) == 60.0,
'checkout': lambda ns: ns['checkout']([30, 20], 10, 0.1) == 49.5,
'tax': lambda ns: ns['add_tax'](10, 0.05) == 10.5,
}
REPRODUCTION = lambda ns: ns['apply_discount'](100, 150) == 0.0
HIDDEN = {
'over_100': lambda ns: ns['apply_discount'](100, 150) == 0.0,
'negative': lambda ns: ns['apply_discount'](50, -10) == 50.0,
'normal': lambda ns: ns['apply_discount'](80, 25) == 60.0,
'checkout_over': lambda ns: ns['checkout']([40, 60], 120, 0.1) == 0.0,
}
def run(tests, ns):
return {name: bool(test(ns)) for name, test in tests.items()}
def normalize(src):
tree = ast.parse(src)
for node in ast.walk(tree):
body = getattr(node, 'body', None)
if isinstance(body, list) and body and isinstance(body[0], ast.Expr) \
and isinstance(body[0].value, ast.Constant) and isinstance(body[0].value.value, str):
node.body = body[1:] or [ast.Pass()]
return ast.unparse(tree)
if __name__ == '__main__':
target = 'shop/pricing.py'
original = load(REPO)
rows, survivors = {}, []
for cid, (search, replace) in CANDIDATES.items():
new_src = apply_search_replace(REPO[target], search, replace)
if new_src is None:
rows[cid] = dict(stage='search block not found')
continue
try:
compile(new_src, target, 'exec')
except SyntaxError:
rows[cid] = dict(stage='rejected by syntax check')
continue
ns = load({**REPO, target: new_src})
reg = run(REGRESSION, ns)
rows[cid] = dict(stage='ran', regression_failures=sum(not v for v in reg.values()),
reproduction_passes=bool(REPRODUCTION(ns)),
hidden_passed=sum(run(HIDDEN, ns).values()), hidden_total=len(HIDDEN))
rows[cid]['_src'] = new_src
ran = [c for c in rows if rows[c]['stage'] == 'ran']
fewest = min(rows[c]['regression_failures'] for c in ran)
plausible = [c for c in ran if rows[c]['regression_failures'] == fewest and rows[c]['reproduction_passes']]
groups = Counter(normalize(rows[c]['_src']) for c in plausible)
group_members = [[c for c in plausible if normalize(rows[c]['_src']) == key] for key, _ in groups.most_common()]
chosen = group_members[0][0]
for r in rows.values():
r.pop('_src', None)
print(json.dumps(dict(
localization=localize(REPO, ISSUE),
original_repo=dict(reproduction_passes=bool(REPRODUCTION(original)),
regression=run(REGRESSION, original), hidden=run(HIDDEN, original)),
candidates=rows,
plausible=plausible,
vote_groups=[[members, len(members)] for members in group_members],
majority_choice=dict(patch=chosen, resolved=rows[chosen]['hidden_passed'] == len(HIDDEN)),
first_plausible=dict(patch=plausible[0], resolved=rows[plausible[0]]['hidden_passed'] == len(HIDDEN)),
), indent=1))
Localization ranks shop/pricing.py first with score 2 (the issue mentions both apply_discount and discount), shop/cart.py second with 1 (the word “total”) and shop/report.py last with 0. On the original repository the reproduction test fails, all three regression tests pass, and one of the four hidden tests passes.
The filters remove three candidates. c5 is rejected by the syntax check because a parenthesis is missing. c9 fails with “search block not found”: its search snippet refers to a variable name that is not in the file, a stale-snippet failure that the Search/Replace format makes visible rather than silently applying. c7 runs but has two regression failures, because it returns 0 for any positive percent. Six candidates remain plausible: c1, c2, c3, c4, c6 and c8, each with zero regression failures and a passing reproduction test.
The hidden tests separate them. c2, c3, c4 and c8 pass all four. c1 passes three: it clamps the result at 0 but does not handle negative percents, so a 50 total with −10% gives 55. c6 passes two: it special-cases exactly 150%, the input in the reproduction test.
Normalization groups c2, c3 and c8 together (they differ only in whitespace, a comment and a docstring), giving a group of size 3; c1, c4 and c6 are groups of size 1. The majority vote picks c2, which resolves the issue. Taking the first plausible patch instead picks c1, which does not. Note that c4 is also correct but sits alone in its group: normalization removes surface differences, not semantic differences, so two correct patches written differently do not vote for each other.
Where tests and benchmarks fall short
Every filter in the pipeline is a proxy. The reproduction test checks what the model thought to check; in the example, c6 passes it by special-casing the reproduced input and c1 passes it while missing half the requirement. SWE-agent’s failure analysis points the same way: about half of unresolved cases were incorrect or overly specific implementations. A patch that passes generated tests and existing regression tests is a candidate, not a proof.
Benchmark tasks themselves have problems. Agentless’s manual classification of SWE-bench Lite found problems whose description contains the exact ground-truth patch (4.3%), problems missing critical information (10.0%) and problems with misleading suggested solutions (5.0%); the authors built a filtered subset, Lite-S. Benchmark problems Agentless also notes that its regression tests come from running the repository’s own tests rather than SWE-bench’s list of tests expected to keep passing, at the maintainers’ request; a terse footnote says that using that list would give 98 on Lite. It states no unit; read against the 96 of 300 reported in the abstract, it most plausibly means 98 resolved problems, not 98%. Footnote
Single-run differences on 300 tasks are small in absolute terms. The edit-without-linting ablation moves Lite from 18.0% to 15.0%, which is 54 against 45 instances. The paper notes that which instances get resolved varies across runs, so a gap of this size from one run is suggestive rather than decisive; repeated runs and intervals are discussed in agent evaluation.
Coding agents execute code they or a model wrote. That code should run in an isolated sandbox with limited network access and credentials, and a human should review patches before they reach shared branches. The example’s exec runs only the fixed strings inside the file, which is acceptable for a demonstration and not for model output. The example also has no model, no sampling, and a repository small enough that localization is trivial. This article did not read anything about commercial coding products or later benchmark versions.
Exercises
-
Why does SWE-agent’s search command refuse to print more than 50 results instead of printing all of them?
Answer: Every printed line costs context, and long result lists distract the model and exhaust its budget. Telling the agent to refine its query is compact, informative feedback, in line with the second and third design principles. The iterative-search ablation (12.0% against 18.0%) shows the cost of the opposite design, in which agents stepped through results one by one.
-
Removing linting from
editchanges SWE-bench Lite performance from 18.0% to 15.0%. On 300 instances, how many instances is that, and what more would you want before calling it a robust effect?Answer: 54 against 45 resolved, a difference of 9 instances. You would want repeated runs, since the paper notes that resolution of individual instances varies across runs, a paired comparison on the same instances, and an interval. A 3-point change on 300 tasks from one run is suggestive, not decisive.
-
In the example, six plausible patches normalize into groups of sizes 3, 1, 1 and 1. If two of the size-1 patches had been written identically to each other, would the vote change?
Answer: No. The groups would be 3, 2 and 1, and the size-3 group still wins. The outcome could change only if some group without a correct patch reached 3 or more: at exactly 3 it would tie with the c2 group and the winner would depend on how ties are broken, and above 3 it would win outright.
-
“A patch that passes the reproduction test and all regression tests resolves the issue.” Is this true?
Answer: Not necessarily. In the example, c6 special-cases the reproduced input (150%) and c1 handles only part of the requirement; both pass the reproduction and regression tests, and both fail hidden tests. A generated reproduction test covers only what the model thought of. SWE-agent’s failure analysis likewise finds about half of unresolved cases to be incorrect or overly specific implementations.
-
You need to fix many small, well-described bugs in a large repository cheaply and auditably. Separately, you need an assistant that investigates an unfamiliar build failure requiring exploratory commands. Which design fits each?
Answer: A fixed pipeline in the style of Agentless fits the first: predictable steps, low cost (0.70 dollars on average in its own report), easy debugging, and selection by tests. An interactive agent with a designed interface fits the second, where the next step depends on what is discovered; give it compact commands, guardrails, a sandbox and budget limits. Both still need tests that actually capture the requirement.
Reading the literature
When reading a coding-agent result, check which benchmark split and which model were used, the cost per instance, whether the result is a single run, and which tests were used for selection versus final evaluation. A change of interface, a change of model and a change of selection rule can each move the resolve rate; comparisons across papers usually change all three at once.
SWE-agent shows that interface design, with the model held fixed, has large effects, and its ablations give concrete guidance: bounded search, a windowed viewer, linted edits and a short history. SWE-agent Agentless shows that a fixed localize–repair–validate pipeline with test-based selection and voting over normalized patches can be competitive at low cost, and it documents quality problems in the benchmark itself. Agentless Neither paper settles which design is better in general; they answer different questions about control, cost and how much the next step depends on what is found.
Make a prediction, then check
In SWE-agent's ablations, which search interface did worst on SWE-bench Lite?
Learning objectives
- Compare an interactive agent-computer interface with a fixed localize–repair–validate pipeline, stating each one's control points, cost and failure modes.
- Select a patch with regression tests, reproduction tests and normalized majority voting, and explain why passing them still does not prove the issue is resolved.
Prerequisites & connections
Explore related knowledge →References
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering — scoped arXiv v3
John Yang; Carlos E. Jimenez; Alexander Wettig; Kilian Lieret; Shunyu Yao; Karthik Narasimhan; Ofir Press · 2024 - Agentless: Demystifying LLM-based Software Engineering Agents — scoped arXiv v2
Chunqiu Steven Xia; Yinlin Deng; Soren Dunn; Lingming Zhang · 2024
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Research was done by a separate research subagent (facts.md) and the prose by a writer subagent. The Gemini app style edits to the opening (intuition) sections, logged in gemini-edits-016a.json, were applied by the main session before this check; each logged old/new pair for this topic was compared and found to be style-only, with no change to facts, hedges or attributions, and the zh/en intuition sections still say the same thing. Ran example.py with python3 and diffed it against example.stdout.txt (identical); confirmed the python block is byte-identical in en.mdx, zh.mdx and example.py and display equations match; traced the localization scores, regression/hidden-test results for c1, c6 and c7 and the vote groups by hand; checked exercise answers. Downloaded both arXiv PDFs and read with pdftotext: SWE-agent v3 abstract, sections 2-5 including Tables 1-3, section 5.2 (51.7% failed edits, 90.5%->57.2%, the median $1.21/12 vs mean $2.52/21 sentence, 93.0% vs 69.0%, n=248, 87% agreement, 52.0% and 23.4%), the 'to the best of our knowledge' first-work claim, and the HumanEvalFix Table 2 (87.7/89.7/87.9) against the results text (88.3%); Agentless v2 abstract, section 1 motivation and benchmark-problem percentages (4.3/10.0/5.0), sections 3.1-3.3 (localization, Search/Replace, reproduction tests, selection and AST normalization), section 4 implementation and the PASS_TO_PASS footnote, and the Table 1 rows for Agentless (96, 32.00%, $0.70) and SWE-agent GPT-4 (18.00%). Confirmed the selection formula is labelled as a restatement and that SWE-agent 18.00% vs Agentless 32.00% is marked as not like-for-like. Compared zh and en section by section and checked data.json IDs and quiz answer. Not checked: appendices, Agentless section 6, rendered HTML.
- example.py output matches example.stdout.txt; code blocks byte-identical across languages.
- SWE-agent Tables 1-3 and section 5.2 figures, and Agentless 32.00%, $0.70, 4.3/10.0/5.0% and implementation settings, match the PDFs.
- Selection formula is labelled as a restatement; 18.00% vs 32.00% is flagged as different models and dates, not like-for-like.
- zh/en agree section by section; Gemini style edits did not change facts or attribution.
Source locations checked:
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering — scoped arXiv v3 · pdftotext of arXiv v3: abstract (12.5%, 87.7%); §1 (12.47% of 2,294; prior best 3.8% RAG; +10.7 points over shell baseline on Lite; Claude 3 Opus 10.5%); §2 ACI definition and four principles; §3 search (≤50 results), file viewer (≤100 lines), edit with linter, context management (last 5 observations); §4 datasets, models, baselines, metrics, $4 budget, configuration search; §5 and Table 1 (RAG 1.31/3.79, Shell-only 11.00 Lite, SWE-agent 12.47/18.00 and 10.46/13.00), Table 2 (HumanEvalFix 87.7/89.7/87.9), Table 3 ablations; §5.1; §5.2 (51.7% trajectories with failed edit, 90.5%→57.2%, $1.21/12 vs $2.52/21, 93.0% vs 69.0%, 248 unresolved, 87% agreement, 52.0% and 23.4%); §6.1–6.2, §7 opening. Not read: appendices A–B (incl. B.2 issue age, B.5 pass@k), figures beyond captions, code.
- Agentless: Demystifying LLM-based Software Engineering Agents — scoped arXiv v2 · pdftotext of arXiv v2: abstract (32.00%, 96 fixes, $0.70); §1 (three agent limitations; 4.3%/10.0%/5.0%; Lite-S; OpenAI adoption claim); §2.1; §2.3 last paragraph on bug reproduction; §3 overview, §3.1.1–3.1.3 localization, §3.2 Search/Replace repair, §3.3.1 reproduction tests, §3.3.2 patch selection and AST normalization; §4 datasets, implementation (GPT-4o 2024-05-13, top 3 files, 4×10=40 patches, temperature 0.8, ±10 lines, 40 test samples), footnote on PASS_TO_PASS, baselines (26 agent-based), metrics. Not read: §5 Table 1 rows and text, §6 (Lite-S analysis), appendices.
Related topics