SuperAPI AI Directory

SWE-agent - Princeton's open-source AI programmer agent

Author: AI小集 · Original source: AI工具集

What is SWE-agent

SWE-agent is an open-source AI programmer and software engineer system developed by researchers in the NLP group at Princeton University. It leverages the capabilities of large language models (such as GPT-4) to automatically solve issues in GitHub repositories. SWE-agent interacts with codebases through an agent-computer interface (ACI), and can perform tasks such as browsing, editing, testing, and executing code. On the SWE-bench test set, the system demonstrates accuracy similar to the closed-source AI programmer Devin, solving a problem in an average of 93 seconds and achieving SOTA performance.

On 25% of the SWE-bench test set, SWE-agent achieved accuracy similar to Devin — solving 12.29% of the problems. SWE-agent is now open-sourced on GitHub, and the research paper will be released on April 10.

SWE-agent

Official entry point for SWE-agent

Main features of SWE-agent

  • Pull request issue resolution: SWE-agent can understand issues in GitHub repositories and attempt to fix them by creating pull requests.
  • Code editing and repair: SWE-agent can browse and edit files in a codebase, automatically fixing errors and vulnerabilities in the code.
  • Automatic syntax checking: During code editing, SWE-agent can run a linter (code checking tool) to ensure the code conforms to syntax standards.
  • File viewer: Provides a specially built file viewer that can display 100 lines of code per round, with support for scrolling up and down and search functionality, so that code can be viewed and edited more efficiently.
  • Full-directory string search: SWE-agent has full-directory string search functionality, and can concisely list all files and code snippets matching the search criteria.
  • Commands and feedback: Through the agent-computer interface (ACI), SWE-agent can receive and execute commands given in natural language form, and provide corresponding feedback.
  • Test writing and execution: SWE-agent can write and execute test code to verify the effectiveness of fixes.
SWE-agent Demo

SWE-agent workflow

  • Understanding the issue: First, SWE-agent understands the issue description in a GitHub repository through natural language processing (NLP) technology. This step relies on its internally integrated large language model (such as GPT-4), which can parse and understand human-written issue reports.
  • Agent-computer interface (ACI): SWE-agent uses ACI to interact with the codebase. ACI is a set of command and feedback formats designed to simplify interaction between large models and computer systems. Through ACI, SWE-agent can browse the codebase, search files, view and edit code, and even execute code.
  • Code analysis and repair: After understanding the issue, SWE-agent analyzes the relevant code, locates possible errors or vulnerabilities, and generates a fix plan. This may include modifying existing code, adding missing code, or refactoring the code structure.
  • Automated testing: To ensure the fix is effective, SWE-agent can automatically write and execute test cases. These test cases are intended to verify whether the code changes solve the original issue without introducing new errors.
  • Performance feedback: Every operation performed by SWE-agent generates feedback, which is used to evaluate the effectiveness of its work. Particularly in the SWE-bench benchmark, SWE-agent evaluates whether the pull request it generates truly resolves the issue.
  • Iteration and Optimization: The design of SWE-agent allows for continuous iteration and optimization. By collecting feedback and performance data from use, the research team continuously improves the ACI design, enhancing SWE-agent's problem-solving capabilities and the accuracy of code fixes.