8000 Improve/describe tool documentation and make add_diagram feature opt-in by default by ssunbear · Pull Request #1824 · qodo-ai/pr-agent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve/describe tool documentation and make add_diagram feature opt-in by default #1824

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

Merged
merged 18 commits into from
May 25, 2025

Conversation

ssunbear
Copy link
Contributor
@ssunbear ssunbear commented May 25, 2025

User description

Summary

This PR addresses qodo-ai/pr-agent#1754.
It improves the /describe tool documentation and modifies the add_diagram behavior to be opt-in (disabled by default), aligning with feature-based PR conventions and ensuring non-disruptive integration into existing workflows.


Changes

  • Reordered the documentation for the /describe tool:
    • Moved the core functionality description to the top for better clarity and readability.
    • Placed optional features and flags (e.g., add_diagram) below the main description.
  • Changed the default value of the add_diagram option to false in configuration.toml, requiring explicit activation.
  • Cleaned up string quoting style for consistency across the codebase.

Design Considerations

  • Why the documentation was reordered
    The main purpose of the /describe tool should be immediately clear to users. Placing the primary functionality explanation at the top helps users understand its intent before diving into optional features.

  • Why add_diagram defaults to false
    Since this PR introduces a new feature, we intentionally disabled it by default to prevent unexpected side effects in existing workflows. This aligns with cautious rollout practices and avoids breaking changes for existing users.

    We believe users should first be informed about new features through documentation and enable them explicitly. Once the feature matures and gains confidence through maintainer feedback, its default value can be reconsidered.


PR Type

Enhancement, Documentation


Description

  • Add add_diagram config flag for sequence diagrams

  • Read add_diagram in pr_agent/tools/pr_description.py

  • Document Mermaid diagram support in describe.md

  • Update prompts to conditionally include diagram output


Changes diagram

sequenceDiagram
  participant U as User
  participant P as PRAgent
  U->>P: /describe command
  P->>P: load config (`add_diagram`)
  alt add_diagram = true
    P->>P: append Mermaid sequence diagram
  else
    P->>U: return text summary only
  end
Loading

Changes walkthrough 📝

Relevant files
Configuration changes
pr_description.py
Read `add_diagram` flag in PR description                               

pr_agent/tools/pr_description.py

  • Imported add_diagram from settings config
  • Added "add_diagram" key to prompt arguments
  • +2/-1     
    configuration.toml
    Add `add_diagram` default configuration                                   

    pr_agent/settings/configuration.toml

  • Introduced add_diagram = false default
  • Placed under [pr_description] section
  • +1/-0     
    Documentation
    describe.md
    Document Mermaid sequence diagram option                                 

    docs/docs/tools/describe.md

  • Added "Sequence Diagram Support" section
  • Show enabling instructions for add_diagram
  • +17/-0   
    Enhancement
    pr_description_prompts.toml
    Enhance prompts for optional sequence diagram                       

    pr_agent/settings/pr_description_prompts.toml

  • Extended PRDescription description with conditional diagram text
  • Added Mermaid sequenceDiagram template block
  • +17/-1   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    1754 - PR Code Verified

    Compliant requirements:

    • Add a Sequence Diagram feature to PR summaries
    • Generate diagrams in Mermaid format based on detected function calls
    • Make it available as an optional section in PR descriptions

    Requires further human verification:

    • Help reviewers visualize the flow of changes between components
    • Reduce cognitive load for reviewers by visualizing interactions
    • Support complex backend changes, asynchronous logic, and microservice architectures

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

    Diagram Implementation

    The diagram implementation relies on the LLM to generate the sequence diagram without specific guidance on how to analyze the code to identify actual function calls and component interactions. This may result in generic or inaccurate diagrams that don't reflect the actual code changes.

    diagram: |
      sequenceDiagram
      participant A as ComponentA
      participant B as ComponentB
      A->>B: functionCall()
      B-->>A: response
    {%- endif %}

    Copy link
    Contributor
    qodo-merge-for-open-source bot commented May 25, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Missing schema field
    Suggestion Impact:The commit implemented a similar solution by adding a 'changes_diagram' field to the PRDescription model, but with a different approach. Instead of using the conditional 'add_diagram', it uses 'enable_pr_diagram' and renamed the field to 'changes_diagram' rather than 'diagram'.

    code diff:

    +{%- endif %}
    +{%- if enable_pr_diagram %}
    +    changes_diagram: str = Field(description="a horizontal diagram that represents the main PR changes, in the format of a mermaid flowchart. The diagram should be concise and easy to read. Leave empty if no diagram is relevant.")
     {%- endif %}

    The prompt template adds diagram instructions but the output schema doesn't
    include a field for the diagram. Add a dedicated diagram field to the
    PRDescription model to properly capture the Mermaid diagram when add_diagram is
    true.

    pr_agent/settings/pr_description_prompts.toml [47]

     description: str = Field(description="summarize the PR changes in up to four bullet points, each up to 8 words. For large PRs, add sub-bullets if needed. Order bullets by importance, with each bullet highlighting a key change group. {% if add_diagram %} Also, generate a Mermaid sequence diagram that focuses on the main function call flow between classes or components. {% endif %}")
    +{% if add_diagram %}diagram: str = Field(description="a Mermaid sequence diagram that visualizes the main function call flow between classes or components"){% endif %}

    [Suggestion processed]

    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies that while the prompt asks for a Mermaid diagram when add_diagram is true, the output schema lacks a corresponding diagram field. Adding this field is important for capturing the diagram output, ensuring consistency between the prompt and the expected model output.

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

    @mrT23
    Copy link
    Collaborator
    mrT23 commented May 25, 2025

    Thanks for the PR @ssunbear
    I prefer that the diagram would be in a separate section, and the prompt needs adjustments.

    Please apply this:
    #1826
    to your PR.

    Also make sure the documentation is properly formatted

    toml
    [pr_description]
    add_diagram = true

    ->

    image

    @mrT23
    Copy link
    Collaborator
    mrT23 commented May 25, 2025

    PR Description updated to latest commit (113229b)

    @jihan-chillin
    Copy link
    Contributor

    @mrT23
    Thank you for your response!
    Out team made the changes as you suggested, but if it's not what you intended, please let me know and I'll roll it back immediately!

    @mrT23
    Copy link
    Collaborator
    mrT23 commented May 25, 2025

    looks good, thanks for the contribution

    @mrT23 mrT23 merged commit 946657a i 6FED nto qodo-ai:main May 25, 2025
    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.

    7 participants
    0