|
| 1 | +# ADK Pull Request Triaging Assistant |
| 2 | + |
| 3 | +The ADK Pull Request (PR) Triaging Assistant is a Python-based agent designed to help manage and triage GitHub pull requests for the `google/adk-python` repository. It uses a large language model to analyze new and unlabelled pull requests, recommend appropriate labels, assign a reviewer, and check contribution guides based on a predefined set of rules. |
| 4 | + |
| 5 | +This agent can be operated in two distinct modes: |
| 6 | + |
| 7 | +* an interactive mode for local use |
| 8 | +* a fully automated GitHub Actions workflow. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Interactive Mode |
| 13 | + |
| 14 | +This mode allows you to run the agent locally to review its recommendations in real-time before any changes are made to your repository's pull requests. |
| 15 | + |
| 16 | +### Features |
| 17 | +* **Web Interface**: The agent's interactive mode can be rendered in a web browser using the ADK's `adk web` command. |
| 18 | +* **User Approval**: In interactive mode, the agent is instructed to ask for your confirmation before applying a label or posting a comment to a GitHub pull request. |
| 19 | + |
| 20 | +### Running in Interactive Mode |
| 21 | +To run the agent in interactive mode, first set the required environment variables. Then, execute the following command in your terminal: |
| 22 | + |
| 23 | +```bash |
| 24 | +adk web |
| 25 | +``` |
| 26 | +This will start a local server and provide a URL to access the agent's web interface in your browser. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## GitHub Workflow Mode |
| 31 | + |
| 32 | +For automated, hands-off PR triaging, the agent can be integrated directly into your repository's CI/CD pipeline using a GitHub Actions workflow. |
| 33 | + |
| 34 | +### Workflow Triggers |
| 35 | +The GitHub workflow is configured to run on specific triggers: |
| 36 | + |
| 37 | +* **Pull Request Events**: The workflow executes automatically whenever a new PR is `opened` or an existing one is `reopened` or `edited`. |
| 38 | + |
| 39 | +### Automated Labeling |
| 40 | +When running as part of the GitHub workflow, the agent operates non-interactively. It identifies and applies the best label or posts a comment directly without requiring user approval. This behavior is configured by setting the `INTERACTIVE` environment variable to `0` in the workflow file. |
| 41 | + |
| 42 | +### Workflow Configuration |
| 43 | +The workflow is defined in a YAML file (`.github/workflows/pr-triage.yml`). This file contains the steps to check out the code, set up the Python environment, install dependencies, and run the triaging script with the necessary environment variables and secrets. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Setup and Configuration |
| 48 | + |
| 49 | +Whether running in interactive or workflow mode, the agent requires the following setup. |
| 50 | + |
| 51 | +### Dependencies |
| 52 | +The agent requires the following Python libraries. |
| 53 | + |
| 54 | +```bash |
| 55 | +pip install --upgrade pip |
| 56 | +pip install google-adk |
| 57 | +``` |
| 58 | + |
| 59 | +### Environment Variables |
| 60 | +The following environment variables are required for the agent to connect to the necessary services. |
| 61 | + |
| 62 | +* `GITHUB_TOKEN`: **(Required)** A GitHub Personal Access Token with `pull_requests:write` permissions. Needed for both interactive and workflow modes. |
| 63 | +* `GOOGLE_API_KEY`: **(Required)** Your API key for the Gemini API. Needed for both interactive and workflow modes. |
| 64 | +* `OWNER`: The GitHub organization or username that owns the repository (e.g., `google`). Needed for both modes. |
| 65 | +* `REPO`: The name of the GitHub repository (e.g., `adk-python`). Needed for both modes. |
| 66 | +* `INTERACTIVE`: Controls the agent's interaction mode. For the automated workflow, this is set to `0`. For interactive mode, it should be set to `1` or left unset. |
| 67 | + |
| 68 | +For local execution in interactive mode, you can place these variables in a `.env` file in the project's root directory. For the GitHub workflow, they should be configured as repository secrets. |
0 commit comments