generate_labels tool analyzes the PR code changes and automatically suggests relevant labels, based on a list of predefined labels and their descriptions.
How to use the generate_labels tool
Manual usage
Comment on the PR:
Enabling custom labels
There are 3 ways to enable custom labels:1. CLI (local configuration file)
When working from CLI, you need to apply the configuration changes to the custom_labels file.2. Repository configuration file
To enable custom labels, you need to apply the configuration changes to the local.pr_agent.toml file in your repository.
3. Handle custom labels from the repo’s labels page
Platforms supported: GitHub, GitLab
- GitHub:
https://github.com/{owner}/{repo}/labels, or click the Labels tab in the issues or PR’s page. - GitLab:
https://gitlab.com/{owner}/{repo}/-/labels, or click Manage and then Labels from the left menu.
Adding custom labels
Custom labels should be formatted as:- Label name: The name of the custom label.
-
Description: Start the description with prefix
pr_agent:, for example:pr_agent: Description of when AI should suggest this label. The description should be comprehensive and detailed, indicating when to add the desired label.
Using generate_labels
After adding labels, they will be available for generation in generate_labels.
- Set
enable_custom_labelstoTrue: This will turn off the default labels and enable the custom labels provided in thecustom_labels.tomlfile. - Add the custom labels. It should be formatted as follows:
Example usage
If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description:
generate_labels tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label:

Note that in addition to the dedicated tool
generate_labels, the custom labels will also be used by the describe tool.