Skip to content

Commit ab808fd

Browse files
authored
fix: Apply suggestions_score_threshold filter to inline code suggestions in dual publishing mode
- Added score filtering to push_inline_code_suggestions - Ensured inline suggestions are properly filtered when dual publishing is enabled - High-importance suggestions appear in both table and inline; others only inline
1 parent 5ec92b3 commit ab808fd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pr_agent/tools/pr_code_suggestions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,18 @@ def _prepare_pr_code_suggestions(self, predictions: str) -> Dict:
539539
async def push_inline_code_suggestions(self, data):
540540
code_suggestions = []
541541

542-
if not data['code_suggestions']:
542+
score_threshold = max(1, int(get_settings().pr_code_suggestions.suggestions_score_threshold))
543+
filtered_suggestions = [d for d in data['code_suggestions'] if int(d.get('score', 0)) >= score_threshold]
544+
545+
if not filtered_suggestions:
543546
get_logger().info('No suggestions found to improve this PR.')
544547
if self.progress_response:
545548
return self.git_provider.edit_comment(self.progress_response,
546549
body='No suggestions found to improve this PR.')
547550
else:
548551
return self.git_provider.publish_comment('No suggestions found to improve this PR.')
549552

550-
for d in data['code_suggestions']:
553+
for d in filtered_suggestions:
551554
try:
552555
if get_settings().config.verbosity_level >= 2:
553556
get_logger().info(f"suggestion: {d}")
@@ -941,4 +944,4 @@ async def self_reflect_on_suggestions(self,
941944
except Exception as e:
942945
get_logger().info(f"Could not reflect on suggestions, error: {e}")
943946
return ""
944-
return response_reflect
947+
return response_reflect

0 commit comments

Comments
 (0)