-
Notifications
You must be signed in to change notification settings - Fork 94
feat: simplify the PR review prompt #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit shortens and simplifies the prompt for PR reviews. The previous prompt was long and complex, making it difficult to adapt to meet own needs. The new prompt is more concise and focused on the most important aspects of the review. The new prompt is divided into the following sections: - Setup: Instructions for the model to get the necessary information. - Review Focus: The key areas to focus on during the review. - Constraints: Rules that the model must follow. - Review Process: The steps to take to complete the review. - Comments Format: The format for the review comments. This change should improve the quality of PR reviews and make them more consistent. Fixes #208
4f8821b
to
51b378e
Compare
Tested it out with workflow dispatch: |
This is an improvement. The most serious problems that it doesn't address are:
Solving these problems requires adding an additional step that preprocesses diffs and provides them to the model in a format that makes it trivial for it to select the line number and side information and consistently provide the correct tool inputs. I would also recommend moving the prompt to a separate file for ease of editing. |
I don't, but the idea is simply to add a couple of steps to the workflow like: - name: Generate diff index
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}
PR_URL: ${{ steps.get_pr_context.outputs.pr_url }}
run: |
python .github/scripts/generate_diff_index.py --pr "${PR_URL}" --output diff_index.json
- name: Load prompt
run: |
{
echo "GEMINI_PROMPT<<EOF"
cat .github/data/gemini-pr-review-prompt.md
echo "EOF"
} >> "$GITHUB_ENV" Here This needs to be paired with prompt changes that direct the model to exclusively use the diff index for line number and side information, and prescribe its exact inputs to the GitHub MCP tools. |
@dan-ri so helpful, let me experiment with this 🙏🏾 |
A bit more detail on the kind of index format that works well: {
"version": 1,
"pr": "https://github.com/owner/repo/pull/123",
"files": [
{
"path": "relative/file/path.py",
"additions": 10,
"deletions": 2,
"hunks": [
{
"old_start": 38, "old_len": 7,
"new_start": 38, "new_len": 9,
"changes": [
{"t": "+", "side": "RIGHT", "line": 41, "preview": " def foo(...", "hash": "a1b2c3d4"},
{"t": "-", "side": "LEFT", "line": 42, "preview": "old line text", "hash": "deadbeef"}
]
}
]
}
]
} Notes:
|
One more suggestion -
Can we use |
|
changes by @sethvargo in #212 simplified the prompt, will close this for now, and separately look into handling diffs -- the change also switched to using an mcp tool for fetching diff, wonder if that changes the diff handling? will test with latest state and explore solutions in this thread -- @dan-ri @vivekkairi let's continue the discussions in #151 |
This commit shortens and simplifies the prompt for PR reviews. The previous prompt was long and complex, making it difficult to adapt to meet own needs. The new prompt is more concise and focused on the most important aspects of the review.
The new prompt is divided into the following sections:
This change should improve the quality of PR reviews and make them more consistent.
This change also makes this workflow consistent with other workflows which are all concise.
Fixes #208