ScriptsApr 6, 2026·3 min read

SWE-agent — Automated Bug Fixing with AI Agents

AI agent system from Princeton NLP that autonomously fixes GitHub issues. Navigates codebases, writes patches, and submits pull requests. Resolves 12% of real-world SWE-bench tasks. 15,000+ stars.

TL;DR
SWE-agent autonomously navigates codebases and writes patches to fix GitHub issues.
§01

What it is

SWE-agent is an AI agent system from Princeton NLP that autonomously fixes GitHub issues. Given a bug report or feature request, it navigates the codebase, understands the problem, writes a patch, and submits a pull request. It uses a custom agent-computer interface (ACI) designed for code editing that gives the AI structured commands for file navigation, editing, and testing.

SWE-agent targets research teams studying AI coding capabilities and development teams exploring automated bug fixing. It demonstrates how purpose-built tool interfaces improve AI agent performance on real-world software engineering tasks.

§02

Why it saves time or tokens

SWE-agent's custom ACI reduces the tokens needed for code exploration compared to generic tool-use approaches. Instead of reading entire files, the agent uses structured commands to navigate, search, and edit specific sections. This focused interaction pattern means fewer wasted tokens on irrelevant code and faster convergence on the fix.

§03

How to use

  1. Clone the SWE-agent repository and install dependencies
  2. Configure your LLM API key (OpenAI, Anthropic, etc.)
  3. Point SWE-agent at a GitHub issue and let it attempt a fix
§04

Example

# Run SWE-agent on a GitHub issue
python run.py \
  --model_name claude-sonnet-4-20250514 \
  --data_path issue.json \
  --config_file config/default.yaml

# SWE-agent will:
# 1. Read the issue description
# 2. Explore the repository structure
# 3. Find relevant files
# 4. Write and test a patch
# 5. Submit the fix
ACI CommandPurpose
find_fileLocate files by name
search_dirSearch for text patterns
openView file contents
editModify specific lines
submitPropose the patch
§05

Related on TokRepo

§06

Common pitfalls

  • SWE-agent works best on well-described issues with clear reproduction steps; vague issues produce unreliable patches
  • The agent may propose patches that pass tests but introduce subtle regressions; human review is still essential
  • Running SWE-agent on large repositories with complex build systems increases token costs and reduces success rates

Frequently Asked Questions

What is the success rate of SWE-agent?+

SWE-agent's success rate varies by model and benchmark. On the SWE-bench dataset of real-world GitHub issues, it resolves a meaningful percentage of tasks end-to-end. Success rates improve with more capable models and well-structured issue descriptions. Check the SWE-bench leaderboard for current numbers.

What LLM models does SWE-agent support?+

SWE-agent supports OpenAI GPT-4, Anthropic Claude, and other LLM providers. The choice of model significantly affects performance. More capable models produce better patches. You configure the model in the SWE-agent config file.

Can SWE-agent fix any type of bug?+

SWE-agent performs best on bugs with clear symptoms, error messages, or test failures. It handles code logic bugs, missing error handling, and simple feature additions well. Complex architectural issues, performance bugs, or security vulnerabilities are harder for it to address autonomously.

How does the agent-computer interface (ACI) help?+

The ACI provides structured commands (find, open, edit, search) instead of raw shell access. This constrains the agent's action space, reducing errors and token waste. The ACI also provides formatted output that the AI can parse reliably, improving its ability to navigate large codebases.

Can I use SWE-agent on my private repositories?+

Yes. SWE-agent runs locally and accesses repositories through Git. You clone your private repo, create an issue description file, and point SWE-agent at it. The code and patches stay on your machine. Only the issue description and code diffs are sent to the LLM API.

Citations (3)
🙏

Source & Thanks

Created by Princeton NLP. Licensed under MIT.

SWE-agent — ⭐ 15,000+

Thanks to Princeton NLP for advancing the frontier of automated software engineering.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets