Skip to content
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

Add focus_only_on_problems setting for targeted code suggestions #1348

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Nov 6, 2024

PR Type

enhancement, configuration changes


Description

  • Introduced a new setting focus_only_on_problems to allow targeted code suggestions focusing on critical issues.
  • Updated the configuration to include focus_only_on_problems and increased max_context_tokens to 16000.
  • Enhanced the suggestion generation logic to adjust labels and guidelines based on the new setting.

Changes walkthrough 📝

Relevant files
Enhancement
pr_code_suggestions.py
Introduce focus-only-on-problems setting and label adjustment

pr_agent/tools/pr_code_suggestions.py

  • Added focus_only_on_problems setting to filter suggestions.
  • Modified suggestion logic to change labels to 'possible issue' for
    critical labels.
  • +6/-0     
    pr_code_suggestions_prompts.toml
    Conditional prompt logic for focused problem suggestions 

    pr_agent/settings/pr_code_suggestions_prompts.toml

  • Added conditional logic for focus_only_on_problems in prompts.
  • Adjusted guidelines for suggestion generation based on focus setting.
  • +17/-2   
    Configuration changes
    configuration.toml
    Update configuration with focus setting and token limit   

    pr_agent/settings/configuration.toml

  • Increased max_context_tokens from 14000 to 16000.
  • Added focus_only_on_problems setting with default false.
  • +2/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 92
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Change
    The new focus_only_on_problems setting changes the behavior of suggestion generation. Ensure this doesn't negatively impact existing functionality.

    Prompt Modification
    The system prompt now includes conditional logic based on the focus_only_on_problems setting. Verify that this change produces the desired output in both cases.

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Use more specific labels for critical issues to improve categorization and prioritization

    Consider using a more specific label than 'general' for critical issues that are not
    bugs or security-related. This could help in better categorizing and prioritizing
    the suggestions.

    pr_agent/settings/pr_code_suggestions_prompts.toml [86]

    -label: str = Field(description="A single, descriptive label that best characterizes the suggestion type. Possible labels include 'security', 'critical bug', 'general'. The 'general' section should be used for suggestions that address a major issue, but are necessarily on a critical level.")
    +label: str = Field(description="A single, descriptive label that best characterizes the suggestion type. Possible labels include 'security', 'critical bug', 'critical performance', 'critical design'. Use these labels for suggestions that address major issues on a critical level.")
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: This suggestion offers a meaningful improvement in categorizing and prioritizing critical issues by introducing more specific labels. It enhances the clarity and effectiveness of the labeling system for critical problems.

    7
    Best practice
    Use constants for string literals to improve code maintainability

    Consider using a constant for the 'critical' label to improve maintainability and
    reduce the risk of typos.

    pr_agent/tools/pr_code_suggestions.py [456-458]

     CRITICAL_LABEL = 'critical'
    +POSSIBLE_ISSUE_LABEL = 'possible issue'
     if CRITICAL_LABEL in suggestion['label'].lower(): # we want the published labels to be less declarative
    -    suggestion['label'] = 'possible issue'
    +    suggestion['label'] = POSSIBLE_ISSUE_LABEL
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: The suggestion improves code maintainability by using constants for string literals, reducing the risk of typos and making future changes easier. However, the impact is moderate as it's a small-scale improvement.

    5
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    💡 Need additional feedback ? start a PR chat

    @mrT23 mrT23 merged commit 732cc18 into main Nov 7, 2024
    2 checks passed
    @mrT23 mrT23 deleted the tr/focus_only_on_problems branch November 7, 2024 07:09
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants