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 1453. 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 comparison4. 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.