# Agents in your GitHub pull request

## The SonarQube Remediation Agent

{% hint style="success" %}
The SonarQube Remediation Agent is a [Beta](https://docs.sonarsource.com/sonarqube-cloud/appendices/product-release-lifecycle#beta) feature available with the Team (annual) and Enterprise plan accounts. It is free during the beta phase and will be a paid feature when it moves to [General Availability](https://docs.sonarsource.com/sonarqube-cloud/appendices/product-release-lifecycle#general-availability). To learn more about the terms & conditions, please see our legal page about features in [Early Access](https://www.sonarsource.com/legal/early-access/).
{% endhint %}

When the SonarQube Remediation Agent is activated for **Pull request fixes** as described on the [sonarqube-remediation-agent](https://docs.sonarsource.com/sonarqube-cloud/administering-sonarcloud/ai-features/sonarqube-remediation-agent "mention") page, it's activity can be reviewed in SonarQube Cloud and the agent can be engaged in GitHub on your open pull request (PR). When your quality gate fails during a PR analysis, the agent is triggered and presents a list of eligible issues as a comment in your PR.&#x20;

Select **Run Remediation Agent** to activate the agent. If a fix or fixes are available, the SonarQube Remediation Agent will suggest changes a new PR targeting your branch. This PR contains a commit or series of commits along with information about each issue and why the changes were made.

<figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2FPlw37uT6ODtzSvQspcqZ%2Fsonarqube-agent-found-issues.png?alt=media&#x26;token=fd197602-832c-48d9-820c-40dbbcd509e8" alt="The SonarQube Remediation Agent will add a comment to your pull request when it finds eligible issues to fix."><figcaption></figcaption></figure>

After selecting **Run Remediation Agent**, a record of its activity shows up in SonarQube Cloud on your project's **Agent activity** page; see [#agent-behavior](#agent-behavior "mention") below, for details.

When additional commits are added to your PR and the quality gate again fails, a new agent will be triggered, repeating the process. Issues will be fixed once you review and merge the agent's changes into your active branch.

## Agent activity

To review the SonarQube Remediation Agent's activity, go to *Your SonarQube Cloud Project* > **Agent activity**. From there you will see the agent's:

1. Status/duration: Time the agent spent to generate fixes.
2. Started: When you selected **Run Remediation Agent**.
3. Source: Where the agent is working. *Backlog fixes* means that the agent is working on issues found in your main branch; or a link will be provided to the branch where you first called the agent.
4. Outcome: A link to the agent's PR will be available.&#x20;
   * PRs made for *Backlog fixes* will be on your `main` branch. See the [agent-backlog-fixes](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/issues/with-ai-features/agent-backlog-fixes "mention") page for details.
   * PRs made for *Pull request fixes* will be made on your branch. See the [#engage-with-the-agent](#engage-with-the-agent "mention") article for more information.

<figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2Fzo0hYjsJKgxztCAKN7rG%2Fsonarqube-cloud-agent-activity.png?alt=media&#x26;token=84d47193-c5c7-486e-98d9-0c59d420da1d" alt="The SonarQube Cloud Agent activity page lists each of the agent&#x27;s event moments on your pull request analyses."><figcaption></figcaption></figure>

## Engage with the agent

After selecting **Run Remediation Agent**, a single **Remediation Agent Summary** will be created on your open pull request explaining the agent's suggestions. The summary provides a brief explanation about the issue types that the agent addresses, giving you insight into types of issues that the agent will correct. A link will be provided to a new PR created by the agent, where you can review each fix before accepting the change. The diagram below highlights what you'll see in the **Remediation Agent Summary**:

1. The status of your quality gate will be shown on the activity history of our PR. The next action item in your history should be the Remediation Agent summary; if it doesn't show up or isn't updating its status, try refreshing your page.
2. Select the **Suggested fixes** collapsible to reveal the list of fixes provided by the agent. The summary page provides information about:
   * **Quality:** each issue's [software quality](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-rules/rules#software-qualities)
   * **Issue:** the issues's rule description and a link to the issue as found in the SonarQube Cloud Pull request analysis
3. If the agent can't provide a fix suggestion, **Issues requiring manual fix** will be listed. When expanded, you will see the issue's rule description and a link to the issue as found in the SonarQube Cloud Pull request analysis. See the page about using [connected-mode](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/connected-mode "mention") and connected mode to learn how to find and fix an issue in your IDE.
4. **Agent created PR #XXX** provides a link to a new PR created by the SonarQube Remediation Agent, on your branch. This PR contains a list of **Fixed Issues** including rule descriptions and a necessary series of commits organized by issue, ready for you to review. See [#review-agent-fix-suggestions](#review-agent-fix-suggestions "mention") below. A link to the same PR is also available on the [#agent-activity](#agent-activity "mention") page.

<div align="left"><figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2FVQODfRc4Y0cMEy9sNI4N%2Fsonarqube-cloud-remediation-agent-summary-with-pr.png?alt=media&#x26;token=4b5eab68-ca8b-4080-840a-8af2494c8cb1" alt="The current state of SonarQube Remediation Agent&#x27;s activity will be summarized as a comment in your pull request on GitHub."><figcaption></figcaption></figure></div>

## Review agent fix suggestions

Open the agent's PR as described in point 4 above to review fix suggestions before merging them into your original PR.

The **Fixed Issues** summary on the agent's pull request lists each issue's rule number, title, quality, description, along with a link to the issue in SonarQube Cloud. Below the PR summary you'll find a list of commits where the change summary is stacked and sorted by issue keys.

1. The SonarQube Remediation Agent creates a new PR targeting your branch.
2. A link to your project in SonarQube Cloud is provided.
3. The PR summary provides a list of **Fixed Issues** as an inventory of fixes in this PR. Expand an issue to see its rule description, information about **Why this is an issue**, and a quick diff view showing **What changed** in this PR.
4. The **View issue** link takes you to the issue in SonarQube Cloud.
5. The SonarQube Remediation Agent is listed as the commit author.
6. The agent's comments are condensed in the commit message and the change summary is stacked and sorted by issue key.
7. A new PR analysis will be run automatically to check the agent's fixes against your quality standards.

<div align="left"><figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2FlgyQ9BW4qXHZawHNutLX%2Fsonarqube-cloud-review-fixed-issues-in-pr.png?alt=media&#x26;token=de7b55c1-84ce-466b-81b7-ec9a1c152dde" alt="Each issue fixed by the SonarQube Remediation Agent will have information to help you review what is changed in the PR."><figcaption></figcaption></figure></div>

Once reviewed and merged, the commits will be added to your original PR. These new commits will trigger a new [pull-request-analysis](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/pull-request-analysis "mention") and the cycle will repeat until your quality gate passes your quality standards.

## Agent backlog fixes

The SonarQube Remediation Agent can also work on existing issues found in your `main` branch. See the [agent-backlog-fixes](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/issues/with-ai-features/agent-backlog-fixes "mention") page for full details.
