Skip to main content

Fetching Ticket Context for PRs

Supported Git Platforms: GitHub, GitLab, Bitbucket, Azure DevOps, Gitea

Branch-name linking: Jira keys on all providers; numeric GitHub issues on GitHub only

Jira ticket keys (e.g. ABC-123) are extracted from the branch name on every git provider. Extracting numeric GitHub issue links from the branch name (and the optional branch_issue_regex setting) is currently implemented for GitHub only; support for other providers is planned for a later release.

Overview​

PR-Agent streamlines code review workflows by seamlessly connecting with multiple ticket management systems. This integration enriches the review process by automatically surfacing relevant ticket information and context alongside code changes.

Ticket systems supported:

Ticket data fetched:

  1. Ticket Title
  2. Ticket Description
  3. Acceptance criteria (configured Jira custom fields and Azure DevOps work items)
  4. GitHub sub-issues
  5. Labels

Image attachments are not fetched or sent to the model as images by the ticket integration.

Affected Commands​

Ticket Recognition Requirements:

  • GitHub/GitLab issue references can appear in the PR/MR title or description. GitHub also recognizes numeric issue references in the branch name.
  • For Jira tickets, you should follow the instructions in Jira Integration in order to authenticate with Jira.
  • For Asana tickets, see Asana Integration.

Describe command​

PR-Agent will recognize the ticket and use the ticket content (title, description, labels) to provide additional context for the code changes. By understanding the reasoning and intent behind modifications, the LLM can offer more insightful and relevant code analysis.

Review command​

Similarly to the describe command, the review command will use the ticket content to provide additional context for the code changes.

In addition, this feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue. Each ticket will be assigned a compliance assessment in the review comment, indicating the degree to which the PR fulfills its original purpose. These assessments are not added as PR labels:

  • Fully Compliant
  • Partially Compliant
  • Not Compliant
  • PR Code Verified
Ticket Compliance

A PR Code Verified assessment indicates the PR code meets ticket requirements, but requires additional manual testing beyond the code scope. For example - validating UI display across different environments (Mac, Windows, mobile, etc.).

Configuration options​

  • By default, the review command will automatically validate if the PR complies with the referenced ticket. If you want to disable this feedback, add the following line to your configuration file:

    [pr_reviewer]
    require_ticket_analysis_review=false

Ask command​

Set pr_questions.use_ticket_context=true to include linked ticket content in top-level /ask questions. This is disabled by default and is independent of pr_reviewer.require_ticket_analysis_review. It reuses the ticket integrations below and fits complete ticket records into the space left after the question, conversation history and selected diff. See Linked ticket context for usage and limits.

GitHub/GitLab Issues Integration​

PR-Agent will automatically recognize GitHub/GitLab issues mentioned in the PR/MR title or description and fetch the issue content. Examples of valid GitHub/GitLab issue references:

  • https://github.com/<ORG_NAME>/<REPO_NAME>/issues/<ISSUE_NUMBER> or https://gitlab.com/<ORG_NAME>/<REPO_NAME>/-/issues/<ISSUE_NUMBER>
  • #<ISSUE_NUMBER>
  • <ORG_NAME>/<REPO_NAME>#<ISSUE_NUMBER>

Full GitHub issue URLs are recognized on the configured instance's HTTPS web origin, including GitHub Enterprise URLs such as https://github.example.com/<ORG_NAME>/<REPO_NAME>/issues/<ISSUE_NUMBER>. Full GitHub issue URLs on other origins are ignored.

GitHub processes references from the description first, then the branch name, then the title. GitLab processes description references before title references. Repeated identical references do not add lookups, and title references use the existing ticket lookup and result limits without displacing earlier sources.

The optional config.description_issue_regex setting applies only to the GitHub PR description. Built-in matching on GitHub and GitLab recognizes local #<ISSUE_NUMBER> references of up to six digits.

Branch names can also be used to link issues, for example:

  • 123-fix-bug (where 123 is the issue number)

This branch-name detection applies only when the git provider is GitHub. Support for other platforms is planned for later.

By default, GitHub and GitLab ticket context is limited to the PR's or MR's own repository. Issues and sub-issues in another repository require explicit host approval through config.repo_context_sibling_repos:

[config]
repo_context_sibling_repos = ["myorg/shared-tickets"]

Only canonical repositories under the PR repository's resolved owner are accepted on GitHub; on GitLab the project must share the MR project's top-level namespace. For private or internal repositories, the command requester must also have read access; CLI runs use the PR author when no command actor is available. Repository settings and comment arguments cannot change this allowlist. An empty list disables cross-repository ticket reads, including public repositories. Approve only content that may be included in the consuming PR's review or description. Ticket lookup limits are separate from the sibling-file limit. PyGithub may follow an issue transfer, but results from a different repository are discarded before prompt use. Reference a transferred issue by its current repository and number.

For GitHub, PR-Agent skips sub-issue lookup only when the parent issue's fetched summary explicitly reports zero sub-issues; nonzero, missing, or invalid totals use the usual lookup. This uses the parent response as a snapshot, so a stale zero count or sub-issues added after that read may leave child tickets out of the current run's context.

Linear Integration​

PR-Agent reads Linear issue links from the user-written PR description and includes their titles, descriptions, and labels in the existing ticket context. This works across git providers, including providers without native issue support. Enable pr_reviewer.require_ticket_analysis_review to use ticket analysis.

Link an issue as https://linear.app/your-workspace/issue/TEAM-123 or include its optional title slug. Query strings and fragments do not change issue identity. Repeated links to the same workspace and issue are deduplicated in description order. Bare identifiers, PR titles and branch names are not scanned for Linear issues.

Create a Linear personal API key with read access to the intended issues. Set LINEAR__API_TOKEN in the deployment environment, or add it to your private .secrets.toml:

[linear]
api_token = "your-personal-api-key"

Do not put the token in repository .pr_agent.toml files. Existing credential protections prevent repositories and review-command arguments from overriding it. Fetched ticket content enters the review model's context; choose credential access appropriate for the repositories using the integration.

The key is sent directly in the Authorization header to https://api.linear.app/graphql, without a Bearer prefix. Requests do not follow redirects. No OAuth application or additional service is required.

PR-Agent attempts the first three unique issue references, concurrently and in description order, with no replacement attempts for failed issues. Results are appended after existing native, Asana and Jira tickets, without reducing their limits. Descriptions are truncated to 10,000 characters and at most 20 labels are fetched. The shared prompt-token budget may further reduce ticket context.

Missing credentials, inaccessible issues, HTTP errors and GraphQL errors cause the affected issues to be skipped with a warning; successful tickets and the code review continue. No placeholder ticket or separate failure verdict is published. An API response for a different workspace or issue is rejected. Configure linear.request_timeout to change the default 10-second per-request timeout (maximum 60 seconds). Existing review-local ticket caching applies.

Asana Integration​

PR-Agent can detect Asana task references in PR descriptions, fetch the referenced tasks through the Asana API, and include their titles, descriptions, and tags in the ticket compliance check.

Supported reference formats:

  • Legacy links: https://app.asana.com/0/{project_gid}/{task_gid}
  • Current permalinks: https://app.asana.com/1/{workspace_gid}/task/{task_gid}
  • Current project links: https://app.asana.com/1/{workspace_gid}/project/{project_gid}/task/{task_gid}
  • Current Home links: https://app.asana.com/1/{workspace_gid}/home/task/{task_gid}
  • Task comment links ending in /comment/{comment_gid} (the parent task is fetched)

How to link a PR to an Asana task:

Include an Asana task URL in your PR description. PR-Agent will detect it automatically and include it in the related tickets list.

Authentication​

Create an Asana personal access token with access to the tasks that PR-Agent should read. Configure it in .secrets.toml:

[asana]
api_token = "YOUR_PERSONAL_ACCESS_TOKEN"

For environment-based deployments, set the equivalent Dynaconf environment variable:

ASANA__API_TOKEN="YOUR_PERSONAL_ACCESS_TOKEN"

The token is sent only to Asana's fixed task API endpoint as a Bearer token. When no token is configured or a task is not accessible to that token, PR-Agent skips that Asana task instead of evaluating compliance against placeholder content. API request timeout can be adjusted with asana.request_timeout (10 seconds by default, capped at 60 seconds).

Ticket limits​

PR-Agent fetches the first three detected Asana tasks at most, preserving their description order. This is an additive, provider-specific limit, with native tickets listed before Asana tasks:

  • On GitHub, the existing limit of three GitHub issues is preserved, plus up to three Asana tasks.
  • On Azure DevOps, all linked work items are preserved, plus up to three Asana tasks.
  • On other providers, up to three detected Asana tasks can supply ticket context.

Keeping these limits separate prevents Asana references from silently displacing native tickets and avoids changing the established ticket-extraction behavior of existing providers.

Jira Integration​

Jira lookup needs the bitbucket extra: pip install "pr-agent[bitbucket]". Without it the lookup is skipped with a warning.

Only Jira Cloud is supported. The base URL is derived from a validated site name (jira_site → https://<site>.atlassian.net) rather than taken as a free-form URL, so the configured destination is always an Atlassian Cloud host. Jira Server / Data Center (self-hosted) uses a free-form host and is not supported yet; it can be added once base-URL handling for the self-hosted case is settled.

Jira Cloud​

Email/Token Authentication​

You can create an API token from your Atlassian account:

  1. Log in to https://id.atlassian.com/manage-profile/security/api-tokens.

  2. Click Create API token.

  3. From the dialog that appears, enter a name for your new token and click Create.

  4. Click Copy to clipboard.

    Jira Cloud API Token
  5. In the PR-Agent host configuration (the secrets file or environment variables such as JIRA__JIRA_SITE) add the following lines. A repository's .pr_agent.toml cannot set them:

    [jira]
    jira_site = "<JIRA_SITE>" # the "<site>" in https://<site>.atlassian.net (e.g. "mycompany")
    cloud_id = "<CLOUD_ID>" # optional UUID for scoped or service-account tokens
    jira_api_email = "YOUR_EMAIL"
    jira_api_token = "YOUR_API_TOKEN"

    jira_site is your Jira Cloud site name — the part before .atlassian.net (for https://mycompany.atlassian.net, the site is mycompany). PR-Agent builds the base URL as https://<jira_site>.atlassian.net; it does not accept a full URL, so configuration cannot redirect the authenticated request to another host. Store jira_api_email and jira_api_token as secrets (environment variables or the secrets file), not in repository-committed configuration.

    For scoped or service-account API tokens, set cloud_id to the UUID of the Jira Cloud site. Requests then use https://api.atlassian.com/ex/jira/<cloud_id> while ticket links continue to use jira_site. Leave cloud_id empty for classic API tokens and the site-specific URL. The value is host-only and invalid values disable Jira lookup without logging the value.

    To find the cloud ID, open https://<site>.atlassian.net/_edge/tenant_info and read the cloudId value from the JSON response. It is also the value after /s/ in the admin.atlassian.com URL. Use the cloud ID, not the Jira organization ID, because Atlassian's API gateway expects the site cloud ID.

Acceptance criteria / requirements (optional)​

To include a ticket's acceptance criteria in the analysis, set jira_requirements_field to the id of the custom field that holds it. The field id is specific to your Jira instance (for example customfield_10127); leave it empty to skip requirements.

[jira]
jira_requirements_field = "customfield_10127"

Project key allowlist (optional)​

Ticket detection matches any PROJECT-123 shaped text, so strings like SHA-256, UTF-8 or ISO-8601 in a title or description each cost an authenticated lookup that returns 404. If your deployment works with a known set of Jira projects, list their keys in the host's project_keys; keys with any other prefix are then dropped before any lookup (they are named once at debug level in the log). By default, project_keys = ["*"] looks up every key found. Set project_keys = [] to disable Jira ticket lookups. cloud_id, project_keys, jira_site and jira_api_email are host-only: a repository's .pr_agent.toml or a comment command cannot change them.

[jira]
project_keys = ["PROJ", "OPS"]

Entries are plain upper-case project keys as Jira writes them (a letter, then letters or digits, such as PROJ or B2B) or "*" to allow all keys. Anything else (a lower-case label, a full ticket key, a URL, a blank entry) is ignored with a warning. If the list is set but none of its entries is valid, no Jira lookup is made at all until it is fixed, so a typo cannot silently widen the lookup again.

To integrate with Jira, you can link your PR to a ticket using either of these methods:

Method 1: Description Reference:

Include a ticket reference in your PR description, using either the complete URL format https://<JIRA_SITE>.atlassian.net/browse/ISSUE-123 or the shortened ticket ID ISSUE-123 (without prefix or suffix for the shortened ID).

Method 2: Branch Name Detection:

Name your branch with the ticket ID as a prefix (e.g., ISSUE-123-feature-description or ISSUE-123/feature-description).