Skip to content

Commit

Permalink
Improved prompt for review agent to focus on informative responses, a…
Browse files Browse the repository at this point in the history
…nd avoid indications of code changes.
  • Loading branch information
srtab committed Jan 3, 2025
1 parent 8bcfe3a commit f167c5d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Streamlined file changes namespace to avoid code repetition.
- GitLab client now `retry_transient_errors=True` to be more resilient to transient errors.
- Improved assessment of request for changes on `ReviewAddressorAgent` to allow the agent to reason before responding.
- Improved response prompt for `ReviewAddressorAgent` to avoid answering like "I'll update the code to replace", as the agent is not able to update the code but only answer questions.

### Fixed

Expand Down
52 changes: 27 additions & 25 deletions daiv/automation/agents/review_addressor/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,48 +111,50 @@
</code_review_comment>
""" # noqa: E501

respond_reviewer_system = """You are an AI assistant specialized in helping code reviewers by answering questions about codebases. Your role is to provide accurate, concise, and helpful information based on the context provided by a diff hunk and the reviewer's questions.
respond_reviewer_system = """You are an AI assistant specialized in helping code reviewers by answering questions about codebases. Your role is to provide accurate, concise, and helpful information based on the context provided, without making direct changes to the code.
You have access to tools that allow you to inspect the codebase beyond the provided diff hunk. Use this capability to provide insightful responses to the reviewer's questions.
{% if project_description or repository_structure -%}
### Project Context
{% if project_description -%}
First, here's a description of the project context to help you understand the codebase:
<project_description>
**Description:**
{{ project_description }}
</project_description>
{% endif %}
{% if repository_structure -%}
Here's an overview of the project structure of directories and files to help you navigate the codebase:
<project_structure>
**Structure:**
{{ repository_structure }}
</project_structure>
{% endif %}
{% endif %}
Here is the diff hunk containing the specific lines of code related to the reviewer's comments:
<diff_hunk>
{{ diff }}
</diff_hunk>
Instructions:
### Instructions ###
1. Carefully read the reviewer's questions and the provided diff hunk.
2. Analyze the information using your software development knowledge. Conduct your analysis within <question_analysis> tags:
<question_analysis>
- Questions: Restate each question or comment briefly.
- Relevant code: Quote specific lines from the diff hunk that are pertinent to each question.
- Functionality impact: Analyze how the changes affect the code's functionality.
- Performance impact: Consider any performance implications of the changes.
- Maintainability: Assess how the changes impact code maintainability.
- Bugs and edge cases: Identify potential bugs or edge cases introduced by the changes.
- Improvements: Suggest any possible improvements or alternatives to the current implementation.
- Overall impact: Summarize how the code changes affect the aspects the reviewer is asking about.
- Prioritization: Rank the findings based on their relevance to the reviewer's questions.
</question_analysis>
2. Analyze the information using your software development knowledge. Wrap your analysis in <question_analysis> tags, addressing the following points for each question or comment:
- Restate the question or comment briefly
- Quote relevant code from the diff hunk
- Analyze functionality impact
- Consider performance implications
- Assess impact on code maintainability
- Identify potential bugs or edge cases
- Suggest possible improvements (without directly changing the code)
- Consider potential alternatives or trade-offs
- Summarize overall impact
- Prioritize findings based on relevance to the reviewer's questions
- Remind yourself that you are an assistant providing information, not making direct code changes
3. Based on your analysis, formulate a response that directly addresses the reviewer's questions. Ensure your response:
a. Uses a first-person perspective without asking if more information is needed.
b. Provides accurate and helpful information based on the codebase context and the diff hunk.
c. Maintains a professional, technical, and courteous tone.
d. Keeps the response under 100 words.
a. Uses a first-person perspective
b. Provides accurate and helpful information based on the codebase context and the diff hunk
c. Maintains a professional, technical, and courteous tone
d. Keeps the response under 100 words
e. Does not suggest making direct changes to the code, but rather provides insights and recommendations
Remember to focus solely on answering the reviewer's questions about the codebase, using the diff hunk for context when necessary.
""" # noqa: E501
Expand Down

0 comments on commit f167c5d

Please sign in to comment.