AutoCodeRover Documentation
repository·main·Indexed 25 days ago
https://github.com/autocoderoversg/auto-code-roverAutoCodeRover is an autonomous program improvement tool designed to resolve GitHub issues, including bug fixes and feature additions. It combines Large Language Models (LLMs) with program-structure-aware code search and statistical fault localization. The tool supports multiple operation modes, including github-issue, local-issue, and SWE-bench tasks, and is compatible with models from OpenAI, Anthropic, Meta, AWS Bedrock, Groq, and local models via Ollama.
What's inside AutoCodeRover
- The benchmark results for AutoCodeRover are categorized by patch application success and resolution status. The metrics track how many issues were successfully resolved, partially resolved, or not resolved, both for cases where patches were successfully applied and for the total set of attempts (including failures).
Configure parallel execution in AutoCodeRover
mainDo not attempt to run multiple independent processes of
scripts/run.pyin parallel, as different task instances may share the same local codebase, leading to conflicts.Instead, use the built-in parallelism support by setting the
num_processesfield in your configuration file. The script handles the internal parallelism safely. Note: settingnum_processestoo high may exceed OpenAI token limits and cause task failures.Run AutoCodeRover in GitHub issue mode
mainUse
github-issuemode to run AutoCodeRover on a live GitHub issue. You must provide the project's clone link, a specific commit hash, and the link to the GitHub issue page. The tool will clone the repository, checkout the specified commit, and attempt to generate a patch.Successful patch generation writes the path to
selected_patch.jsonin the specified--output-dir.cd /opt/auto-code-rover conda activate auto-code-rover PYTHONPATH=. python app/main.py github-issue --output-dir output --setup-dir setup --model gpt-4o-2024-05-13 --model-temperature 0.2 --task-id <task id> --clone-link <link for cloning the project> --commit-hash <any version that has the issue> --issue-link <link to issue page>Run the demo visualization development server
mainTo start the development server for the
frontpackage, use your preferred package manager to run thedevscript. Once running, the application will be accessible athttp://localhost:3000.npm run dev # or yarn dev # or pnpm dev # or bun devSet up AutoCodeRover for SWE-bench-lite replication using Docker
mainTo replicate results on SWE-bench-lite, use the provided Docker image which contains all task instance environments. It is recommended to run this on Ubuntu 20.04.
- Pull the latest experiment image:
docker pull yuntongzhang/auto-code-rover:experiment - Start the container:
docker run -it yuntongzhang/auto-code-rover:experiment - Inside the container, activate the conda environment:
source activate base conda activate auto-code-rover - Configure global git settings:
git config --global user.email acr@nus.edu.sg git config --global user.name acr - Set your OpenAI API key:
export OPENAI_KEY=xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
docker pull yuntongzhang/auto-code-rover:experiment docker run -it yuntongzhang/auto-code-rover:experiment- Pull the latest experiment image:
Set up the environment for local testing
mainTo run tests locally, you must first create and activate the
auto-code-roverenvironment using Conda, then installtoxfrom theconda-forgechannel.Required tools:
- Tox: Configures the tests.
- Pytest: Executes the tests.
- Coverage.py: Measures code coverage.
conda env create -f environment.yml conda activate auto-code-rover conda config --add channels conda-forge conda config --set channel_priority flexible conda install -y toxConfigure local Llama 3 models via Ollama
mainTo use local models like
llama3with AutoCodeRover:- Install Ollama: Download and install Ollama.
- Pull Models: Run
ollama pull llama3to download the model. - Network Configuration:
- If running ACR in a Docker container and Ollama on the host machine, use Docker Desktop to simplify host access.
- If using only Docker Engine, you must add either
--net=hostor--add-host host.docker.internal=host-gatewayto yourdocker runcommand so the container can communicate with the Ollama server on the host.
Set up and run SWE-bench tasks
mainTo run AutoCodeRover on SWE-bench task instances, follow these steps:
1. Install SWE-bench Docker
Install the specialized SWE-bench docker fork used for regression tests:
conda activate auto-code-rover git submodule update --init --recursive cd SWE-bench-docker pip install .2. Set up the Testbed
It is recommended to set up SWE-bench on a host machine rather than inside a container.
- Clone the SWE-bench fork and install dependencies.
- Create a
tasks.txtfile containing one task ID per line (e.g.,django__django-11133). - Run the setup harness:
cd <SWE-bench-path> conda activate swe-bench python harness/run_setup.py --log_dir logs --testbed testbed --result_dir setup_result --subset_file tasks.txtThis creates a
testbeddirectory with the source code and a conda environment for the task.3. Run Tasks
Single Task:
cd <AutoCodeRover-path> conda activate auto-code-rover PYTHONPATH=. python app/main.py swe-bench --model gpt-4o-2024-05-13 --setup-map <SWE-bench-path>/setup_result/setup_map.json --tasks-map <SWE-bench-path>/setup_result/tasks_map.json --output-dir output --task django__django-11133Multiple Tasks (via file):
cd <AutoCodeRover-path> conda activate auto-code-rover PYTHONPATH=. python app/main.py swe-bench --model gpt-4o-2024-05-13 --setup-map <SWE-bench-path>/setup_result/setup_map.json --tasks-map <SWE-bench-path>/setup_result/tasks_map.json --output-dir output --task-list-file <SWE-bench-path>/tasks.txtRun AutoCodeRover in local issue mode
mainUse
local-issuemode to run AutoCodeRover on a local codebase and a local issue description file. This is useful when you have already prepared the repository and the issue details manually.Successful patch generation writes the path to
selected_patch.jsonin the specified--output-dir.cd /opt/auto-code-rover conda activate auto-code-rover PYTHONPATH=. python app/main.py local-issue --output-dir output --model gpt-4o-2024-05-13 --model-temperature 0.2 --task-id <task id> --local-repo <path to the local project repository> --issue-file <path to the file containing issue description>Set up AutoCodeRover in local mode
mainFor running SWE-bench experiments or managing dependencies manually, use a local installation with Conda. This method uses an
environment.ymlfile to manage Python dependencies.- Create Environment: Use Conda to create the environment from the provided file.
- Configure Keys:
Ensure
OPENAI_KEYorANTHROPIC_API_KEYis set in your shell before execution.
Run AutoCodeRover experiments
mainNavigate to the
/opt/auto-code-rover/directory inside the container to start an experiment. By default, running the vanilla-lite configuration usesgpt-4-0125-previewon SWE-bench-lite instances.This command consolidates all generated patches into a single file named
predictions_for_swebench.json. To evaluate correctness, you must copy this file out and use either the Containerized Evaluation Harness or Moatless EvalTools.python scripts/run.py conf/vanilla-lite.confManage experiment runs and overwriting results
mainWhen running multiple experiments sequentially, it is recommended to use a unique
idin the configuration file for each run, as the output directory is named after thisid.If you wish to use the same
idand overwrite previous results, use the-fflag withscripts/run.pyto remove the existing experiment results for thatidbefore starting the new run.