Doramagic Project Pack Β· Human Manual
pr-agent
PR-Agent serves as an intelligent assistant that scans pull request code changes and generates automated feedback, suggestions, and descriptions. It integrates seamlessly with major versio...
Introduction to PR-Agent
Related topics: Quick Start Guide, System Architecture, Tools Overview
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: Quick Start Guide, System Architecture, Tools Overview
Introduction to PR-Agent
PR-Agent is an open-source, AI-powered code review agent that provides automated analysis and feedback on pull requests. Originally developed by Qodo, the project was donated to the open-source community, making it a community-maintained legacy project distinct from Qodo's primary AI code review offering.
Overview
PR-Agent serves as an intelligent assistant that scans pull request code changes and generates automated feedback, suggestions, and descriptions. It integrates seamlessly with major version control platforms including GitHub, GitLab, Bitbucket, and Azure DevOps.
The project provides a comprehensive suite of tools that can be triggered automatically on PR events (such as when a PR is opened or synchronized) or invoked manually through comments on pull requests. Each tool focuses on a specific aspect of the PR review process.
Architecture
PR-Agent follows a modular architecture where each tool operates as an independent component. The core system consists of:
- Agent Core - The main orchestration layer that processes incoming requests and routes them to appropriate tools
- Git Provider Integration - Abstraction layer for different VCS platforms
- Tool Suite - Individual tools for description, review, improvement, and other operations
- Configuration System - TOML-based configuration with environment variable support
Component Flow
graph TD
A[Pull Request Event] --> B[Git Provider]
B --> C[Agent Core]
C --> D[Tool Router]
D --> E[/describe]
D --> F[/review]
D --> G[/improve]
D --> H[/ask]
E --> I[AI Model]
F --> I
G --> I
H --> I
I --> J[PR Comment/Update]Available Tools
PR-Agent provides multiple tools that can be invoked via slash commands in PR comments.
Describe Tool
The /describe tool scans PR code changes and generates a comprehensive description including:
- Title - Auto-generated PR title in the format
<PR type>: <title> - Type - Classification such as Bug fix, Tests, Enhancement, Documentation, or Other
- Summary - Brief overview of changes
- Walkthrough - File-by-file breakdown of modifications
- Labels - Auto-assigned labels based on content
Sources: pr_agent/servers/help.py:1-50
Review Tool
The /review tool performs detailed code analysis and provides:
- Code quality assessment - Evaluation of code structure and patterns
- Security analysis - Potential vulnerability detection
- Performance considerations - Optimization suggestions
- Recommended focus areas - Specific files or lines requiring attention
Sources: pr_agent/servers/help.py:1-100
Improve Tool (Code Suggestions)
The /improve tool automatically generates code improvement suggestions:
- Category classification - Each suggestion is labeled and categorized
- Impact scoring - Suggestions are scored by potential improvement impact
- Code examples - Before/after code comparisons when relevant
- Automatic sorting - Suggestions ordered by score within categories
Sources: pr_agent/tools/pr_code_suggestions.py:1-80
Ask Tool
The /ask tool answers natural language questions about the PR:
- Queries about the entire PR scope
- Specific questions about code lines or files
- Image-related questions when visual content is present
Note that the tool does not retain memory between questionsβeach query is answered independently.
Sources: pr_agent/servers/help.py:1-150
Help Docs Tool
The /help_docs tool retrieves documentation based on relative file paths, supporting both repository-local documentation and external sources.
Output Format
PR-Agent generates output using GitHub Flavored Markdown (GFM) with enhanced formatting:
graph LR
A[Code Analysis] --> B[GFM Table Format]
B --> C[Collapsible Sections]
C --> D[Code Blocks]
D --> E[Links & References]Markdown Table Structure
PR-Agent uses structured HTML tables within Markdown for organized output:
<table>
<thead>
<tr>
<td><strong>Category</strong></td>
<td><strong>Suggestion</strong></td>
<td><strong>Impact</strong></td>
</tr>
</thead>
<tbody>
<!-- Content rows -->
</tbody>
</table>
Sources: pr_agent/algo/utils.py:1-100
Configuration
PR-Agent uses a TOML-based configuration system with multiple configuration levels.
Configuration Sections
| Section | Purpose | Key Settings |
|---|---|---|
pr_description | Describe tool behavior | enable_help_comment, use_description_markers, output_relevant_configurations |
pr_reviewer | Review tool behavior | Various review-specific options |
pr_code_suggestions | Improve tool behavior | Suggestion filtering and scoring |
config | Global settings | output_relevant_configurations |
Sources: pr_agent/tools/pr_config.py:1-50
Configuration Methods
Command-line invocation:
/describe --pr_description.some_config1=... --pr_description.some_config2=...
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
Configuration file (TOML):
[pr_description]
some_config1=...
some_config2=...
[pr_code_suggestions]
some_config1=...
Sources: pr_agent/servers/help.py:1-200
Custom Labels
The describe tool supports custom labels defined in the repository's labels page or via configuration file. Examples:
| Custom Label | Description |
|---|---|
Main topic:performance | PR focuses on performance optimization |
New endpoint | New API endpoint added |
SQL query | Database query changes |
Dockerfile changes | Container configuration updates |
Installation and Deployment
Docker Installation
Docker images are published to pragent/pr-agent. Recent releases (0.34.2+) are available at the new namespace. Legacy images up to v0.31 remain at codiumai/pr-agent.
Sources: README.md:1-100
GitHub Action (Recommended)
name: PR Agent
on:
pull_request:
types: [opened, synchronize]
jobs:
pr_agent_job:
runs-on: ubuntu-latest
steps:
- name: PR Agent action step
uses: the-pr-agent/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLI Usage
pip install pr-agent
export OPENAI_KEY=your_key_here
pr-agent --pr_url https://github.com/owner/repo/pull/123 review
Automation Modes
PR-Agent supports multiple automation configurations:
- Automatic on PR events - Tools run automatically when PR is opened or updated
- Manual invocation - Users trigger tools via slash commands in comments
- Marker-based control - Using
pr_agent:marker_namemarkers for selective updates
The default automation mode for the describe tool uses:
pr_commands = ["/describe", ...]
Sources: pr_agent/servers/help.py:1-250
Development Guidelines
Contributors should follow these practices:
- Use conventional commit messages (e.g.,
fix: handle missing repo settings gracefully) - Target branch names follow
feature/<name>orfix/<issue>patterns - Keep PRs focused on single features or fixes
- Include unit tests for new functionality using pytest
- Update prompts and configuration files together when behavior changes
Sources: CONTRIBUTING.md:1-80
Security Considerations
- Secrets must be supplied through environment variables, not hardcoded
- API keys and credentials should never be committed to the repository
- Docker builds and e2e tests requiring external credentials need coordination before execution
Sources: pr_agent/servers/help.py:1-50
Quick Start Guide
Related topics: Introduction to PR-Agent
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: Introduction to PR-Agent
Quick Start Guide
Overview
The Quick Start Guide provides developers with immediate access to automated PR review capabilities through PR-Agent. This guide covers installation methods, configuration options, and basic usage patterns to get started with AI-powered code review in minutes.
PR-Agent is an open-source, AI-powered code review agent that integrates seamlessly with GitHub, GitLab, Bitbucket, and Azure DevOps. It offers automated reviews, descriptions, code suggestions, and more without requiring complex setup.
Installation Methods
PR-Agent supports multiple installation methods to accommodate different development workflows and infrastructure requirements.
GitHub Action (Recommended)
The GitHub Action method is the recommended approach for automated PR reviews. It runs as part of your CI/CD pipeline and automatically reviews pull requests when they are opened or updated.
# .github/workflows/pr-agent.yml
name: PR Agent
on:
pull_request:
types: [opened, synchronize]
jobs:
pr_agent_job:
runs-on: ubuntu-latest
steps:
- name: PR Agent action step
uses: the-pr-agent/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sources: README.md:1-25
| Parameter | Type | Required | Description |
|---|---|---|---|
OPENAI_KEY | secret | Yes | OpenAI API key for AI capabilities |
GITHUB_TOKEN | secret | Yes | GitHub token for API access |
GITLAB_TOKEN | secret | No | Required for GitLab integration |
AZURE_DEVOPS_TOKEN | secret | No | Required for Azure DevOps integration |
CLI Usage (Local Development)
For local development and testing, use the Command Line Interface:
pip install pr-agent
export OPENAI_KEY=your_key_here
pr-agent --pr_url https://github.com/owner/repo/pull/123 review
Sources: README.md:31-37
| Command | Description |
|---|---|
pr-agent --pr_url <URL> review | Run a review on a PR |
pr-agent --pr_url <URL> describe | Generate PR description |
pr-agent --pr_url <URL> improve | Get code improvement suggestions |
pr-agent --pr_url <URL> ask "<question>" | Ask questions about the PR |
Docker Deployment
Docker images are available for containerized deployments:
| Image Tag | Description | Registry |
|---|---|---|
pragent/pr-agent:0.34.2+ | Current releases | hub.docker.com |
pragent/pr-agent:latest | Latest stable | hub.docker.com |
pragent/pr-agent:0.34.2-github_action | GitHub Action variant | hub.docker.com |
codiumai/pr-agent:v0.31 | Legacy (frozen) | hub.docker.com |
ηζ¬ 0.34.2 εδΉεεεΈε¨ pragent/pr-agent ε½εη©Ίι΄οΌζ§ηζ¬οΌη΄ε° v0.31οΌδ»ε―ε¨ codiumai/pr-agent θ·εδ½δΈδΌεζ΄ζ°γ
Sources: README.md:1-8
For enhanced security, specify Docker images using their digest:
steps:
- name: PR Agent action step
id: pragent
uses: docker://pragent/pr-agent@sha256:a0b36966ca3a197ca739fa1e65c16703076fc1c744cd423ca203b8c21707d71c
Sources: SECURITY.md:1-12
Architecture Overview
graph TD
A[Pull Request Event] --> B[GitHub/GitLab/Bitbucket/Azure DevOps]
B --> C[PR-Agent Trigger]
C --> D{Installation Method}
D -->|GitHub Action| E[GitHub Actions Runner]
D -->|CLI| F[Local Environment]
D -->|Docker| G[Container Runtime]
E --> H[OpenAI API / LLM]
F --> H
G --> H
H --> I[Review Output]
I --> J[PR Comment]Configuration System
PR-Agent uses a flexible configuration system that supports multiple levels of customization.
Configuration Hierarchy
| Level | Location | Scope | Priority |
|---|---|---|---|
| 1 | Environment Variables | Global | Highest |
| 2 | Configuration File | Project | Medium |
| 3 | Inline Command Flags | Per-invocation | Lowest |
Configuration File Format
Create a .pr_agent.toml or use pr_agent/settings/configuration.toml:
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
"""
Sources: pr_agent/servers/help.py:1-15
Inline Configuration via Comments
When commenting on a PR, use the following template to modify configurations:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
Sources: pr_agent/servers/help.py:1-10
Available Commands
PR-Agent provides several commands that can be invoked via PR comments:
Command Reference Table
| Command | Purpose | Auto-trigger | Manual Trigger |
|---|---|---|---|
/describe | Generate PR description | β | β |
/review | Perform code review | β | β |
/improve | Suggest code improvements | β | β |
/ask "..." | Answer questions about PR | β | β |
/help_docs "..." | Query documentation | β | β |
/config | Show configuration | β | β |
Command Usage Examples
Sources: pr_agent/servers/help.py:1-50
#### Describe Command
/describe --pr_description.some_config1=value
Generates a PR description including title, type, summary, walkthrough, and labels.
#### Review Command
/review --pr_reviewer.some_config1=value --pr_reviewer.some_config2=value
Performs an automated code review with configurable focus areas.
#### Improve Command
/improve --pr_code_suggestions.some_config1=value
Scans PR code changes and generates improvement suggestions.
#### Ask Command
/ask "What are the main changes in this PR?"
Answers questions about the PR without memory of previous interactions.
Security Best Practices
Environment Variables
Secrets should be supplied through environment variables exclusively:
export OPENAI_KEY=sk-...
export GITHUB_TOKEN=ghp_...
Do not persist credentials in code or configuration files that might be committed to version control.
Sources: AGENTS.md:1-10
Docker Security
For production deployments, use pinned Docker image digests instead of floating tags:
uses: docker://pragent/pr-agent@sha256:<digest>
Sources: SECURITY.md:1-12
Output Format
PR-Agent generates formatted markdown output for PR comments with support for GitHub Flavored Markdown (GFM).
Output Structure
graph LR
A[Review Output] --> B{GFM Supported?}
B -->|Yes| C[Rich Tables & Details]
B -->|No| D[Plain Markdown]
C --> E[Collapsible Sections]
D --> F[Basic Formatting]Example Output Features
| Collapsible details | β `
| Feature | GFM Support | Fallback |
|---|---|---|
| Code blocks | β Syntax highlighting | β Basic blocks |
| Tables | β Rich formatting | β Text list |
System Architecture
Overview
PR-Agent is an open-source AI-powered code review agent that provides automated PR analysis, review, and improvement suggestions. The system follows a modular architecture that separates concerns between agent orchestration, tool execution, git provider abstraction, and utility functions.
The primary goal of PR-Agent's architecture is to support multiple Git hosting platforms (GitHub, GitLab, Bitbucket, Azure DevOps) while providing consistent tooling for PR-related operations like description generation, code review, code suggestions, and documentation assistance.
Sources: README.md
Sources: README.md:1-25
Command-to-Tool Mapping
Related topics: System Architecture, Tools Overview
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: System Architecture, Tools Overview
Command-to-Tool Mapping
Overview
The Command-to-Tool Mapping system in PR-Agent is the core routing mechanism that translates user-issued commands (such as /review, /describe, /improve) into corresponding tool invocations. This mapping enables the framework to dispatch requests to appropriate specialized tools while managing configuration, argument parsing, and execution flow.
The system serves as the entry point for all user interactions, whether they occur via GitHub/GitLab comments, CLI execution, or programmatic API calls.
Architecture
graph TD
A[User Command] --> B[CLI / Comment Handler]
B --> C[Command Parser]
C --> D[Argument Extraction]
D --> E[Tool Router]
E --> F{Command Type}
F -->|/describe| G[pr_description.py]
F -->|/review| H[pr_reviewer.py]
F -->|/improve| I[pr_code_suggestions.py]
F -->|/ask| J[pr_ask.py]
F -->|/help| K[help.py]
G --> L[Git Provider]
H --> L
I --> L
J --> L
K --> M[Documentation]Core Components
Command Registry
The command registry maps slash commands to their corresponding tool implementations. Based on the help system and tool definitions, the following commands are registered:
| Command | Tool Module | Purpose |
|---|---|---|
/describe | pr_description.py | Generate PR description, title, type, summary, walkthrough |
/review | pr_reviewer.py | Perform automated code review |
/improve | pr_code_suggestions.py | Generate code improvement suggestions |
/ask | pr_ask.py | Answer questions about PR changes |
/help_docs | help_docs.py | Query repository documentation |
Sources: pr_agent/servers/help.py:1-50
Argument Parsing
The cli_args.py module handles command-line argument parsing and configuration overrides. Commands can accept configuration parameters in two formats:
Inline Configuration (GitHub Comment):
/describe --pr_description.some_config1=value1 --pr_description.some_config2=value2
Configuration File Format:
[pr_description]
some_config1=value1
some_config2=value2
Sources: pr_agent/servers/help.py:30-45
Command Handlers
Describe Command
The /describe command triggers automatic PR description generation.
@staticmethod
def get_describe_usage_guide():
output = "**Overview:**\n"
output += "The `describe` tool scans the PR code changes, and generates a description for the PR"
Configuration Section: pr_description
Key Parameters:
enable_help_comment- Show help links in PR bodyuse_description_markers- Use markers in PR description for selective updatesoutput_relevant_configurations- Display relevant config settings
Sources: pr_agent/tools/pr_description.py:1-30
Review Command
The /review command initiates automated code review.
# Configuration template from help message
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
Configuration Section: pr_reviewer
Sources: pr_agent/servers/help.py:50-70
Improve Command
The /improve command generates code improvement suggestions.
@staticmethod
def get_improve_usage_guide():
output = "**Overview:**\n"
output += "The code suggestions tool, named `improve`, scans the PR code changes..."
Configuration Section: pr_code_suggestions
Key Features:
- Automatic triggering on PR open
- Manual invocation via comment
- Configurable suggestion categories and scoring
Sources: pr_agent/servers/help.py:50-100
Ask Command
The /ask command answers questions about the PR without maintaining conversation state.
/ask "What changes were made to the authentication module?"
@staticmethod
def get_ask_usage_guide():
output += """\
The `ask` tool answers questions about the PR, based on the PR code changes.
Note that the tool does not have "memory" of previous questions,
and answers each question independently.
You can ask questions about the entire PR, about specific code lines,
or about an image related to the PR code changes.
Sources: pr_agent/servers/help.py:80-95
Help Docs Command
The /help_docs command queries repository documentation.
@staticmethod
def get_help_docs_usage_guide():
output = "**Overview:**\n"
output += """\
The help docs tool, named `help_docs`, answers a question based on
a given relative path of documentation."""
Sources: pr_agent/servers/help.py:130-145
Execution Flow
sequenceDiagram
participant User
participant CLI as Command Line
participant Parser as Argument Parser
participant Router as Tool Router
participant Tool as Selected Tool
participant Provider as Git Provider
User->>CLI: /command --config=value
CLI->>Parser: Parse arguments
Parser->>Router: Route to tool
Router->>Tool: Instantiate tool class
Tool->>Provider: Fetch PR data
Provider-->>Tool: Diff files, comments
Tool->>Tool: Process and analyze
Tool->>Provider: Post results
Provider-->>User: PR comment/responseConfiguration Integration
Configuration Precedence
The system follows a hierarchical configuration resolution:
- Default values - Defined in tool settings
- Configuration file - User-defined settings in
.pr_agent.tomlorsettings/configuration.toml - Command arguments - Inline overrides from command invocation
- Environment variables - System-level settings
Relevant Configurations Output
When enabled, the system can output relevant configuration settings in the PR response:
if get_settings().get('config', {}).get('output_relevant_configurations', False):
pr_body += show_relevant_configurations(relevant_section='pr_description')
Sources: pr_agent/tools/pr_description.py:25-27
CLI Integration
The CLI module (cli.py) provides command-line access to all tools:
# Local repository CLI usage
pr-agent --pr_url https://github.com/owner/repo/pull/123 review
# Help text
pr-agent --help
The CLI maps the --pr_url parameter and selected command to the appropriate tool implementation.
Sources: README.md:30-40
Tool Output Formatting
The utility module (algo/utils.py) provides shared formatting functions used across all tools:
| Function | Purpose |
|---|---|
parse_code_suggestion() | Convert code suggestions to markdown |
extract_relevant_lines_str() | Extract relevant code lines from diff |
render_issue() | Format review findings as markdown |
Sources: pr_agent/algo/utils.py:50-150
Summary
The Command-to-Tool Mapping system provides:
- Unified Interface: Single entry point for all user interactions
- Flexible Configuration: Per-command and global configuration options
- Extensible Architecture: Easy addition of new commands and tools
- Consistent Output: Standardized markdown formatting across tools
- Multi-Platform Support: Works with GitHub, GitLab, Bitbucket, and Azure DevOps
This architecture enables PR-Agent to maintain a clean separation between command handling, tool implementation, and output rendering, facilitating maintainability and extensibility.
Sources: pr_agent/servers/help.py:1-50
Tools Overview
Related topics: /describe Tool, /review Tool, /improve Tool, Additional Tools
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: /describe Tool, /review Tool, /improve Tool, Additional Tools
Tools Overview
PR-Agent provides a comprehensive suite of AI-powered tools for automated pull request analysis, review, and enhancement. These tools are designed to streamline the code review process by automating routine tasks and providing intelligent suggestions.
Architecture Overview
The tools system in PR-Agent follows a modular architecture where each tool is responsible for a specific aspect of PR management. Tools can be invoked automatically (on PR events) or manually via slash commands in PR comments.
graph TD
A[GitHub/GitLab/Bitbucket Event] --> B[PR Agent Core]
B --> C[Tool Router]
C --> D[/describe]
C --> E[/review]
C --> F[/improve]
C --> G[/ask]
C --> H[/help_docs]
D --> I[pr_description.py]
E --> J[pr_reviewer.py]
F --> K[pr_code_suggestions.py]
G --> L[pr_questions.py]
H --> M[Help System]
I --> N[Markdown Output]
J --> N
K --> N
L --> N
M --> NAvailable Tools
PR-Agent includes five core tools, each designed for specific PR workflow tasks:
| Tool | Purpose | Invocation |
|---|---|---|
/describe | Generates PR description (title, type, summary, walkthrough, labels) | Automatic or manual |
/review | Performs comprehensive code review with issue detection | Automatic or manual |
/improve | Provides code improvement suggestions | Automatic or manual |
/ask | Answers questions about the PR code changes | Manual only |
/help_docs | Retrieves documentation based on repository files | Manual only |
Sources: pr_agent/servers/help.py:1-50
Tool Invocation Patterns
Slash Command Invocation
Tools can be triggered by commenting directly on a PR using slash commands:
/describe --pr_description.some_config1=... --pr_description.some_config2=...
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
/ask "Your question here"
/help_docs "path/to/documentation"
Sources: pr_agent/servers/help.py:8-25
Configuration File Invocation
For persistent configuration, tools can be configured via a configuration file:
[pr_description]
some_config1=...
some_config2=...
[pr_reviewer]
some_config1=...
some_config2=...
[pr_code_suggestions]
some_config1=...
some_config2=...
Describe Tool
The describe tool scans PR code changes and generates a comprehensive description including:
- Title: Short, concise PR title (up to 10 words)
- Type: PR classification (Bug fix, Enhancement, Documentation, etc.)
- Summary: Brief overview of changes
- Walkthrough: File-by-file change explanation
- Labels: Relevant labels for the PR
Description Markers
When use_description_markers is enabled, the tool replaces markers in the PR description:
pr_agent:type
pr_agent:summary
pr_agent:walkthrough
pr_agent:diagram
Sources: pr_agent/servers/help.py:85-105
Custom Labels
The describe tool supports custom labels defined in the repository's labels page or configuration:
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
"""
Supported custom label formats:
Main topic:performance- Marks performance-related PRsNew endpoint- Indicates new API endpointsSQL query- Flags SQL changesDockerfile changes- Identifies container changes
Review Tool
The /review tool performs comprehensive code review by analyzing:
- Code quality issues
- Security vulnerabilities
- Performance concerns
- Test coverage gaps
- Documentation completeness
Review Focus Areas
The review tool generates a table of recommended focus areas with links to relevant code sections:
# From pr_description.py - Focus areas structure
if gfm_supported:
issue_str = f""
Improve Tool (Code Suggestions)
The improve tool generates actionable code improvement suggestions, organized by category and impact score.
Suggestion Output Structure
graph TD
A[Code Suggestions] --> B[Group by Label]
B --> C[Sort by Score]
C --> D[Category Column]
C --> E[Suggestion Column]
C --> F[Impact Column]Suggestion Table Format
The tool outputs suggestions in a structured table format:
<table>
<thead>
<tr>
<td><strong>Category</strong></td>
<td align=left><strong>Suggestion</strong></td>
<td align=center><strong>Impact</strong></td>
</tr>
</thead>
<tbody>
Sources: pr_agent/tools/pr_code_suggestions.py:30-45
Suggestion Processing
Suggestions are processed through the following pipeline:
- Label Grouping: Suggestions are grouped by their category labels
- Score Sorting: Groups and suggestions within are sorted by score (descending)
- Markdown Formatting: Suggestions are formatted using GitHub Flavored Markdown
# Group suggestions by label
suggestions_labels = dict()
for suggestion in data['code_suggestions']:
label = suggestion['label'].strip().strip("'").strip('"')
if label not in suggestions_labels:
suggestions_labels[label] = []
suggestions_labels[label].append(suggestion)
# Sort by highest score
suggestions_labels = dict(
sorted(suggestions_labels.items(),
key=lambda x: max([s['score'] for s in x[1]]),
reverse=True))
Sources: pr_agent/tools/pr_code_suggestions.py:50-70
Ask Tool
The ask tool provides conversational access to PR information:
- Answers questions about the entire PR
- Can reference specific code lines
- Processes images related to PR changes
- Independent question answering (no memory of previous questions)
/ask "What is the purpose of the new authentication module?"
/ask "Explain the changes in src/utils.py lines 50-100"
Note: Each question is answered independently without context from previous questions.
Sources: pr_agent/servers/help.py:115-130
Help Docs Tool
The help_docs tool retrieves and explains documentation based on repository files:
/help_docs "How do I configure the CI pipeline?"
This tool searches documentation within the repository or a specified external repository.
Output Formatting
GitHub Flavored Markdown Support
PR-Agent detects GFM support and adjusts output accordingly:
if gfm_supported:
markdown_text += '<table>'
# Table-based formatting with collapsible sections
else:
# Standard markdown with headers
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
Collapsible File Lists
For PRs with many changed files, the tools use collapsible sections:
Sources: pr_agent/tools/pr_description.py:100-130
Diff Statistics
File changes are displayed with diff statistics:
diff_plus_minus += f"+{num_plus_lines}/-{num_minus_lines}"
Configuration System
Per-Tool Configuration
Each tool has its own configuration section:
| Tool | Configuration Section | Location |
|---|---|---|
| Describe | pr_description | pr_agent/settings/configuration.toml |
| Review | pr_reviewer | pr_agent/settings/configuration.toml |
| Improve | pr_code_suggestions | pr_agent/settings/configuration.toml |
Configuration Output
When output_relevant_configurations is enabled, tools output relevant settings:
if get_settings().get('config', {}).get('output_relevant_configurations', False):
pr_body += show_relevant_configurations(relevant_section='pr_description')
Sources: pr_agent/tools/pr_config.py:1-30
Help Comments
Tools can optionally add help comments to PR descriptions:
if get_settings().pr_description.enable_help_comment and self.git_provider.is_supported("gfm_markdown"):
pr_body += ('\n\n___\n\n> ')
Sources: pr_agent/tools/pr_description.py:45-60
Multi-Platform Support
PR-Agent tools adapt their output based on the Git provider:
GitHub
Uses full GFM support with table formatting and collapsible sections.
GitLab
Adapted output for GitLab markdown compatibility:
else: # gitlab
pr_body += ("\n\n___\n\n")
Bitbucket
Bitbucket Server has limited multi-line suggestion support, so code suggestions use code blocks instead:
# Bitbucket does not support multi-line suggestions so use a code block instead
body = body.replace("```suggestion", "```")
Sources: pr_agent/git_providers/bitbucket_server_provider.py:150-160
Workflow Integration
Automatic Triggers
Tools can be configured to run automatically on PR events:
pr_commands = ["/describe", "/review", "/improve"]
With markers enabled:
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
Manual Invocation
For interactive use, tools are invoked via PR comments:
# Review a specific aspect
/review --pr_reviewer.extra_instructions="Focus on security issues only"
Summary
The PR-Agent tools system provides comprehensive automation for pull request workflows:
- Describe: Automatic PR documentation
- Review: Intelligent code analysis
- Improve: Actionable suggestions
- Ask: Conversational PR queries
- Help Docs: Documentation retrieval
Each tool is independently configurable, supports multiple Git providers, and can be integrated into CI/CD pipelines or used interactively.
Sources: pr_agent/servers/help.py:1-50
/describe Tool
Related topics: Tools Overview
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: Tools Overview
/describe Tool
The /describe tool is one of the core features of PR-Agent that automatically generates comprehensive descriptions for Pull Requests by analyzing code changes.
Overview
The describe tool scans PR code changes and automatically generates a structured description including:
- PR Title - Concise summary of the changes
- PR Type - Classification (Bug fix, Enhancement, Documentation, Tests, Other)
- Summary - High-level overview of modifications
- Walkthrough - File-by-file breakdown of changes
- Labels - Automatically suggested labels based on content
Sources: pr_agent/servers/help.py:1-50
Architecture
graph TD
A[PR Opened/Updated] --> B{Automation Triggered?}
B -->|Yes| C[Automatic Mode]
B -->|No| D[Manual Comment: /describe]
C --> E[PRDescriptionTool.run]
D --> E
E --> F[Analyze Diff Files]
F --> G[Generate Title & Type]
G --> H[Generate Summary]
H --> I[Generate Walkthrough Table]
I --> J[Apply Labels]
J --> K[Update PR Description]
K --> L[Optional: Add Help Comment]Usage Modes
Automatic Mode
The tool can run automatically when a PR is opened or updated, configured via GitHub App settings.
# Default automation configuration
pr_commands = ["/describe", ...]
Sources: pr_agent/servers/help.py:70-85
Manual Mode
Invoke manually by commenting on a PR:
/describe
With custom configurations:
/describe --pr_description.some_config1=... --pr_description.some_config2=...
Sources: pr_agent/servers/help.py:45-60
Marker Mode
An alternative approach using markers in the PR description:
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
Available markers:
pr_agent:type- PR typepr_agent:summary- PR summarypr_agent:walkthrough- File walkthroughpr_agent:diagram- Sequence diagram (if enabled)
Sources: pr_agent/servers/help.py:80-100
Output Structure
The generated PR description follows this structure:
| Section | Description |
|---|---|
| Title | PR type prefix + concise title (max 10 words) |
| Type | Classification of the change |
| Summary | High-level description of modifications |
| Walkthrough | Table of changed files with descriptions |
| Labels | Suggested labels for categorization |
Configuration Options
Configuration File
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
- Use bullet points for clarity
"""
Key Configuration Parameters
| Parameter | Description | Default |
|---|---|---|
enable_help_comment | Add help text to PR | true |
use_description_markers | Use markers in PR body | false |
enable_generate_title | Auto-generate title | true |
enable.type | Include PR type | true |
enable.walkthrough | Include file walkthrough | true |
enable.labels | Include labels | true |
extra_instructions | Custom instructions | "" |
Sources: pr_agent/servers/help.py:46-55
Walkthrough Table Format
The file walkthrough is rendered as a markdown table with collapsible sections:
| Theme | Files Changed |
|-------|---------------|
| **Core Logic** |
This is displayed conditionally based on:
enable_help_commentsetting- Git provider support for GFM markdown
- Provider type (GitHub vs GitLab)
Sources: pr_agent/tools/pr_description.py:25-45
Implementation Flow
sequenceDiagram
participant User
participant GitProvider
participant PRDescriptionTool
participant Model
User->>GitProvider: Opens PR
GitProvider->>PRDescriptionTool: Trigger /describe
PRDescriptionTool->>GitProvider: Get diff files
GitProvider-->>PRDescriptionTool: Return diff
PRDescriptionTool->>Model: Request description
Model-->>PRDescriptionTool: Generated content
PRDescriptionTool->>PRDescriptionTool: Format markdown
PRDescriptionTool->>GitProvider: Update PR description
alt enable_help_comment
PRDescriptionTool->>GitProvider: Add help comment
endCode Suggestion Integration
The describe tool works alongside the improve tool for code suggestions:
# From pr_description.py
if get_settings().get('config', {}).get('output_relevant_configurations', False):
pr_body += show_relevant_configurations(relevant_section='pr_description')
Sources: pr_agent/tools/pr_description.py:50-52
Relevant Configuration Display
When output_relevant_configurations is enabled, relevant settings are included in the output:
[pr_description]
some_config1=...
some_config2=...
Sources: pr_agent/tools/pr_config.py:1-20
Related Commands
| Command | Purpose |
|---|---|
/review | Analyze PR code and provide feedback |
/improve | Generate code improvement suggestions |
/ask | Answer questions about the PR |
/help_docs | Answer questions from documentation |
Best Practices
- Custom Labels: Define labels relevant to your repository's domain
- Extra Instructions: Use
extra_instructionsfor project-specific formatting rules - Markers: Use markers for incremental updates to PR descriptions
- Automation: Enable automatic triggering for consistent documentation
Sources: AGENTS.md:1-30
Summary
The /describe tool is a powerful feature that transforms raw code changes into human-readable PR descriptions. It supports multiple invocation modes, customizable output formats, and integrates seamlessly with GitHub's workflow automation capabilities.
Sources: pr_agent/servers/help.py:1-50
/review Tool
Related topics: Tools Overview
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: Tools Overview
/review Tool
Overview
The /review tool is a core component of PR-Agent that performs automated code review of pull requests. It scans PR code changes and provides a comprehensive analysis including code quality assessment, potential bugs, security issues, testing gaps, and improvement suggestions.
The tool can be triggered automatically when a new PR is opened, or invoked manually by commenting on a PR with the /review command.
Architecture
graph TD
A[User Trigger: /review] --> B[Git Provider Integration]
B --> C[Diff Files Extraction]
C --> D[PR Reviewer Engine]
D --> E[LLM Analysis]
E --> F[Review Output Generation]
F --> G[Publish to PR Comments]
H[Configuration] --> D
I[Prompt Templates] --> EInvocation Methods
Manual Invocation
To invoke the review tool manually, comment on a PR with:
/review
To customize behavior, pass configuration parameters:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
Configuration File
Alternatively, configure via a configuration file:
[pr_reviewer]
some_config1=...
some_config2=...
Configuration Options
The pr_reviewer section in configuration.toml controls the review tool behavior:
| Parameter | Description | Default |
|---|---|---|
enable_help_text | Show help text in review output | true |
enable_load_files | Load file contents for deeper analysis | false |
enable_intro | Show introduction section | true |
enable_final_comment | Add final summary comment | true |
enable_review_status | Track review completion status | false |
Sources: pr_agent/servers/help.py:1-30
Review Output Structure
The review output is generated in markdown format with collapsible sections. The output follows this structure:
## PR Review Summary
[Overview of changes]
### Code Quality Assessment
[Analysis of code structure and patterns]
### Potential Issues
[List of identified problems]
### Suggestions
[Improvement recommendations]
### Security Considerations
[Security-relevant findings]
Integration with Code Suggestions
The review tool leverages the code suggestions subsystem to provide actionable improvement recommendations:
# From pr_code_suggestions.py
suggestions_labels = dict()
for suggestion in data['code_suggestions']:
label = suggestion['label'].strip()
if label not in suggestions_labels:
suggestions_labels[label] = []
suggestions_labels[label].append(suggestion)
Sources: pr_agent/tools/pr_code_suggestions.py:50-60
Code Suggestion Display Format
When GFM (GitHub Flavored Markdown) is supported, suggestions are displayed in a structured table:
<table>
<thead>
<tr>
<td><strong>Category</strong></td>
<td align=left><strong>Suggestion</strong></td>
<td align=center><strong>Impact</strong></td>
</tr>
</thead>
<tbody>
<!-- Suggestions rendered here -->
</tbody>
</table>
Sources: pr_agent/tools/pr_code_suggestions.py:40-50
Markdown Rendering Utilities
The tool uses utility functions to convert suggestion dictionaries to markdown:
def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str:
"""
Convert a dictionary of data into markdown format.
"""
markdown_text = ""
if gfm_supported and 'relevant_line' in code_suggestion:
markdown_text += '<table>'
# ... table rendering logic
markdown_text += "</table>\n"
return markdown_text
Sources: pr_agent/algo/utils.py:100-120
Git Provider Integration
The review output can be published to different Git platforms. The publish_code_suggestions method in bitbucket_server_provider.py demonstrates platform-specific handling:
if relevant_lines_end > relevant_lines_start:
# Bitbucket does not support multi-line suggestions
body = body.replace("```suggestion", "```")
post_parameters = {
"body": body,
"path": relevant_file,
"line": relevant_lines_end,
# ...
}
Sources: pr_agent/git_providers/bitbucket_server_provider.py:1-30
Configuration Output
The tool can output relevant configurations in the review comment when enabled:
def show_relevant_configurations(relevant_section='pr_description') -> str:
# Returns formatted markdown of configuration settings
Sources: pr_agent/tools/pr_config.py:1-20
Workflow Diagram
sequenceDiagram
participant User
participant GitProvider
participant ReviewTool
participant LLM
participant OutputFormatter
User->>GitProvider: /review command
GitProvider->>ReviewTool: Fetch PR diff
ReviewTool->>LLM: Send for analysis
LLM->>OutputFormatter: Return structured review
OutputFormatter->>GitProvider: Format as markdown
GitProvider->>User: Publish review commentFile Walkthrough Parsing
The review tool parses file walkthroughs from PR descriptions using regex patterns:
regex_pattern = r'
# /improve Tool
## Overview
The `/improve` tool is a PR-Agent module that automatically scans pull request code changes and generates actionable code suggestions for improving the PR. It serves as the core component behind the `pr_code_suggestions` feature, providing developers with intelligent recommendations to enhance code quality, performance, and maintainability.
The tool can be triggered automatically when a PR is opened or invoked manually by commenting `/improve` on any pull request.
## Key Characteristics
| Attribute | Description |
|-----------|-------------|
| Tool Name | `improve` |
| Configuration Section | `pr_code_suggestions` |
| Invocation Command | `/improve` |
| Auto-trigger Support | Yes |
| Manual Trigger | Via PR comment |
| Output Format | Markdown table with collapsible code diffs |
## Architecture
graph TD A[PR Opened / /improve Command] --> B[pr_code_suggestions.py] B --> C[Get Diff Files from PR] C --> D[Analyze Code Changes] D --> E[Generate Suggestions via LLM] E --> F[Parse & Format Suggestions] F --> G[Render Markdown Output] G --> H[Post to PR as Comment]
F --> I[parse_code_suggestion function] I --> J[Table Format with GFM] I --> K[Diff Code Generation]
H --> L[GitHub Provider] H --> M[GitLab Provider] H --> N[Bitbucket Provider]
## Data Flow
sequenceDiagram participant User participant GitProvider participant ImproveTool participant LLM participant MarkdownRenderer
User->>GitProvider: Trigger /improve command GitProvider->>ImproveTool: Pass PR diff files ImproveTool->>LLM: Request code suggestions LLM->>ImproveTool: Return structured suggestions ImproveTool->>MarkdownRenderer: Parse suggestion data MarkdownRenderer->>ImproveTool: Generate formatted markdown ImproveTool->>GitProvider: Post comment to PR
## Configuration Options
The `/improve` tool is configured via the `pr_code_suggestions` section in the configuration file or through command-line arguments.
### Configuration Parameters
| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `enable_help_comment` | bool | Show help instructions in PR comment | Varies |
| `num_code_suggestions` | int | Maximum number of suggestions to generate | Config dependent |
### Command-Line Override
When commenting on a PR, edit configurations using:
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
### Configuration File Format
[pr_code_suggestions] some_config1=... some_config2=...
Sources: [pr_agent/servers/help.py:78-90]()
## Output Format
### Markdown Table Structure
The tool renders suggestions in a structured table format:
Category | Suggestion Content | Impact ---------|-------------------|--------
### Suggestion Component Model
Each code suggestion contains:
| Field | Description |
|-------|-------------|
| `label` | Category/label for the suggestion |
| `score` | Priority score (used for sorting) |
| `one_sentence_summary` | Brief description |
| `existing_code` | Original code block |
| `improved_code` | Suggested improved code |
| `relevant_file` | Target file path |
| `relevant_lines_start` | Start line number |
| `relevant_lines_end` | End line number |
Sources: [pr_agent/tools/pr_code_suggestions.py:1-50]()
### Rendering Logic
The rendering engine sorts suggestions by:
1. **Primary sort**: Group by label, ordered by highest score within each group
2. **Secondary sort**: Within each label group, suggestions are sorted by score descending
suggestions_labels = dict( sorted(suggestions_labels.items(), key=lambda x: max([s['score'] for s in x[1]]), reverse=True)) for label, suggestions in suggestions_labels.items(): suggestions_labels[label] = sorted(suggestions, key=lambda x: x['score'], reverse=True)
Sources: [pr_agent/tools/pr_code_suggestions.py:30-40]()
## Diff Generation
### Unified Diff Format
The tool generates `unified_diff` output for comparing existing and improved code:
diff = difflib.unified_diff( existing_code.split('\n'), improved_code.split('\n'), n=999 ) patch_orig = "\n".join(diff) patch = "\n".join(patch_orig.splitlines()[5:]).strip('\n')
Sources: [pr_agent/tools/pr_code_suggestions.py:80-90]()
### Output Wrapper
--- original
+++ improved
@@ ... @@
...diff content...
## Multi-Provider Support
### GitHub Provider
Standard markdown rendering with collapsible details:
### GitLab Provider
Similar to GitHub with minor formatting adjustments.
### Bitbucket Server Provider
Special handling for multi-line suggestions:
> Bitbucket does not support multi-line suggestions so use a code block instead
Sources: [pr_agent/git_providers/bitbucket_server_provider.py:200-210]()
## Usage Examples
### Manual Invocation
/improve /improve --pr_code_suggestions.num_code_suggestions=5 /improve --pr_code_suggestions.some_config=value
### Automated Trigger
Configured via GitHub App automatic tools, the tool runs on PR open events when enabled in settings.
## Related Utility Functions
### parse_code_suggestion
Located in `pr_agent/algo/utils.py`, this function converts suggestion dictionaries to markdown:
def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str: """ Convert a dictionary of data into markdown format. """ markdown_text = "" if gfm_supported and 'relevant_line' in code_suggestion: markdown_text += '<table>' # ... processing logic return markdown_text
Sources: [pr_agent/algo/utils.py:100-120]()
### extract_relevant_lines_str
Extracts relevant code lines from PR diff for context:
def extract_relevant_lines_str(end_line, files, relevant_file, start_line, dedent=False) -> str: """Finds 'relevant_file' in 'files', and extracts the lines from 'start_line' to 'end_line'"""
Sources: [pr_agent/algo/utils.py:150-180]()
## Integration Points
graph LR A[pr_code_suggestions.py] --> B[HelpMessage] A --> C[get_settings] A --> D[GitProvider] A --> E[utils.py functions]
B --> F[get_improve_usage_guide] C --> G[Configuration Loading] D --> H[Post Comments] E --> I[parse_code_suggestion] E --> J[render_*_markdown]
## See Also
- [Review Tool](/tools/review/) - Code review functionality
- [Describe Tool](/tools/describe/) - PR description generation
- [Ask Tool](/tools/ask/) - Interactive PR questions
- [Configuration Guide](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/)Sources: pr_agent/servers/help.py:1-30
Additional Tools
Related topics: Tools Overview, /describe Tool, /review Tool
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
Related topics: Tools Overview, /describe Tool, /review Tool
Additional Tools
PR-Agent provides several supplementary tools that extend beyond the core code review capabilities. These tools help developers with documentation lookup, changelog management, label generation, and finding related issues.
Overview
The Additional Tools module encompasses standalone utilities that can be invoked manually on pull requests. Unlike the core automated tools (describe, review, improve) that run automatically, these tools are typically triggered through comments on specific PRs.
graph TD
A[PR Agent Tools] --> B[Core Automated Tools]
A --> C[Additional Tools]
C --> D[ask]
C --> E[help_docs]
C --> F[update_changelog]
C --> G[generate_labels]
C --> H[similar_issue]
style C fill:#f9f,stroke:#333,stroke-width:2px
style D fill:#bbf,stroke:#333,stroke-width:1px
style E fill:#bbf,stroke:#333,stroke-width:1px
style F fill:#bbf,stroke:#333,stroke-width:1px
style G fill:#bbf,stroke:#333,stroke-width:1px
style H fill:#bbf,stroke:#333,stroke-width:1pxAsk Tool
The ask tool answers questions about the PR code changes using natural language.
Purpose
The ask tool provides a question-and-answer interface that allows developers to query information about a specific pull request. It analyzes the PR diff and code to provide contextual answers.
Invocation
/ask "What changes were made to the authentication module?"
Key Characteristics
| Characteristic | Description |
|---|---|
| Memory | No memory of previous questions |
| Independence | Each question answered independently |
| Scope | Entire PR, specific code lines, or images |
| Invocation | Manual only via PR comments |
Sources: pr_agent/servers/help.py:1-50
Implementation
The ask functionality is implemented in pr_agent/tools/pr_questions.py. The tool:
- Parses the question from the PR comment
- Extracts relevant code changes from the PR diff
- Generates a contextual response using the LLM
graph LR
A[User Comment: /ask "..."] --> B[Parse Question]
B --> C[Extract PR Diff]
C --> D[Generate Context]
D --> E[LLM Processing]
E --> F[Response Output]Help Docs Tool
The help_docs tool answers questions based on documentation files within the repository.
Purpose
This tool enables developers to ask questions about project documentation and receive accurate answers based on the actual documentation files.
Invocation
/help_docs "How do I configure the webhook?"
Configuration
The tool supports documentation from:
- The repository's own documentation files
- External documentation sources specified in configuration
Key Features
- Answers questions based on relative documentation paths
- Supports both repository-local and external documentation sources
- Provides accurate answers using RAG (Retrieval-Augmented Generation) techniques
Sources: pr_agent/tools/pr_help_docs.py
Update Changelog Tool
The update_changelog tool automatically updates changelog files based on PR changes.
Purpose
This tool ensures that changelog entries are created or updated when new features, fixes, or changes are merged.
Key Workflow
graph TD
A[PR Merged] --> B[Trigger update_changelog]
B --> C[Analyze PR Changes]
C --> D[Determine Changelog Category]
D --> E{Find Existing Changelog?}
E -->|Yes| F[Update Existing Entry]
E -->|No| G[Create New Entry]
F --> H[Format According to Standards]
G --> H
H --> I[Commit Changes]Changelog Categories
| Category | Description |
|---|---|
| Features | New functionality additions |
| Bug Fixes | Resolution of bugs |
| Breaking Changes | API or behavior changes |
| Documentation | Documentation updates |
Sources: pr_agent/tools/pr_update_changelog.py
Generate Labels Tool
The generate_labels tool automatically creates or suggests labels for pull requests.
Purpose
This tool analyzes PR changes and generates appropriate labels based on the content, type, and impact of the changes.
Label Generation Process
graph LR
A[Analyze PR Diff] --> B[Determine PR Type]
B --> C[Assess Impact Area]
C --> D[Match Against Existing Labels]
D --> E[Generate Label Suggestions]
E --> F[Apply or Present to User]Supported Label Types
| Label Type | Example |
|---|---|
| Type-based | Bug fix, Enhancement, Documentation |
| Area-based | Frontend, Backend, API, Database |
| Scope-based | Performance, Security, Testing |
| Custom | Repository-specific labels |
Sources: pr_agent/tools/pr_generate_labels.py
Similar Issue Tool
The similar_issue tool finds related issues or pull requests that address similar problems.
Purpose
This tool helps developers avoid duplicate work by identifying existing issues or PRs that may be related to the current issue being addressed.
Search Strategy
The tool uses multiple approaches to find similar issues:
- Semantic Search: Uses embeddings to find semantically similar text
- Keyword Matching: Identifies shared terminology
- Historical Analysis: Examines closed/resolved similar issues
Output Format
| Field | Description |
|---|---|
| Issue/PR Number | Reference identifier |
| Title | Issue/PR title |
| Similarity Score | Relevance indicator |
| Status | Open/Closed/Resolved |
| Resolution | How it was addressed (if closed) |
Sources: pr_agent/tools/pr_similar_issue.py
Common Configuration Options
Additional tools share several common configuration patterns.
Configuration via Comments
/tool_name --section.option=value
Configuration via File
[section_name]
option1 = value1
option2 = value2
Shared Settings
| Setting | Description | Default |
|---|---|---|
enable_help_comment | Show help links in output | Varies by tool |
output_relevant_configurations | Include config details in output | false |
Sources: pr_agent/servers/help.py:1-100
Usage Patterns
Manual Invocation
All additional tools are invoked manually through PR comments:
/ask "What does this function do?"
/help_docs "How do I run tests?"
/generate_labels
/similar_issue "authentication bug"
Tool Comparison
| Tool | Trigger Type | Automated | Primary Use Case |
|---|---|---|---|
| ask | Manual | No | Code understanding |
| help_docs | Manual | No | Documentation lookup |
| update_changelog | Manual/Auto | Optional | Release notes |
| generate_labels | Manual | Optional | Organization |
| similar_issue | Manual | No | Avoiding duplicates |
Help System Integration
Each tool includes integrated help documentation accessible through the help system:
graph TD
A[User] --> B[/help or /ask "help"]
B --> C[HelpMessage Class]
C --> D{Identify Tool}
D --> E[get_{tool}_usage_guide]
E --> F[Display Usage Info]
F --> G[Link to Full Documentation]The help system provides:
- Usage examples for each tool
- Configuration templates
- Links to detailed documentation pages
- GitHub App vs GitLab compatibility notes
Sources: pr_agent/servers/help.py:50-150
Implementation Architecture
Tool Base Structure
classDiagram
class BaseTool {
+run()
+get_settings()
+git_provider
}
class AskTool {
+answer_question()
}
class HelpDocsTool {
+find_documentation()
}
class UpdateChangelogTool {
+update_changelog()
}
class GenerateLabelsTool {
+generate_labels()
}
class SimilarIssueTool {
+find_similar()
}
BaseTool <|-- AskTool
BaseTool <|-- HelpDocsTool
BaseTool <|-- UpdateChangelogTool
BaseTool <|-- GenerateLabelsTool
BaseTool <|-- SimilarIssueToolUtility Functions
Shared utilities in pr_agent/algo/utils.py provide common functionality:
parse_code_suggestion(): Converts code suggestion dictionaries to markdownextract_relevant_lines_str(): Extracts specific code lines from diffsshow_relevant_configurations(): Displays configuration details
Sources: pr_agent/algo/utils.py:1-100
Best Practices
When to Use Additional Tools
| Scenario | Recommended Tool |
|---|---|
| Understanding complex code changes | ask |
| Finding documentation information | help_docs |
| Preparing release notes | update_changelog |
| Organizing PRs with labels | generate_labels |
| Checking for duplicate work | similar_issue |
Configuration Recommendations
- Enable help comments to guide users unfamiliar with tools
- Set up custom label mappings for the generate_labels tool
- Configure changelog format to match project standards
- Use appropriate documentation paths for help_docs tool
Documentation References
For detailed information about specific tools, refer to:
Sources: pr_agent/servers/help.py:1-50, pr_agent/servers/help.py:50-100
Sources: pr_agent/servers/help.py:1-50
Doramagic Pitfall Log
Source-linked risks stay visible on the manual page so the preview does not read like a recommendation.
First-time setup may fail or require extra isolation and rollback planning.
Developers may expose sensitive permissions or credentials: Add support for Databricks hosted models
The project may affect permissions, credentials, data exposure, or host boundaries.
The project may affect permissions, credentials, data exposure, or host boundaries.
Doramagic Pitfall Log
Doramagic extracted 16 source-linked risk signals. Review them before installing or handing real data to the project.
1. Installation risk: Allow specifying a custom branch for locating `.pr_agent.toml`
- Severity: high
- Finding: Installation risk is backed by a source signal: Allow specifying a custom branch for locating
.pr_agent.toml. Treat it as a review item until the current version is checked. - User impact: First-time setup may fail or require extra isolation and rollback planning.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/1977
2. Security or permission risk: Developers should check this security_permissions risk before relying on the project: Add support for Databricks hosted models
- Severity: high
- Finding: Developers should check this security_permissions risk before relying on the project: Add support for Databricks hosted models
- User impact: Developers may expose sensitive permissions or credentials: Add support for Databricks hosted models
- Recommended check: Before packaging this project, run the relevant install/config/quickstart check for: Add support for Databricks hosted models. Context: Observed when using python, docker
- Evidence: failure_mode_cluster:github_issue | fmev_63e7f7511bd7314419df2ded4a1a20e9 | https://github.com/The-PR-Agent/pr-agent/issues/2246 | Add support for Databricks hosted models
3. Security or permission risk: Add support for Databricks hosted models
- Severity: high
- Finding: Security or permission risk is backed by a source signal: Add support for Databricks hosted models. Treat it as a review item until the current version is checked.
- User impact: The project may affect permissions, credentials, data exposure, or host boundaries.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2246
4. Security or permission risk: GITLAB 404 project not found
- Severity: high
- Finding: Security or permission risk is backed by a source signal: GITLAB 404 project not found. Treat it as a review item until the current version is checked.
- User impact: The project may affect permissions, credentials, data exposure, or host boundaries.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2282
5. Security or permission risk: Incorrect Inline Code Suggestion Formatting in Azure DevOps
- Severity: high
- Finding: Security or permission risk is backed by a source signal: Incorrect Inline Code Suggestion Formatting in Azure DevOps. Treat it as a review item until the current version is checked.
- User impact: The project may affect permissions, credentials, data exposure, or host boundaries.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2110
6. Installation risk: Developers should check this installation risk before relying on the project: Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider
- Severity: medium
- Finding: Developers should check this installation risk before relying on the project: Bug + feature:
-i(incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider - User impact: Developers may fail before the first successful local run: Bug + feature:
-i(incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider - Recommended check: Before packaging this project, run the relevant install/config/quickstart check for: Bug + feature:
-i(incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider. Context: Observed when using python - Evidence: failure_mode_cluster:github_issue | fmev_f812843570a304cde8d165f9bd42e8dc | https://github.com/The-PR-Agent/pr-agent/issues/2379 | Bug + feature:
-i(incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider
7. Installation risk: Developers should check this installation risk before relying on the project: feat: support agent skills for context-aware review guidance
- Severity: medium
- Finding: Developers should check this installation risk before relying on the project: feat: support agent skills for context-aware review guidance
- User impact: Developers may fail before the first successful local run: feat: support agent skills for context-aware review guidance
- Recommended check: Before packaging this project, run the relevant install/config/quickstart check for: feat: support agent skills for context-aware review guidance. Context: Observed when using python
- Evidence: failure_mode_cluster:github_issue | fmev_6fae5a58920d170992e268f4837b86a9 | https://github.com/The-PR-Agent/pr-agent/issues/2384 | feat: support agent skills for context-aware review guidance
8. Installation risk: Developers should check this installation risk before relying on the project: v0.35.0
- Severity: medium
- Finding: Developers should check this installation risk before relying on the project: v0.35.0
- User impact: Upgrade or migration may change expected behavior: v0.35.0
- Recommended check: Before packaging this project, run the relevant install/config/quickstart check for: v0.35.0. Context: Observed when using python, docker, windows
- Evidence: failure_mode_cluster:github_release | fmev_c8b7b30719c4160c5c0104029f83e764 | https://github.com/The-PR-Agent/pr-agent/releases/tag/v0.35.0 | v0.35.0
9. Installation risk: CORS error on Azure DevOps when displaying "Work in progress" loading GIF
- Severity: medium
- Finding: Installation risk is backed by a source signal: CORS error on Azure DevOps when displaying "Work in progress" loading GIF. Treat it as a review item until the current version is checked.
- User impact: First-time setup may fail or require extra isolation and rollback planning.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2223
10. Installation risk: Publish linux/arm64 Docker image for github_app tag
- Severity: medium
- Finding: Installation risk is backed by a source signal: Publish linux/arm64 Docker image for github_app tag. Treat it as a review item until the current version is checked.
- User impact: First-time setup may fail or require extra isolation and rollback planning.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2386
11. Installation risk: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering
- Severity: medium
- Finding: Installation risk is backed by a source signal: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering. Treat it as a review item until the current version is checked.
- User impact: First-time setup may fail or require extra isolation and rollback planning.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2380
12. Installation risk: [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic
- Severity: medium
- Finding: Installation risk is backed by a source signal: [Bug]
temperatureparameter sent to claude-opus-4-7 causes 400 from Anthropic. Treat it as a review item until the current version is checked. - User impact: First-time setup may fail or require extra isolation and rollback planning.
- Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
- Evidence: Source-linked evidence: https://github.com/The-PR-Agent/pr-agent/issues/2400
Source: Doramagic discovery, validation, and Project Pack records
Community Discussion Evidence
These external discussion links are review inputs, not standalone proof that the project is production-ready.
Count of project-level external discussion links exposed on this manual page.
Open the linked issues or discussions before treating the pack as ready for your environment.
Community Discussion Evidence
Doramagic exposes project-level community discussion separately from official documentation. Review these links before using pr-agent with real data or production workflows.
- AzureDevopsProvider.get_repo_settings drops chunks after the first, sile - github / github_issue
- Incorrect Inline Code Suggestion Formatting in Azure DevOps - github / github_issue
- /improve on GitLab duplicates the persistent suggestions thread on every - github / github_issue
- [[Bug]
temperatureparameter sent to claude-opus-4-7 causes 400 from An](https://github.com/The-PR-Agent/pr-agent/issues/2400) - github / github_issue - Allow specifying a custom branch for locating
.pr_agent.toml- github / github_issue - Add support for Databricks hosted models - github / github_issue
- GITLAB 404 project not found - github / github_issue
- Publish linux/arm64 Docker image for github_app tag - github / github_issue
- CORS error on Azure DevOps when displaying "Work in progress" loading GI - github / github_issue
- feat: support agent skills for context-aware review guidance - github / github_issue
- Ticket context not scoped per PR in long-lived deployments β stale ticke - github / github_issue
- Developers should check this installation risk before relying on the project: Bug + feature:
-i(incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider - GitHub / issue
Source: Project Pack community evidence and pitfall evidence