tl;dr: Proposal to automatically create AI-generated PRs to fix broken bazel builds. It doesn’t impact anyone who doesn’t care about bazelbot.
Background
One of the build systems LLVM supports building with is Bazel. Contributors to LLVM are not required to keep Bazel builds in working state as it is part of Peripheral-tier that cater to few specific subcommunities, including us in Google where our consumption of LLVM downstream relies on keeping upstream Bazel builds working. Because of this, we manually fix Bazel builds multiple times a day.
Proposal
We would like to deploy an experimental AI-assisted bot that automatically creates verified (by running local bazel builds) pull requests to fix Bazel builds, which are then manually reviewed and merged by Bazel maintainers.
Initial Design & Deployment
Bot will be a simple python script that listens to breakages in our upstream Bazel buildkite pipeline. The Bot monitors for new bazel breakages (passed to failed build state transition). The bot identifies failures and first attempts a resolution by running dwyu command from bant.build which fixes missing bazel deps for us. If that is unsuccessful, it consults an AI agent for code changes required to resolve the Bazel error, using the SHA of the breaking commit as a reference. Suggestions are verified using a local build which if fails triggers the AI agent again in a loop until local build verification succeeds or we hit the maximum threshold. When the local build verification succeeds, changes are pushed to a branch in llvm/llvm-project under this format: users/google/bazel-fix- followed by creating a pull request from this branch. Bot gives up after repeated failed verifications. Code changes by dwyu and the AI agent will exclusively be to Bazel files in utils/bazel.
The bot will be running in Google’s cloud infrastructure together with other machines that are currently supporting our upstream bazel builds enabling Bazel remote cache sharing. The AI agent will be using Gemini APIs to make calls to LLMs.
Testing
Running the bot on all Bazel breakages from Nov 1, 2025 to Dec 15, 2025 led it to generate fixes for ~85% of the total bazel breakages. Here are the sample fixes by the AI bot for these breakages. While more than 80% were completely identical to fix proposed manually, some of them included harmless unnecessary additions. Refining the prompt over time should facilitate both quantitative improvements in reliability and qualitative enhancements in the overall quality of fixes. Moreover, all these fixes are purely AI-generated and didn’t run the dwyu tool which should reduce unnecessary additions even further in the final deployed version.
Out of total breakages analyzed above, around ~40% of them were simple dependency fixes that could be handled by dwyu while the rest of them needed AI assistance.
Alternatives considered
A non-AI powered Bazel bot that can handle all Bazel breakages could be another solution. This would be similar to llvmgnsyncbot that syncs GN build files from CMake and pushes any changes to the main LLVM branch. Replicating such a solution to sync Bazel BUILD files from CMake is not possible due to Bazel’s strict deps, and layering checks. There isn’t enough information in just CMake files to fix Bazel builds, requiring us to look at other files for a proper solution to handle all corner cases. It quickly becomes complicated and hard to maintain. Turning up an AI agent on the other hand has shown potential to handle a variety of corner cases for us and has proven sufficiently accurate.
Asks from the LLVM community
We require LLVM org admins on GitHub to install a Google-LLVM GitHub app, which allows us to do these kinds of integrations with enhanced security and higher API rate limits while not being tied to any specific user account. This is GitHub’s recommended way for long-lived integrations. This will also allow us to create PRs with the bot’s identity. The app will request the following two repository permissions on llvm/llvm-project. They are broader permissions than they need to be because GitHub doesn’t allow granularity finer than this:
-
Contents (read/write): Required to create branches. Allows creating and writing to any branch but the bot would only be creating branches under users/google/
-
Pull request (read/write): Required to create pull requests. Allows creating any pull request but we would only be sending pull requests to fix Bazel breakages.
There’s precedence with granting such permissions to bots like llvmgnsyncbot (which operates as a regular GitHub user with commit access to push such changes). The part of the Bazel bot described in this RFC that’s responsible for interacting with GitHub is not AI-powered. So there’s no risk that the AI bot will hallucinate and do random branch writes or pull request creation. It will only create branches under users/google/ and create pull requests changing only Bazel files. It is also more secure as GitHub apps require using short-lived tokens for requests which expire within hours vs personal access tokens which have longer expiration and can get misused if leaked.
Because we manually have to fix every Bazel breakage upstream today, the frequency of new automated pull requests will not be more than what it is today. Pull requests will continue to get marked with a bazel tag just as it’s done today to allow filtering these out. Since we require these fixes urgently to keep our internal processes working, the review load of all such pull requests should mostly be handled by Google.
Creating user branches in the LLVM repository and creating PRs from there makes it possible to manage everything with GitHub app authentication. Maintaining a separate fork for such branches, however, requires setting up a different bot account. To keep things simple, we would like to use users/google/* branches for this integration that will be pruned by the bot after the pull request is merged.
Let me know if you have any feedback or objections.
This RFC was accepted in this message.