Generate Labels
The 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
generate_labels
toolManual usage
Comment on the PR:
/generate_labels
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
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
generate_labels
After adding labels, they will be available for generation in generate_labels
.
Set
enable_custom_labels
toTrue
: This will turn off the default labels and enable the custom labels provided in thecustom_labels.toml
file.Add the custom labels. It should be formatted as follows:
[config]
enable_custom_labels=true
[custom_labels."Custom Label Name"]
description = "Description of when AI should suggest this label"
[custom_labels."Custom Label 2"]
description = "Description of when AI should suggest this label 2"
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:

When running the 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.
Last updated
Was this helpful?