In the previous phase, the preliminary design phase of the project was completed, resulting in a comprehensive diagram outlining the project architecture and initial code to test the preliminary requirements of the models. This design serves as a blueprint for the development process. Since then, significant progress has been made, particularly in creating an environment for our agents and automating the pull request lifecycle.
In this blog, I will recap the work I did since then on creating an environment for our agents, focusing on the steps taken, resources utilized, and the challenges faced. This phase is crucial as it lays the foundation for allowing the agents to navigate codespaces and solve issues efficiently.
Creating an environment for the agents was a critical step in the project. This environment would enable the agents to interact with and navigate through code repositories, understand the context, and solve issues autonomously.
Initially, I focused on researching various approaches and tools to aid in environment creation ie. allowing them to navigate codespaces and solve issues. During my research, I came across several noteworthy papers:
After evaluating these resources, I decided that implementing AutoCodeRover with a toy repository would be the best fit for our project. I began working on this implementation, anticipating it would provide a solid framework for our agents.
AutoCodeRover is a system designed to help agents navigate code repositories efficiently. It employs advanced techniques to understand the structure and dependencies within a codebase, making it highly suitable for our project. By implementing AutoCodeRover, I aimed to leverage its capabilities to enhance our agents’ ability to solve issues and navigate complex codebases autonomously.
This environment I created is based on the paper “AutoCodeRover: Autonomous Program Improvement” and it’s open-source code implementation on github has been used as a dependency in my project .
Implementing AutoCodeRover was not without its challenges. Alhough it was compatible with Ollama and running locally hosted open-source LLMs like LLaMA3, it was only tested to work with GPT-4, and due to resource constraints, I had to adapt it to work with LLaMA3-7B, a significantly smaller model. This required substantial modifications to the prompts and underlying logic.
I spent considerable time debugging these changes, ensuring that the adapted prompts could still deliver effective results despite the limitations of the smaller model. This involved understanding the nuances of prompt engineering and making iterative adjustments. I documented the changes I made to the original repository code at my-own-fork.
Ensuring that the setup and implementation were reproducible was a priority. I documented each step meticulously to facilitate easy replication by others.
venv
to ensure that all dependencies were isolated and managed efficiently.requirements.txt
requirements.txt
file listing all necessary dependencies. This ensured that anyone setting up the environment could install all required packages with a single commandIn this phase, the primary focus was to automate the entire pull request lifecycle, from issue identification and solution to the creation, submission, review, and merging of pull requests. This process involved the creation of two essential classes: ContributorAgent
and MaintainerAgent
. Below, I detail the steps taken and the challenges faced during this process.
The first step was to design and initialize the ContributorAgent
class. This agent is responsible for generating and submitting pull requests. I implemented the necessary methods to allow the agent to identify issues within the codebase, propose solutions, and create pull requests.
ContributorAgent
class. This class includes methods to scan the codebase for issues, generate solutions, and package these solutions into pull requests.ContributorAgent
, I integrated docker-py
for Docker management. This allowed the agent to operate within a Docker container, which replicates the auto-code-rover project’s environment.ContributorAgent
made changes, it was crucial to extract the generated diff from the Docker container to the local system for review and integration.ContributorAgent
needed to not only propose changes but also follow the proper protocol for committing these changes and submitting them for review..diff
file and open a pull_request.md
with adequate description for the same stored in a local pull_requests
folder.docker-py
, which involved modifying some of its internal scripts to run within the container context.The MaintainerAgent
is responsible for reviewing submitted pull requests and deciding whether to accept or reject them based on their quality and relevance.
MaintainerAgent
was designed to review the pull request description generated by the ContributorAgent
. It will later also check for metrics such as code quality, relevance, and adherence to project guidelines.MaintainerAgent
merges the pull request into the main branch. This involves fetching the pull request, reviewing the diffs, and executing the merge.MaintainerAgent
to apply approved diffs to the local repository and commit the changes. This automation ensures that the approved changes are seamlessly incorporated into the project.reviewed_pr.py
The primary outcome of this phase is the reviewed_pr.py
file, which automates the creation, submission, review, and merging of pull requests by simulating the interactions between ContributorAgent
and MaintainerAgent
. This script encapsulates the workflow and ensures that the entire process is automated, efficient, and reproducible.
ContributorAgent
and MaintainerAgent
classes.ContributorAgent
.MaintainerAgent
.By automating the pull request lifecycle, I have streamlined the process of identifying and solving issues, creating and submitting pull requests, and reviewing and merging changes. This is a big step towards the upcoming phases of this project.
All of the code for this can be found at the OREL-group GSOC repository.