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.

AG
Agent Toolkit · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

pip install swe-agent
# Fix a GitHub issue automatically
swe-agent run \
  --model claude-sonnet-4-20250514 \
  --issue https://github.com/user/repo/issues/123

SWE-agent clones the repo, analyzes the issue, navigates the codebase, writes a fix, and creates a patch.


Intro

SWE-agent is an AI agent system from Princeton NLP that autonomously resolves real-world GitHub issues with 15,000+ GitHub stars. Give it an issue URL and it clones the repository, navigates the codebase, identifies the bug, writes a patch, and validates the fix — achieving 12.5% on the SWE-bench benchmark of real-world software engineering tasks. It uses a custom Agent-Computer Interface (ACI) designed specifically for code navigation and editing. Best for researchers studying AI coding capabilities and teams experimenting with automated bug fixing. Works with: Claude, GPT-4. Setup time: under 5 minutes.


How It Works

1. Issue Analysis

SWE-agent reads the GitHub issue and understands:

  • What is broken
  • Expected vs actual behavior
  • Relevant error messages and stack traces

2. Codebase Navigation

Using its Agent-Computer Interface (ACI):

# The agent navigates like a developer
find_file "auth_handler.py"
open_file "src/auth/auth_handler.py"
search_file "validate_token"
goto_line 145

3. Bug Identification

The agent reads relevant code, traces the logic, and pinpoints the issue:

Analyzing: src/auth/auth_handler.py:145
Issue: Token expiry check uses UTC timestamp but comparison uses local time
Fix: Convert both to UTC before comparison

4. Patch Generation

Writes and applies the fix:

# Before
if token.expiry < datetime.now():

# After (SWE-agent fix)
if token.expiry < datetime.now(timezone.utc):

5. Validation

Runs existing tests to verify the fix:

Running test suite...
test_auth_valid_token: PASS
test_auth_expired_token: PASS (was FAIL)
test_auth_refresh: PASS
All tests passing.

Agent-Computer Interface (ACI)

Custom commands designed for code navigation:

Command Action
find_file Search for files by name
open_file Open and display file content
search_file Search within current file
search_dir Search across directory
goto_line Jump to specific line
edit Edit lines in current file
submit Submit the patch

SWE-bench Results

Model Resolve Rate
Claude Sonnet 12.5%
GPT-4 10.3%
GPT-3.5 3.8%

Key Stats

  • 15,000+ GitHub stars
  • Princeton NLP research
  • 12.5% SWE-bench resolve rate
  • Custom Agent-Computer Interface
  • Supports Claude and GPT-4

FAQ

Q: What is SWE-agent? A: SWE-agent is an AI system from Princeton NLP that autonomously fixes real-world GitHub issues by navigating codebases, writing patches, and validating fixes.

Q: Is SWE-agent free? A: Yes, open-source under MIT license. You need LLM API keys.

Q: Can SWE-agent fix any bug? A: It resolves about 12.5% of real-world software engineering tasks. It works best on well-specified bugs with clear reproduction steps.


🙏

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