Local and global metadata injection with multi-stage analysis
Supported Git Platforms: GitHub, GitLab, Bitbucket, Azure DevOps, Gitea
-
PR-Agent initially retrieves for each PR the following data:
- PR title and branch name
- PR original description
- Commit messages history (GitHub, GitLab, Gitea and Gerrit; the other providers send none).
/reviewand/improveget them too; setconfig.max_commits_tokens = -1to leave them out. - PR diff patches, in hunk diff format
- The entire content of the files that were modified in the PR
Tip: Organization-level metadataIn addition to the inputs above, PR-Agent can incorporate supplementary preferences provided by the user, like
extra_instructions. This information can be used to enhance the PR analysis. -
By default, the first command that PR-Agent executes is
describe, which generates three types of outputs:- PR Type (e.g. bug fix, feature, refactor, etc)
- PR Description - a bullet point summary of the PR
- Changes walkthrough - for each modified file, provide a one-line summary followed by a detailed bullet point list of the changes.
These AI-generated outputs are now considered as part of the PR metadata, and can be used in subsequent commands like
reviewandimprove. This effectively enables multi-stage chain-of-thought analysis, without doing any additional API calls which will cost time and money.For example, when generating code suggestions for different files, PR-Agent can inject the AI-generated "Changes walkthrough" file summary in the prompt:
## File: 'src/file1.py'### AI-generated file summary:- edited function `func1` that does X- Removed function `func2` that was not used- ....@@ ... @@ def func1():__new hunk__11 unchanged code line012 unchanged code line113 +new code line2 added14 unchanged code line3__old hunk__unchanged code line0unchanged code line1-old code line2 removedunchanged code line3@@ ... @@ def func2():__new hunk__...__old hunk__... -
The entire PR files that were retrieved are also used to expand and enhance the PR context (see Dynamic Context).
-
All the metadata described above represents several level of cumulative analysis - ranging from hunk level, to file level, to PR level, to organization level. This comprehensive approach enables PR-Agent AI models to generate more precise and contextually relevant suggestions and feedback.