Website & Demo | Discord | Paper [coming April 10th]
## ๐ Overview SWE-agent turns LMs (e.g. GPT-4) into software engineering agents that can fix bugs and issues in real GitHub repositories. On [SWE-bench](https://github.com/princeton-nlp/SWE-bench), SWE-agent resolves **12.29%** of issues, achieving the state-of-the-art performance on the full test set. SWE-agent is built and maintained by researchers from Princeton University.### โจ Agent-Computer Interface (ACI) We accomplish these results by designing simple LM-centric commands and feedback formats to make it easier for the LM to browse the repository, view, edit and execute code files. We call this an **Agent-Computer Interface** (ACI) and build the SWE-agent repository to make it easy to iterate on ACI design for repository-level coding agents. Just like how typical language models requires good prompt engineering, good ACI design leads to much better results when using agents. As we show in our paper, a baseline agent without a well-tuned ACI does much worse than SWE-agent. SWE-agent contains features that we discovered to be immensely helpful during the agent-computer interface design process: 1. We add a linter that runs when an edit command is issued, and do not let the edit command go through if the code isn't syntactically correct. 2. We supply the agent with a special-built file viewer, instead of having it just ```cat``` files. We found that this file viewer works best when displaying just 100 lines in each turn. The file editor that we built has commands for scrolling up and down and for performing a search within the file. 3. We supply the agent with a special-built full-directory string searching command. We found that it was important for this tool to succintly list the matches- we simply list each file that had at least one match. Showing the model more context about each match proved to be too confusing for the model. 4. When commands have an empty output we return a message saying "Your command ran successfully and did not produce any output." Read our paper for more details [coming soon!]. ``` @misc{yang2024sweagent, title={SWE-agent: Agent Computer Interfaces Enable Software Engineering Language Models}, author={John Yang and Carlos E. Jimenez and Alexander Wettig and Shunyu Yao and Karthik Narasimhan and Ofir Press}, year={2024}, } ``` ## ๐ Setup ### ๐๏ธ Express Setup + Run You can run the software directly using Docker. 1. [Install Docker](https://docs.docker.com/engine/install/), then start Docker locally. 2. Run `docker pull sweagent/swe-agent:latest` 3. Add your API tokens to a file `keys.cfg` as explained [below](#-add-your-api-keystokens) Then run ```bash # Please remove all comments (lines starting with '#') before running this command! docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \ # replace /xxxx/keys.cfg with the paths to your keys -v /xxxx/keys.cfg:/app/keys.cfg \ sweagent/swe-agent-run:latest \ python run.py --image_name=sweagent/swe-agent:latest \ # the rest of the command as shown in the quickstart/benchmarking section, # for example to run on a specific github issue --model_name gpt4 \ --data_path https://github.com/pvlib/pvlib-python/issues/1603 \ --config_file config/default_from_url.yaml --skip_existing=False ``` > [!TIP] > * For more information on the different API keys/tokens, see [below](#-add-your-api-keystokens). > * If you're using docker on Windows, use `-v //var/run/docker.sock:/var/run/docker.sock` > (double slash) to escape it ([more information](https://stackoverflow.com/a/47229180/)). ### ๐ Setup with conda (development version) To install the development version: 1. [Install Docker](https://docs.docker.com/engine/install/), then start Docker locally. 2. Clone this repository 3. [Install Miniconda](https://docs.anaconda.com/free/miniconda/miniconda-install/), then create the `swe-agent` environment with `conda env create -f environment.yml` 4. Activate using `conda activate swe-agent`. 5. Run `./setup.sh` to create the `swe-agent` docker image. 6. Create a `keys.cfg` file at the root of this repository ([see below](#-add-your-api-keystokens)) > [!WARNING] > Expect some issues with Windows (we're working on them). > In the meantime, simply use Docker (see above). > If you want the latest version, you can also build your own `swe-agent-run` > container with the `Dockerfile` at the root of this repository by running > `docker built -t sweagent/swe-agent-run:latest .` ### ๐ Add your API keys/tokens For the conda setup, create a `keys.cfg` file at the root of this repository and populate it with your API keys. ``` GITHUB_TOKEN: 'GitHub Token Here (required)' OPENAI_API_KEY: 'OpenAI API Key Here if using OpenAI Model (optional)' ``` If you're using docker, pass the key with the [`-e` option](https://stackoverflow.com/a/30494145/) to the docker container.