Skip to content

Implement LLM-driven review assigner for PR bot - #39980

Draft
kennknowles wants to merge 1 commit into
apache:masterfrom
kennknowles:review-assigner
Draft

Implement LLM-driven review assigner for PR bot#39980
kennknowles wants to merge 1 commit into
apache:masterfrom
kennknowles:review-assigner

Conversation

@kennknowles

Copy link
Copy Markdown
Member

Beam's existing PR reviewer assigner works like so:

  • matches directory paths against coarse labels (e.g. java, python, kafka)
  • and assigns one reviewer per matching label via round-robin

The downsides:

  • Reviewer bloat on multi-directory PRs
  • Doesn't stay up to date
  • Is pretty coarse

This PR is meant to introduce a little more intelligence:

  • Read the history and do some heuristics on who has edited in a meaningful way recently
  • Provide that heuristic along with the history to an LLM to choose a good reviewer
  • Give the reviewer a one-liner about why they were chosen

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions github-actions Bot added the build label Sep 2, 2026
Beam's existing PR reviewer assigner matches directory paths against
coarse labels (e.g. java, python, kafka) and assigns one reviewer per
matching label via round-robin. This creates reviewer bloat on
multi-directory PRs, fails to consider who actually worked on the
affected files, and offers no rationale to reviewers on why they were
tagged.

Introduce an intelligent reviewer assigner powered by Gemini:

1. Extract git revision history and churn for touched files (with
   fallback to parent directory for new files), filtering automated
   bots and the PR author.
2. Use Gemini to identify true domain experts based on substantive
   commits rather than mechanical edits (e.g. formatting, version
   bumps), and minimize the assigned reviewer set (target: 1 reviewer).
3. Post an informative PR comment stating the chosen reviewer(s), their
   specific expertise rationale, and suggested backup experts.
4. Support seamless handover to backup experts when a reviewer requests
   reassignment via "assign to next reviewer".
5. Provide a deterministic recency-decayed familiarity scoring fallback
   when GEMINI_API_KEY is not configured or fails.
@kennknowles

Copy link
Copy Markdown
Member Author

@damccorm I need to give this a more thorough review, but the biggest picture is that I don't really know what it looks like for Beam's infra to make the gemini calls that are in this using a GEMINI_API_KEY or if there is an entirely different appropriate architecture.

this.exclusionList.map((e) => `@${e}`).join(", ") || "(none)";

return `You are the Apache Beam Code Review Assigner.
Your goal is to choose a small, optimal set of expert reviewers for a pull request based on real git history and file churn.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done a full review, but I don't think that this has the information needed to do this optimally. Specific things which aren't covered, but seem important:

  1. How many times has this reviewer been assigned recently (right now we just round robin)
  2. Committership
  3. Does this person actually want to be a reviewer for the area/are they willing to respond in a timely manner (I can think of contributors who commit a good amount of code, but aren't necessarily ideal reviewers).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the problems, do we need a full system overhaul or can we just make smaller less-invasive changes? The gemini infra is going to be painful since it will need to be a secret we regularly rotate.

Reviewer bloat on multi-directory PRs

Could this be solved by just choosing one of the reviewers from the set of available ones (probably with a preference for code-related expertise)?

Doesn't stay up to date

Is this really an issue? I have not seen this one cause meaningful problems since reviewers tend to opt out fairly quickly once they are out of the loop.

I think the ability to opt in/out is a pretty useful feature.

Is pretty coarse

This is less avoidable (though we certainly could have tighter categories).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could ditch gemini and just go with the heuristic score, for example.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And TBH I think the selected reviewers are just almost always not the right person. I'm biased because I get on there for "java" and "website" and "fallback" and realistically there's always a better choice. I don't think load balancing to people who are that vaguely related is necessarily good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants