Skip to content

Commit 2f9fbbf

Browse files
committed
Prevent reducing the number of suggestions if already low enough
1 parent 0189e12 commit 2f9fbbf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pr_agent/tools/pr_code_suggestions.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,14 @@ async def rank_suggestions(self, data: List) -> List:
286286
data_sorted[importance_order - 1] = suggestion_list[suggestion_number - 1]
287287

288288
if get_settings().pr_code_suggestions.final_clip_factor != 1:
289-
new_len = int(0.5 + len(data_sorted) * get_settings().pr_code_suggestions.final_clip_factor)
290-
data_sorted = data_sorted[:new_len]
289+
max_len = max(
290+
len(data_sorted),
291+
get_settings().pr_code_suggestions.num_code_suggestions,
292+
get_settings().pr_code_suggestions.num_code_suggestions_per_chunk,
293+
)
294+
new_len = int(0.5 + max_len * get_settings().pr_code_suggestions.final_clip_factor)
295+
if new_len < len(data_sorted):
296+
data_sorted = data_sorted[:new_len]
291297
except Exception as e:
292298
if get_settings().config.verbosity_level >= 1:
293299
get_logger().info(f"Could not sort suggestions, error: {e}")

0 commit comments

Comments
 (0)