SWE-agent

On this page 7

SWE-agent is an open-source autonomous coding agent from researchers at Princeton University and Stanford University that lets a language model resolve real software issues by navigating a repository, editing files and running code inside a sandboxed environment. In AI for coding, it is best known for introducing the agent-computer interface (ACI), a set of tools and feedback formats designed specifically for language models rather than for human developers.

Published in 2024 and presented at NeurIPS that year, SWE-agent became a reference baseline for agentic coding research and for the SWE-bench family of benchmarks. Its central lesson is that interface design strongly affects agent performance: the same model solves far more tasks when the tools it uses are concise, guarded and easy to interpret.

How SWE-agent works on a repository

SWE-agent runs a reasoning and acting loop. At each step the model receives the issue text, its previous actions and the latest environment output, writes a short thought, and issues exactly one command. The command executes in an isolated Docker container that holds the repository, and the observation is returned to the model for the next step.

A typical trajectory follows a recognizable pattern. The agent reproduces the bug with a small script, localizes the faulty code by searching the repository, edits the relevant function, reruns the reproduction script and finally submits a patch as a Git diff. The run ends when the agent calls submit or exhausts its cost or step budget.

The following table outlines the stages of a standard SWE-agent run and what each stage produces.

StageMain actionsOutput
SetupClone repository, build container, load issueReady environment
ReproductionWrite and run a failing scriptConfirmed bug behavior
LocalizationSearch files, open and scroll codeSuspected faulty lines
EditingReplace code ranges with guarded editsModified source files
Verification and submissionRerun script, review diff, submitCandidate patch
Stages of a typical SWE-agent trajectory

The agent-computer interface

The agent-computer interface is the layer between the model and the operating system. Instead of exposing a raw shell only, the original SWE-agent added specialized commands for viewing, searching and editing code, each returning short, structured feedback that fits the model’s context window and attention limits.

The design follows a few principles from the paper: actions should be simple and compact, feedback should be informative but brief, and guardrails should prevent common errors from cascading. An edit that introduces a syntax error, for example, is rejected by an integrated linter and the agent sees the error instead of a broken file.

ToolFunctionWhy it helps a model
File viewerShows about 100 lines with line numbersAvoids flooding context with whole files
Search commandsfind_file, search_file, search_dirReturn compact match lists
Edit commandReplaces a line range with new textPrecise changes with lint checks
Empty-output noticeConfirms commands that print nothingPrevents confusion about success
SubmitProduces the final diffClear termination signal
Key ACI tools in the original SWE-agent

In ablation experiments, removing the linter or replacing the windowed viewer with full-file printing lowered the solve rate noticeably. This result made ACI design a recognized research topic alongside model training and prompting.

Benchmark results and project evolution

With GPT-4 Turbo, the original SWE-agent resolved about 12.5 percent of the full SWE-bench test set of 2,294 Python issues, a large jump over the roughly 4 percent reached by earlier retrieval-based baselines. Results on SWE-bench Lite and later SWE-bench Verified rose steadily as stronger models and refined tools appeared.

The project then broadened into a research ecosystem. SWE-agent 1.0 reorganized the configuration system and execution backend, mini-SWE-agent showed that a minimal agent using only Bash can reach strong scores with modern models, EnIGMA adapted the approach to cybersecurity capture-the-flag tasks, and SWE-smith generated training data for open models such as SWE-agent-LM. Exact scores change with each model release, so published numbers should be read with the model version and benchmark split in mind.

SWE-agent compared with other coding agents

SWE-agent is primarily a research and benchmarking framework, whereas many neighboring tools target daily developer workflows inside an editor or terminal. The comparison below highlights the differences in purpose rather than ranking quality.

SystemPrimary settingDistinguishing trait
SWE-agentAutonomous issue resolution in containersCustom ACI and reproducible research configs
OpenHandsOpen platform for software agentsBroader runtime with browser and web interface
AiderTerminal pair programmingHuman-in-the-loop edits with Git commits
ClineEditor extension agentInteractive approval of each action
AgentlessFixed localization and repair pipelineNo open-ended agent loop
SWE-agent and related agentic coding systems

Limitations and practical cautions

SWE-agent inherits the weaknesses of autonomous agents. It can loop on unproductive commands, misread an ambiguous issue or produce a patch that passes the reproduction script but breaks untested behavior. Costs grow with every step, so runs are capped by budget limits.

  • Benchmark contamination: models may have seen SWE-bench repositories during training, which can inflate scores.
  • Test overfitting: a patch that satisfies visible checks is not always a correct fix.
  • Security: agents execute arbitrary code, so sandboxing in containers is essential.
  • Language coverage: the original evaluations focused on Python repositories.
  • Human review: generated patches still require code review before merging.

Put simply

SWE-agent is a program that lets an AI model work like a junior developer. It reads a bug report, looks through the code, makes a change and tests it. Then it hands back a proposed fix.

Its key idea is giving the AI tools built for an AI. A person can scroll through a huge file easily. A model works better with small views, short search results and quick warnings when an edit is broken. Better tools led to many more solved bugs.

In practice

A university research group studies how open-weight models handle real maintenance work. The team runs SWE-agent on the 500 tasks of SWE-bench Verified, giving each run its own Docker container and a cost limit of a few dollars per task. Each run records a full trajectory of thoughts, commands and observations.

After the first pass, the researchers notice that many failures come from edits applied to the wrong file. They change the configuration so that the agent must run a reproduction script before editing, then repeat the evaluation with the same model. The solve rate rises by several percentage points, and the saved trajectories let the team explain each improvement in a paper rather than only reporting a final score. Before sharing results, they manually review a sample of passing patches to confirm that the fixes are genuinely correct.