Skip to content

Commit ae71825

Browse files
[code_review] Improve the filtering prompt (#4827)
Co-authored-by: Suhaib Mujahid <[email protected]>
1 parent 8e49ad9 commit ae71825

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

bugbug/tools/code_review.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,21 @@ class LargeDiffError(Exception):
137137
{comments}"""
138138

139139

140-
PROMPT_TEMPLATE_FILTERING_ANALYSIS = """Please, double check the code review provided for the patch below.
141-
Just report the comments that are:
142-
- applicable for the patch;
143-
- consistent with the {target_code_consistency} source code;
144-
- focusing on reporting possible bugs, major readability regressions, or similar concerns;
145-
- filter out any descriptive comments;
146-
- filter out any praising comments.
140+
PROMPT_TEMPLATE_FILTERING_ANALYSIS = """Filter review comments to keep those that:
141+
- are consistent with the {target_code_consistency} source code;
142+
- focus on reporting possible bugs, functional regressions, issues, or similar concerns;
143+
- report readability or design concerns.
147144
148-
Do not change the contents of the comments and the report format.
149-
Adopt the template below as the report format:
150-
[
151-
{{
152-
"file": "com/br/main/Pressure.java",
153-
"code_line": 458,
154-
"comment" : "In the third code block, you are using `nsAutoStringN<256>` instead of `nsString`. This is a good change as `nsAutoStringN<256>` is more efficient for small strings. However, you should ensure that the size of `tempString` does not exceed 256 characters, as `nsAutoStringN<256>` has a fixed size."
155-
}}
156-
]
157-
Do not report any explanation about your choice. Only return a valid JSON list.
145+
Exclude comments that:
146+
- only describe the change;
147+
- restate obvious facts like renamed variables or replaced code;
148+
- include praising;
149+
- ask if changes are intentional or ask to ensure things exist.
158150
159-
Review:
160-
{review}
151+
Do not report any explanation about your choice. Only return a valid JSON list.
161152
162-
Patch:
163-
{patch}
153+
Comments:
154+
{comments}
164155
165156
As examples of not expected comments, not related to the current patch, please, check some below:
166157
- {rejected_examples}
@@ -1298,8 +1289,7 @@ def run(self, patch: Patch) -> list[InlineComment] | None:
12981289

12991290
raw_output = self.filtering_chain.invoke(
13001291
{
1301-
"review": output,
1302-
"patch": patch.raw_diff,
1292+
"comments": output,
13031293
"rejected_examples": rejected_examples,
13041294
},
13051295
return_only_outputs=True,

0 commit comments

Comments
 (0)