From c6c80a2ac25af3438add933ae02456a547f9b75b Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 11 Aug 2026 23:53:59 -0300 Subject: [PATCH] CI: make the Gemini PR reviewer actually review The job has never posted a review. It passed the Gemini API key but never set a model, so PR-Agent kept its OpenAI defaults (`gpt-5.6`, falling back to `gpt-5.6-terra`) and every call failed with AuthenticationError - Incorrect API key provided: dummy_key PR-Agent swallows that error, so the run still went green and the failure was invisible. Setting `config.model` / `config.fallback_models` to Gemini models is the actual fix. Three other reasons it never worked: - `pull_request` gives no secrets to fork PRs, and most contributions are fork PRs (23 of the 27 currently open). Those runs sat in `action_required` (22 of the last 60) and would have had an empty key even once approved. `pull_request_target` is safe here because the job never checks the PR out. - `synchronize` is not in PR-Agent's `pr_actions`, so every push logged "Skipping action: synchronize" after a ~30 s image build - 38 of the last 60 runs were that no-op. - `issue_comment` runs the workflow from the default branch, and this file only exists on `develop`, so `/review` and `/ask` never fired once: all 74 recorded runs were `pull_request`. Also raise the token ceiling off the 32k default, since Gemini takes 1M and larger diffs were being truncated; leave the human-written PR description alone by turning `auto_describe` off; and drop the unused `contents: write`. The action ref moves from `@main` to a release tag. Note that this pins the action definition only: `Dockerfile.github_action_dockerhub` is a one-liner that pulls `pragent/pr-agent:github_action`, a floating tag, so the agent itself is still whatever that image currently holds. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/pr_agent.yml | 43 ++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr_agent.yml b/.github/workflows/pr_agent.yml index 7e1300ff2..67b6f13b9 100644 --- a/.github/workflows/pr_agent.yml +++ b/.github/workflows/pr_agent.yml @@ -1,22 +1,51 @@ -name: Qodo PR-Agent Gemini Reviewer +name: PR Agent Gemini Reviewer +# Automatic PR review powered by Google AI Studio (Gemini) through PR-Agent. +# +# `pull_request_target` rather than `pull_request`: most contributions arrive as +# PRs from forks, and a `pull_request` run triggered by a fork gets no secrets, +# so GEMINI_API_KEY would be empty (and the run would sit in `action_required` +# waiting for approval). That is safe here because this job never checks the +# pull request out - PR-Agent reads the diff over the GitHub API, and the only +# step is a version-pinned container action - so no untrusted code is executed. +# +# `synchronize` is deliberately absent: PR-Agent skips that event unless +# `github_action_config.handle_push_trigger` is set, so it only burned a runner +# on every push. Enable that setting if you want a re-review on each push. on: - pull_request: - types: [opened, synchronize, reopened] + pull_request_target: + types: [opened, reopened, ready_for_review] issue_comment: types: [created] jobs: pr_agent_job: + name: Run PR Agent + # Never react to our own comments, which would loop, and ignore comments on + # plain issues, which carry no diff to review. + if: >- + github.event.sender.type != 'Bot' + && (github.event_name != 'issue_comment' || github.event.issue.pull_request) runs-on: ubuntu-latest permissions: + contents: read issues: write pull-requests: write - contents: write - name: Run PR Agent steps: - name: PR Agent Action - uses: the-pr-agent/pr-agent@main + uses: the-pr-agent/pr-agent@v0.42.0 env: - GOOGLE_AI_STUDIO.GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GOOGLE_AI_STUDIO.GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + # Required. Without an explicit model PR-Agent keeps its OpenAI + # defaults and every call dies with `AuthenticationError - Incorrect + # API key provided: dummy_key`, which is what kept this job from ever + # posting a review. + config.model: "gemini/gemini-3.5-pro" + config.fallback_models: '["gemini/gemini-3.6-flash"]' + # Gemini accepts 1M tokens; the 32k default truncates larger diffs. + config.max_model_tokens: "128000" + # Review and suggest, but leave the human-written description alone. + github_action_config.auto_describe: "false" + github_action_config.auto_review: "true" + github_action_config.auto_improve: "true"