From e4a9dab101d96a582cedaba894a70aced464d2a4 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:33:55 -0500 Subject: [PATCH 1/6] feat: reusable PR-Agent review with workload identity, no stored key Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pr-agent.yml | 95 ++++++++++++++++++++++++++++++++++ docs/USAGE.md | 41 +++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .github/workflows/pr-agent.yml diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml new file mode 100644 index 0000000..2e0581a --- /dev/null +++ b/.github/workflows/pr-agent.yml @@ -0,0 +1,95 @@ +name: PR-Agent review + +# Reusable AI code review: PR-Agent (open source, MIT) on Claude, with no stored key. +# Each run exchanges GitHub's identity token for a 15-minute Anthropic token +# (workload identity federation). The token acts as the `pr-agents` service account +# and works only in the `pr-cicd` workspace, which has its own spend limit. +# +# The federation rule `pr-agent-org` accepts a token only when all of these hold: +# - the repository owner is tilorahdotco (owner id 350058761); +# - the running job is this workflow (`job_workflow_ref`); +# - the caller file is the repository's `.github/workflows/pr-agent.yml`; +# - the event is `pull_request` or `issue_comment`. +# No other workflow can mint a token, and fork PRs get no identity token. +# +# Callers own triggers and concurrency, and must grant `id-token: write`. +# Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback; a repository's +# `.pr_agent.toml` can override them and add review instructions. See docs/USAGE.md. +on: + workflow_call: + inputs: + runner: + description: Runner label. Public repositories must use a GitHub-hosted runner. + type: string + default: instabox-small + timeout-minutes: + type: number + default: 15 + +jobs: + review: + name: PR-Agent + # PR events from this repository (not forks or drafts), or `/` commands on a PR + # from people with write access to it. + if: >- + (github.event_name == 'pull_request' + && github.event.pull_request.head.repo.full_name == github.repository + && !github.event.pull_request.draft) + || (github.event_name == 'issue_comment' + && github.event.issue.pull_request + && startsWith(github.event.comment.body, '/') + && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) + runs-on: ${{ inputs.runner }} + timeout-minutes: ${{ inputs.timeout-minutes }} + permissions: + contents: read + pull-requests: write + issues: write + id-token: write + steps: + - name: Get a short-lived Anthropic token + env: + RULE_ID: fdrl_01HuULKgzQTuwtQDA7Cy8xQf # pr-agent-org + ORGANIZATION_ID: 3efd7970-54a4-4834-bde7-e84f38565f5a + SERVICE_ACCOUNT_ID: svac_01LYi4xr4JDN5ev9mGmcouMu # pr-agents + WORKSPACE_ID: wrkspc_01YNuFrBrkTtRpF7MFBtFqbv # pr-cicd + run: | + set -euo pipefail + JWT=$(curl -fsS --max-time 30 -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ + "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://api.anthropic.com" | jq -r .value) + echo "::add-mask::$JWT" + export JWT + if ! response=$(jq -n '{grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", + assertion: env.JWT, federation_rule_id: env.RULE_ID, organization_id: env.ORGANIZATION_ID, + service_account_id: env.SERVICE_ACCOUNT_ID, workspace_id: env.WORKSPACE_ID}' \ + | curl -sS --max-time 30 https://api.anthropic.com/v1/oauth/token \ + -H 'content-type: application/json' -d @-); then + echo "::error::Could not reach the Anthropic token endpoint." + exit 1 + fi + token=$(jq -r '.access_token // empty' <<<"$response" 2>/dev/null || true) + case "$token" in + sk-ant-oat01-*) ;; + *) + # The error body holds no secret: a type and a fixed message. + reason=$(jq -r '"\(.error.type // "unknown"): \(.error.message // "no message")"' <<<"$response" 2>/dev/null \ + || echo "the response was not JSON") + echo "::error::The Anthropic token exchange failed ($reason). The Claude Console shows the deny reason under Workload identity, History." + exit 1 + ;; + esac + echo "::add-mask::$token" + echo "ANTHROPIC_WIF_TOKEN=$token" >> "$GITHUB_ENV" + - name: Run PR-Agent + uses: The-PR-Agent/pr-agent@e673a02076ce09a4726c3d0c3cc85780e59ca52b # v0.50.0 + env: + # LiteLLM sends an `sk-ant-oat` token as `Authorization: Bearer`. + ANTHROPIC.KEY: ${{ env.ANTHROPIC_WIF_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + CONFIG.MODEL: anthropic/claude-opus-5-5 + CONFIG.FALLBACK_MODELS: '["anthropic/claude-sonnet-5-5"]' + CONFIG.ENABLE_CLAUDE_ADAPTIVE_THINKING: "true" + CONFIG.REASONING_EFFORT: high + github_action_config.auto_review: "true" + github_action_config.auto_describe: "false" # the PR template is the description + github_action_config.auto_improve: "false" diff --git a/docs/USAGE.md b/docs/USAGE.md index 6548e10..5c5e77d 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -20,6 +20,7 @@ jobs: | `security.yml` | Parallel jobs `Secret scan` (gitleaks CLI) and `Dependency audit`. | `secret-scan`, `audit`, `audit-level`, `working-directory`, `runner` | none | | `deploy-cpanel.yml` | Job `Deploy` (cPanel Git pull), then `Verify live` (HTTP 200 and byte compare). | `trigger`, `cpanel-repo`, `branch`, `host` (required), `verify-url`, `live-base-url`, `live-files`, `runner` | `CPANEL_USER`, `CPANEL_PASSWORD` | | `deploy-cloudflare.yml` | Job `Build`, then `Deploy` (wrangler) from the built artifact. Manual release only. | `node-version`, `install`, `build`, `check`, `wrangler-version`, `command`, `runner` | `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID` | +| `pr-agent.yml` | Job `PR-Agent`: AI review of each PR with PR-Agent on Claude, and `/review`, `/improve`, `/ask` comments. No stored key: it exchanges GitHub's identity token for a 15-minute Anthropic token. | `runner`, `timeout-minutes` | none | Rules: - Pin every `uses:` to a full commit SHA. Dependabot keeps the pins in this repository current. @@ -181,3 +182,43 @@ jobs: root-dir: . args: --verbose --no-progress --exclude-mail '**/*.html' ``` + +## PR-Agent review + +Copy this caller to `.github/workflows/pr-agent.yml` in the repository. The file +name matters: the Anthropic federation rule accepts tokens only for a caller at +that path, running this workflow, in a `tilorahdotco` repository, on a +`pull_request` or `issue_comment` event. + +```yaml +name: PR-Agent review +on: + pull_request: + types: [opened, reopened, ready_for_review] + issue_comment: + types: [created] +permissions: + contents: read + pull-requests: write + issues: write + id-token: write # GitHub's identity token, exchanged for a short-lived Anthropic token +concurrency: + group: pr-agent-${{ github.event.pull_request.number || github.event.issue.number }} + cancel-in-progress: false +jobs: + review: + name: PR-Agent review + uses: tilorahdotco/.github/.github/workflows/pr-agent.yml@ + with: + runner: ${{ vars.LIGHT_RUNNER || 'instabox-small' }} # public repositories: ubuntu-latest +``` + +- Tokens act as the `pr-agents` service account and work only in the `pr-cicd` + Anthropic workspace, which has its own spend limit. No repository needs an + Anthropic secret. +- Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback, adaptive thinking + at high effort. A repository's `.pr_agent.toml` can override them and add + `[pr_reviewer] extra_instructions`. +- A failed exchange fails the job with Anthropic's error type. The deny reason is + in the Claude Console under Workload identity, History. + From bf2a191e0661a6da781b52d151324d67ec218880 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:41:51 -0500 Subject: [PATCH 2/6] feat(pr-agent): review with Claude Haiku 5.5 at medium effort Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pr-agent.yml | 9 +++++---- docs/USAGE.md | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index 2e0581a..b57d00d 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -13,8 +13,9 @@ name: PR-Agent review # No other workflow can mint a token, and fork PRs get no identity token. # # Callers own triggers and concurrency, and must grant `id-token: write`. -# Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback; a repository's -# `.pr_agent.toml` can override them and add review instructions. See docs/USAGE.md. +# The model is Claude Haiku 5.5 at medium effort (PB, 2026-11-19: reviews are comments, +# so the small model is enough); Sonnet 5.5 runs only when a Haiku call fails. A +# repository's `.pr_agent.toml` can add review instructions. See docs/USAGE.md. on: workflow_call: inputs: @@ -86,10 +87,10 @@ jobs: # LiteLLM sends an `sk-ant-oat` token as `Authorization: Bearer`. ANTHROPIC.KEY: ${{ env.ANTHROPIC_WIF_TOKEN }} GITHUB_TOKEN: ${{ github.token }} - CONFIG.MODEL: anthropic/claude-opus-5-5 + CONFIG.MODEL: anthropic/claude-haiku-5-5 CONFIG.FALLBACK_MODELS: '["anthropic/claude-sonnet-5-5"]' CONFIG.ENABLE_CLAUDE_ADAPTIVE_THINKING: "true" - CONFIG.REASONING_EFFORT: high + CONFIG.REASONING_EFFORT: medium github_action_config.auto_review: "true" github_action_config.auto_describe: "false" # the PR template is the description github_action_config.auto_improve: "false" diff --git a/docs/USAGE.md b/docs/USAGE.md index 5c5e77d..6c13a10 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -216,9 +216,10 @@ jobs: - Tokens act as the `pr-agents` service account and work only in the `pr-cicd` Anthropic workspace, which has its own spend limit. No repository needs an Anthropic secret. -- Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback, adaptive thinking - at high effort. A repository's `.pr_agent.toml` can override them and add - `[pr_reviewer] extra_instructions`. +- The model is Claude Haiku 5.5 with adaptive thinking at medium effort; Sonnet 5.5 + runs only when a Haiku call fails. Reviews are comments, so the small model is + enough. A repository's `.pr_agent.toml` can add `[pr_reviewer] extra_instructions`; + leave the model to this workflow so every repository stays on the same one. - A failed exchange fails the job with Anthropic's error type. The deny reason is in the Claude Console under Workload identity, History. From 1a521f5503109bd2a0e2a1124a1389e305bb0376 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:42:17 -0500 Subject: [PATCH 3/6] Revert "feat(pr-agent): review with Claude Haiku 5.5 at medium effort" PB: keep PR-Agent reviews on Opus 5.5; Haiku was meant for posting comments. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pr-agent.yml | 9 ++++----- docs/USAGE.md | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index b57d00d..2e0581a 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -13,9 +13,8 @@ name: PR-Agent review # No other workflow can mint a token, and fork PRs get no identity token. # # Callers own triggers and concurrency, and must grant `id-token: write`. -# The model is Claude Haiku 5.5 at medium effort (PB, 2026-11-19: reviews are comments, -# so the small model is enough); Sonnet 5.5 runs only when a Haiku call fails. A -# repository's `.pr_agent.toml` can add review instructions. See docs/USAGE.md. +# Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback; a repository's +# `.pr_agent.toml` can override them and add review instructions. See docs/USAGE.md. on: workflow_call: inputs: @@ -87,10 +86,10 @@ jobs: # LiteLLM sends an `sk-ant-oat` token as `Authorization: Bearer`. ANTHROPIC.KEY: ${{ env.ANTHROPIC_WIF_TOKEN }} GITHUB_TOKEN: ${{ github.token }} - CONFIG.MODEL: anthropic/claude-haiku-5-5 + CONFIG.MODEL: anthropic/claude-opus-5-5 CONFIG.FALLBACK_MODELS: '["anthropic/claude-sonnet-5-5"]' CONFIG.ENABLE_CLAUDE_ADAPTIVE_THINKING: "true" - CONFIG.REASONING_EFFORT: medium + CONFIG.REASONING_EFFORT: high github_action_config.auto_review: "true" github_action_config.auto_describe: "false" # the PR template is the description github_action_config.auto_improve: "false" diff --git a/docs/USAGE.md b/docs/USAGE.md index 6c13a10..5c5e77d 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -216,10 +216,9 @@ jobs: - Tokens act as the `pr-agents` service account and work only in the `pr-cicd` Anthropic workspace, which has its own spend limit. No repository needs an Anthropic secret. -- The model is Claude Haiku 5.5 with adaptive thinking at medium effort; Sonnet 5.5 - runs only when a Haiku call fails. Reviews are comments, so the small model is - enough. A repository's `.pr_agent.toml` can add `[pr_reviewer] extra_instructions`; - leave the model to this workflow so every repository stays on the same one. +- Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback, adaptive thinking + at high effort. A repository's `.pr_agent.toml` can override them and add + `[pr_reviewer] extra_instructions`. - A failed exchange fails the job with Anthropic's error type. The deny reason is in the Claude Console under Workload identity, History. From cb672ee45c74b2a1a53a4a2ed43b84c89bff0974 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:43:35 -0500 Subject: [PATCH 4/6] feat(pr-agent): answer /ask and /improve with Claude Haiku 5.5 Reviews (automatic or /review) stay on Opus 5.5 at high effort. The comment commands /ask and /improve use Haiku 5.5 at medium effort (PB, 2026-11-19). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pr-agent.yml | 10 ++++++---- docs/USAGE.md | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index 2e0581a..71febb6 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -13,8 +13,10 @@ name: PR-Agent review # No other workflow can mint a token, and fork PRs get no identity token. # # Callers own triggers and concurrency, and must grant `id-token: write`. -# Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback; a repository's -# `.pr_agent.toml` can override them and add review instructions. See docs/USAGE.md. +# Models (PB, 2026-11-19): reviews, automatic or `/review`, use Claude Opus 5.5 at +# high effort; the `/ask` and `/improve` comment commands use Claude Haiku 5.5 at +# medium effort. Sonnet 5.5 runs only when the chosen model fails. This workflow owns +# the model; a repository's `.pr_agent.toml` adds review instructions. See docs/USAGE.md. on: workflow_call: inputs: @@ -86,10 +88,10 @@ jobs: # LiteLLM sends an `sk-ant-oat` token as `Authorization: Bearer`. ANTHROPIC.KEY: ${{ env.ANTHROPIC_WIF_TOKEN }} GITHUB_TOKEN: ${{ github.token }} - CONFIG.MODEL: anthropic/claude-opus-5-5 + CONFIG.MODEL: ${{ (startsWith(github.event.comment.body, '/ask') || startsWith(github.event.comment.body, '/improve')) && 'anthropic/claude-haiku-5-5' || 'anthropic/claude-opus-5-5' }} CONFIG.FALLBACK_MODELS: '["anthropic/claude-sonnet-5-5"]' CONFIG.ENABLE_CLAUDE_ADAPTIVE_THINKING: "true" - CONFIG.REASONING_EFFORT: high + CONFIG.REASONING_EFFORT: ${{ (startsWith(github.event.comment.body, '/ask') || startsWith(github.event.comment.body, '/improve')) && 'medium' || 'high' }} github_action_config.auto_review: "true" github_action_config.auto_describe: "false" # the PR template is the description github_action_config.auto_improve: "false" diff --git a/docs/USAGE.md b/docs/USAGE.md index 5c5e77d..68e806d 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -20,7 +20,7 @@ jobs: | `security.yml` | Parallel jobs `Secret scan` (gitleaks CLI) and `Dependency audit`. | `secret-scan`, `audit`, `audit-level`, `working-directory`, `runner` | none | | `deploy-cpanel.yml` | Job `Deploy` (cPanel Git pull), then `Verify live` (HTTP 200 and byte compare). | `trigger`, `cpanel-repo`, `branch`, `host` (required), `verify-url`, `live-base-url`, `live-files`, `runner` | `CPANEL_USER`, `CPANEL_PASSWORD` | | `deploy-cloudflare.yml` | Job `Build`, then `Deploy` (wrangler) from the built artifact. Manual release only. | `node-version`, `install`, `build`, `check`, `wrangler-version`, `command`, `runner` | `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID` | -| `pr-agent.yml` | Job `PR-Agent`: AI review of each PR with PR-Agent on Claude, and `/review`, `/improve`, `/ask` comments. No stored key: it exchanges GitHub's identity token for a 15-minute Anthropic token. | `runner`, `timeout-minutes` | none | +| `pr-agent.yml` | Job `PR-Agent`: AI review of each PR with PR-Agent on Claude (Opus 5.5 reviews, Haiku 5.5 for `/ask` and `/improve`), and `/review`, `/improve`, `/ask` comments. No stored key: it exchanges GitHub's identity token for a 15-minute Anthropic token. | `runner`, `timeout-minutes` | none | Rules: - Pin every `uses:` to a full commit SHA. Dependabot keeps the pins in this repository current. @@ -216,9 +216,11 @@ jobs: - Tokens act as the `pr-agents` service account and work only in the `pr-cicd` Anthropic workspace, which has its own spend limit. No repository needs an Anthropic secret. -- Models default to Claude Opus 5.5 with Sonnet 5.5 as fallback, adaptive thinking - at high effort. A repository's `.pr_agent.toml` can override them and add - `[pr_reviewer] extra_instructions`. +- Reviews (automatic, or a `/review` comment) use Claude Opus 5.5 at high effort. + The `/ask` and `/improve` comment commands use Claude Haiku 5.5 at medium effort. + Sonnet 5.5 runs only when the chosen model fails. This workflow owns the model: + a repository's `.pr_agent.toml` adds `[pr_reviewer] extra_instructions` but should + not set `model`, or it would override the split. - A failed exchange fails the job with Anthropic's error type. The deny reason is in the Claude Console under Workload identity, History. From 4723e8688252074754c2af34fbb773358963fe47 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:55:39 -0500 Subject: [PATCH 5/6] fix(pr-agent): pin the image digest, limit commands, require main for tokens Review findings: the action wraps a rolling image tag, so pin the 0.50.0-github_action digest; run only /review, /ask and /improve and skip --config. arguments; document that callers use @main because the federation rule will accept only this workflow at refs/heads/main. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/pr-agent.yml | 27 ++++++++++++++++++++------- docs/USAGE.md | 34 +++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index 71febb6..ac8e517 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -7,16 +7,21 @@ name: PR-Agent review # # The federation rule `pr-agent-org` accepts a token only when all of these hold: # - the repository owner is tilorahdotco (owner id 350058761); -# - the running job is this workflow (`job_workflow_ref`); +# - the running job is this workflow at `refs/heads/main` of this repository +# (`job_workflow_ref`), so a copy on another branch, commit or fork gets nothing; # - the caller file is the repository's `.github/workflows/pr-agent.yml`; # - the event is `pull_request` or `issue_comment`. -# No other workflow can mint a token, and fork PRs get no identity token. +# Callers must therefore use `@main`, not a commit SHA: the one exception to the +# pin rule in docs/USAGE.md. Only organization owners can push to `main` here. +# Fork PR events get no identity token and are skipped below. # # Callers own triggers and concurrency, and must grant `id-token: write`. # Models (PB, 2026-11-19): reviews, automatic or `/review`, use Claude Opus 5.5 at # high effort; the `/ask` and `/improve` comment commands use Claude Haiku 5.5 at # medium effort. Sonnet 5.5 runs only when the chosen model fails. This workflow owns -# the model; a repository's `.pr_agent.toml` adds review instructions. See docs/USAGE.md. +# the model: these settings win over a `model` in a repository's `.pr_agent.toml`, which +only adds review instructions. Other PR-Agent commands and `--config.` arguments in a +comment are not run. See docs/USAGE.md. on: workflow_call: inputs: @@ -31,15 +36,19 @@ on: jobs: review: name: PR-Agent - # PR events from this repository (not forks or drafts), or `/` commands on a PR - # from people with write access to it. + # PR events from this repository (not forks or drafts), or a `/review`, `/ask` or + # `/improve` comment on a PR from people with write access to it. A comment with a + # `--config.` argument is skipped, so nobody changes the model from a comment. if: >- (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft) || (github.event_name == 'issue_comment' && github.event.issue.pull_request - && startsWith(github.event.comment.body, '/') + && (startsWith(github.event.comment.body, '/review') + || startsWith(github.event.comment.body, '/ask') + || startsWith(github.event.comment.body, '/improve')) + && !contains(github.event.comment.body, '--config.') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) runs-on: ${{ inputs.runner }} timeout-minutes: ${{ inputs.timeout-minutes }} @@ -83,7 +92,11 @@ jobs: echo "::add-mask::$token" echo "ANTHROPIC_WIF_TOKEN=$token" >> "$GITHUB_ENV" - name: Run PR-Agent - uses: The-PR-Agent/pr-agent@e673a02076ce09a4726c3d0c3cc85780e59ca52b # v0.50.0 + # PR-Agent v0.50.0, the `0.50.0-github_action` image by digest. The action + # repository only wraps a rolling image tag, so the digest is the real pin + # (PR-Agent SECURITY.md). To upgrade, take the digest of the new + # `-github_action` tag on Docker Hub. + uses: docker://pragent/pr-agent@sha256:548e894a88071180832b2f4233f734d0acd0db1a879e2fcbaa70bac8b8372ebe env: # LiteLLM sends an `sk-ant-oat` token as `Authorization: Bearer`. ANTHROPIC.KEY: ${{ env.ANTHROPIC_WIF_TOKEN }} diff --git a/docs/USAGE.md b/docs/USAGE.md index 68e806d..3020d31 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -23,7 +23,7 @@ jobs: | `pr-agent.yml` | Job `PR-Agent`: AI review of each PR with PR-Agent on Claude (Opus 5.5 reviews, Haiku 5.5 for `/ask` and `/improve`), and `/review`, `/improve`, `/ask` comments. No stored key: it exchanges GitHub's identity token for a 15-minute Anthropic token. | `runner`, `timeout-minutes` | none | Rules: -- Pin every `uses:` to a full commit SHA. Dependabot keeps the pins in this repository current. +- Pin every `uses:` to a full commit SHA. Dependabot keeps the pins in this repository current. The one exception is `pr-agent.yml`, which callers use at `@main` (see PR-Agent review). - Callers own triggers, concurrency and job names. - Public repositories run on GitHub-hosted runners only. - Keep secrets at the organization level, limited to the repositories that use them. @@ -186,9 +186,13 @@ jobs: ## PR-Agent review Copy this caller to `.github/workflows/pr-agent.yml` in the repository. The file -name matters: the Anthropic federation rule accepts tokens only for a caller at -that path, running this workflow, in a `tilorahdotco` repository, on a -`pull_request` or `issue_comment` event. +name and the `@main` reference both matter. The Anthropic federation rule +`pr-agent-org` gives a token only to this workflow at `refs/heads/main` of this +repository, called from a `tilorahdotco` repository's +`.github/workflows/pr-agent.yml`, on a `pull_request` or `issue_comment` event. +This is the one exception to the SHA pin rule above: a copy of the workflow on +another branch, commit or fork gets no token, and a change merged to `main` here +reaches every repository at once. Only organization owners can push to `main`. ```yaml name: PR-Agent review @@ -203,14 +207,19 @@ permissions: issues: write id-token: write # GitHub's identity token, exchanged for a short-lived Anthropic token concurrency: - group: pr-agent-${{ github.event.pull_request.number || github.event.issue.number }} + # Commands from people with write access share one queue per PR. Any other comment + # gets its own group, so it never replaces a queued command. + group: pr-agent-${{ github.event.pull_request.number || github.event.issue.number }}-${{ github.event_name == 'issue_comment' && !(github.event.issue.pull_request && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && (startsWith(github.event.comment.body, '/review') || startsWith(github.event.comment.body, '/ask') || startsWith(github.event.comment.body, '/improve'))) && github.event.comment.id || 'review' }} cancel-in-progress: false jobs: review: name: PR-Agent review - uses: tilorahdotco/.github/.github/workflows/pr-agent.yml@ + # Only PR events and the three commands start a run. The shared workflow checks + # again: drafts, fork PRs, the author's write access and `--config.` arguments. + if: github.event_name == 'pull_request' || (github.event.issue.pull_request && (startsWith(github.event.comment.body, '/review') || startsWith(github.event.comment.body, '/ask') || startsWith(github.event.comment.body, '/improve'))) + uses: tilorahdotco/.github/.github/workflows/pr-agent.yml@main with: - runner: ${{ vars.LIGHT_RUNNER || 'instabox-small' }} # public repositories: ubuntu-latest + runner: instabox-small # public repositories: ubuntu-latest ``` - Tokens act as the `pr-agents` service account and work only in the `pr-cicd` @@ -218,9 +227,12 @@ jobs: Anthropic secret. - Reviews (automatic, or a `/review` comment) use Claude Opus 5.5 at high effort. The `/ask` and `/improve` comment commands use Claude Haiku 5.5 at medium effort. - Sonnet 5.5 runs only when the chosen model fails. This workflow owns the model: - a repository's `.pr_agent.toml` adds `[pr_reviewer] extra_instructions` but should - not set `model`, or it would override the split. + Sonnet 5.5 runs only when the chosen model fails. The workflow's settings win + over a `model` in a repository's `.pr_agent.toml`; use that file for + `[pr_reviewer] extra_instructions`. No other PR-Agent command runs. +- A fork PR gets no automatic review. A maintainer's `/review` comment on it runs + from the default branch and reviews it; PR-Agent reads the diff and runs no PR code. +- The PR-Agent image is pinned by digest in the workflow. Use a runner with Docker: + instabox or GitHub-hosted, not the `cjbb2-ci` fallback runner. - A failed exchange fails the job with Anthropic's error type. The deny reason is in the Claude Console under Workload identity, History. - From 1af456ee600df2d174bf414b42f829d5f3117be9 Mon Sep 17 00:00:00 2001 From: pb <5535435+pekth@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:55:46 -0500 Subject: [PATCH 6/6] fix(pr-agent): restore two comment markers in the workflow header Co-Authored-By: Claude Fable 5.2 --- .github/workflows/pr-agent.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index ac8e517..6191c19 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -20,8 +20,8 @@ name: PR-Agent review # high effort; the `/ask` and `/improve` comment commands use Claude Haiku 5.5 at # medium effort. Sonnet 5.5 runs only when the chosen model fails. This workflow owns # the model: these settings win over a `model` in a repository's `.pr_agent.toml`, which -only adds review instructions. Other PR-Agent commands and `--config.` arguments in a -comment are not run. See docs/USAGE.md. +# only adds review instructions. Other PR-Agent commands and `--config.` arguments in a +# comment are not run. See docs/USAGE.md. on: workflow_call: inputs: