Skip to content

SWE-agent: Agent-Computer Interfaces for Software Engineering

Skip →Indirect prompt injection
main track #9corefundamentalpaperrubric 12/122024 · NeurIPS 2024 · ~35 min

John Yang, Carlos E. Jimenez, Alexander Wettig, …, Ofir Press

Status

TL;DR. SWE-agent puts a language model in a Linux shell and asks it to fix real GitHub issues (SWE-bench). The key move is an agent-computer interface (ACI): a small set of commands built for LMs, not humans. It has summarised search, a 100-line file viewer with line numbers, an edit command that runs a linter and rejects broken edits, and history compression. With the model fixed (GPT-4 Turbo), this interface raises SWE-bench Lite from 11.0% (shell only) to 18.0%. The paper’s ablations show that each interface choice changes the result.

Why it matters now. The scores are from 2024 and are now stale; the idea is not. Every agent that searches, reads and edits works through an interface someone designed: how many results a search returns, how much of a document a read shows, how old observations are kept. For an IR researcher, SWE-agent is the clearest evidence that search-tool design for agents is its own problem. A search interface built for people (step through hits one by one) did worse than no special search tool at all.

The paper treats the LM as a new kind of user. Humans skim, ignore irrelevant output and look at a screen; an LM pays for every token in its context and can be distracted by it. So the authors design the interface for the model, and tune it by inspecting trajectories and running a grid search on a development set. They state four principles (§2):

  1. Simple actions with few options and short documentation.
  2. Compact actions: one command for a high-level operation, such as replacing lines 404–407 in a single edit.
  3. Informative but concise feedback, such as showing the updated file after an edit, or a clear message when a command prints nothing.
  4. Guardrails that catch errors early, such as a linter that rejects edits that break syntax.

At each step the agent writes a thought and a command, in the ReAct style. The ACI runs the command in the shell and formats the result. Observations older than the last five are collapsed to one line each.

SWE-agent: an agent-computer interface sits between the language model and the shell The language model sends a thought and a command to the agent-computer interface. The interface offers four parts: summarized search that returns at most 50 results, a file viewer that shows 100 lines with line numbers, an editor that replaces a line range and runs a linter so that invalid edits are rejected, and a context manager that collapses observations older than the last five. The interface runs commands in a Linux shell over the repository and returns concise feedback to the model as the next observation. LM agent thought and command agent-computer interface (ACI) search find_file, search_dir max 50 results, else asks to narrow query file viewer 100-line window line numbers, goto, scroll up and down editor + linter replace lines a to b invalid edit rejected, updated view shown context manager keeps last 5 outputs older ones become one line each Linux shell repo and tests feedback back to the agent: short, current, and flags errors early
Original sketch. The ACI sits between the model and the shell: it limits search output, shows a bounded file window, lints edits, and compresses old observations before the next model call.
  • Main results (Table 1). With GPT-4 Turbo, SWE-agent resolves 12.47% of the full SWE-bench test set (2,294 tasks; about USD 1.59 per task) and 18.00% of Lite (300 tasks). RAG with the same model gets 1.31% and 2.67%. Claude 3 Opus gets 10.46% and 13.00%. These are 2024 numbers.
  • Ablations (Table 3, Lite). No edit command 10.3; edit without linting 15.0; iterative search 12.0; no search command 15.7; 30-line viewer 14.3; full-file viewer 12.7; full history 15.0; no demonstration 16.3. Each row is a single run with one component changed.
  • Variance (Table 10). Six runs average 17.94 with standard deviation 0.49; pass@6 reaches 32.67, so many tasks are solved only in some runs.
  • Behaviour (§5.2). Runs start by reproducing the bug or localising it, then loop between editing and running code. An editing attempt eventually succeeds 90.5% of the time; conditional on its first edit failing, eventual success falls to 57.2%.
  • Failures (Figure 8). A GPT-4o labeller (87% agreement with the authors on a validation set) puts 52.0% of unresolved Lite runs in incorrect or overly specific implementation, and 23.4% in cascading failed edits.
  • Other benchmark. On HumanEvalFix, the text reports 88.3% pass@1, while Table 2 lists 87.7 for Python; I could not resolve this difference from the paper.
  • Stale scores. The models and the leaderboard have moved on; use the ablations, not the headline score.
  • One configuration, one model. Ablations vary one component at a time around one setup with GPT-4 Turbo, so interactions and model dependence are unknown.
  • Single runs. Most ablation rows are one run on 300 tasks; differences under about 1.5 points are within noise.
  • Tests as the oracle. Success means the repository’s tests pass, which can reward overly specific fixes.
  • Manual design. The ACI was hand-tuned; learning or searching over interface designs automatically is an open direction.
  • Action-space design: CodeAct gives the model a full interpreter; SWE-agent curates a few compact commands. ReAct is the thought-then-action loop SWE-agent uses.
  • Evaluation: I did not find a SWE-bench page on this site yet, so SWE-bench is named here as plain text. For cost-aware comparison see trajectory and cost evaluation, and for benchmark leakage see contamination.
  • Search tools for agents: fixed-corpus agent benchmarks such as BrowseComp-Plus let you run the same kind of interface ablation on retrieval tools.
  • Coding agents and reward hacking: when tests are the success check, agents can learn to satisfy the tests instead of the task; see reward hacking in agents.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    SWE-agent with GPT-4 Turbo resolves 17.94% of the 300 SWE-bench Lite tasks on average over 6 runs (standard deviation 0.49), with pass@1 17.94 and pass@6 32.67. Convert these to task counts, explain what the gap between pass@1 and pass@6 says about per-task randomness, and decide whether the "w/o demonstration" ablation (16.3 vs 18.0) is likely to be a real effect.

    What a strong answer covers
    • 17.94% of 300 is about 54 tasks per run; one task is 0.33 points, so the run-to-run standard deviation of 0.49 is about 1.5 tasks.
    • pass@6 of 32.67% is about 98 tasks solved at least once, so about 44 tasks are solved in some runs but not others; per-task outcomes are much noisier than the average.
    • The demo ablation gap is 1.7 points, about 5 tasks, or about 3.5 run-level standard deviations, so it is probably real if the ablation run had similar variance, but it comes from a single run.
    • Because many tasks flip between runs, a paired comparison on the same tasks with several seeds per condition gives a much better test than comparing two single-run averages.
  2. Mechanism

    In the SWE-agent ablations on Lite, "iterative search" (results shown one at a time with next and prev, like an IDE) scores 12.0, worse than having no special search command at all (15.7), while "summarised search" (all matching files listed, capped at 50 results, otherwise ask for a narrower query) scores 18.0. Explain the mechanism.

    What a strong answer covers
    • With iterative search, agents tend to step through every match with next, which spends turns, budget and context on irrelevant hits.
    • This drains the cost budget or context window before editing starts, so the task ends unfinished, which is worse than plain grep and find.
    • Summarised search gives a compact overview in one observation, so the agent can choose where to look next in one step.
    • The 50-result cap with a request to narrow the query acts as a guardrail against flooding the context and pushes the agent to reformulate.
    • The general principle is that an interface built for humans, who skim and skip, can hurt an LM, for which every token of output has a cost.
  3. What if…

    Table 3 reports these SWE-bench Lite results relative to the full interface at 18.0: no edit command 10.3, edit without linting 15.0, 30-line viewer 14.3, full-file viewer 12.7, full history instead of last 5 observations 15.0, no demonstration 16.3. Rank the components by measured importance, and say what the table cannot tell you about interactions between components.

    What a strong answer covers
    • Largest drops: no edit (−7.7), iterative search (−6.0), full-file viewer (−5.3), 30-line viewer (−3.7), then no linting and full history (−3.0 each), and no demo (−1.7).
    • Each row changes one component with the others fixed, so the table measures marginal effects around one configuration, not interactions.
    • For example, the linter may matter more when the viewer is small, or history compression may matter more with verbose search; the one-at-a-time design cannot show this.
    • The rows are single runs on 300 tasks, with a run-to-run standard deviation of about 0.5 points, so differences under about 1.5 points are hard to rank.
    • All ablations use one model, GPT-4 Turbo; the best viewer size or history length may differ for models with longer context or better long-context use.
  4. Critique

    A reader summarises SWE-agent as "GPT-4 solves 12.5% of SWE-bench". Critique this summary, and explain what the paper's real contribution is and which parts of its evidence age well.

    What a strong answer covers
    • The headline numbers are for 2024 models; later systems score far higher, so the specific score is stale.
    • The score belongs to the model plus interface; with the same GPT-4 Turbo, a shell-only agent gets 11.0 on Lite vs 18.0 with the ACI, and retrieval-then-generate (RAG) gets 2.67.
    • The lasting contribution is the ACI idea: commands, feedback format and history management can be designed for LMs as users, and evaluated with ablations.
    • There are small inconsistencies to check, such as HumanEvalFix reported as 88.3 in the text and 87.7 for Python in Table 2.
    • SWE-bench uses repository tests as the success check, so a patch can pass the tests without fixing the issue in general; the paper's failure analysis finds overly specific fixes among failures.
  5. Connect

    CodeAct argues for giving the agent a general Python interpreter as its action space; SWE-agent argues for a small set of simple, compact commands with concise feedback. Are these designs in conflict? Explain using the ACI principles and the evidence each paper gives.

    What a strong answer covers
    • Both treat the action space as a design choice that changes performance with the model held fixed.
    • CodeAct gains from composition: loops and variables let one action do many tool calls; SWE-agent gains from compact high-level commands (edit a line range in one step) and from limiting output size.
    • They agree on feedback: CodeAct returns tracebacks, and SWE-agent adds a linter and shows the updated file after each edit.
    • They differ in openness: SWE-agent keeps bash available but steers the agent to a curated set; CodeAct leaves the interpreter fully open.
    • A combined design is common in later coding agents: general execution plus a few curated, output-limited tools for search and editing.
  6. Design

    You are designing the search tool for a deep-research agent over a large fixed corpus. Using SWE-agent's ACI findings, design the tool's command set, its output format and its overflow behaviour, and describe an ablation study to measure each choice.

    What a strong answer covers
    • Commands: a search call that returns a ranked list of doc IDs, titles and short snippets, and a separate read call that returns a bounded window of a document with position markers.
    • Output: a fixed number of results with short snippets, so each observation has a predictable token cost; for very broad queries, return counts and ask for a narrower query instead of dumping results.
    • History: collapse old search results to one line each (query and top IDs) so the agent remembers what it tried without carrying full snippets.
    • Ablations: vary the number of results, snippet length, read-window size and history compression one at a time, with the model and budget fixed.
    • Metrics: answer accuracy, evidence recall of gold documents, number of search calls, and tokens per task, over several seeds.

Done with this page?

Status