Skip to content
Merged
6 changes: 6 additions & 0 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ jobs:
install_claude
# Best-effort install of fallbacks for duck/fallback support
npm install -g @google/gemini-cli || true
if ! command -v gemini >/dev/null 2>&1; then
echo "::warning::gemini CLI unavailable — Gemini rate-limit fallback will be unavailable"
fi
Comment thread
don-petry marked this conversation as resolved.
Resolved
if ! env GH_TOKEN="$COPILOT_GITHUB_TOKEN" gh copilot --version > /dev/null 2>&1; then
echo "::warning::gh copilot built-in unavailable with user token — rate-limit fallback will be unavailable."
fi
Expand All @@ -216,6 +219,9 @@ jobs:
fi
install_claude || true
npm install -g @google/gemini-cli || true
if ! command -v gemini >/dev/null 2>&1; then
echo "::warning::gemini CLI unavailable — Gemini duck review will be skipped"
fi
Comment thread
don-petry marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
;;
*)
echo "::error::Unknown REVIEW_ENGINE=$REVIEW_ENGINE"
Expand Down
8 changes: 8 additions & 0 deletions docs/pr-review-agent/machine-user-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ Verify:
gh secret list --repo petry-projects/.github-private | grep DON_PETRY_BOT_GH_PAT
```

### Secret naming reference

| Secret | Purpose |
|--------|---------|
| `DON_PETRY_BOT_GH_PAT` | Machine user / bot reviewer PAT. Used by `pr-review.yml`, `repair-pr-approvals.yml`, `daily-pr-review-health.yml`, and `claude.yml` for GitHub API authentication as the bot. |
| `GH_PAT` | User PAT with a Copilot subscription. Exposed as `COPILOT_GITHUB_TOKEN` in `pr-review.yml` for Copilot CLI access. Do **not** store the bot reviewer PAT here. |
Comment thread
don-petry marked this conversation as resolved.
Resolved
| `GOOGLE_API_KEY` | API key for Google AI (Gemini). Used by the `gemini` engine for triage, deep review, and audit tiers. |

## Step 5: Verify the setup

Trigger a one-shot dry-run of the PR review workflow:
Expand Down
56 changes: 31 additions & 25 deletions scripts/engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,49 @@ RETRY_MAX_ATTEMPTS="${RETRY_MAX_ATTEMPTS:-2}" # total attempts including first
RETRY_BASE_DELAY_SEC="${RETRY_BASE_DELAY_SEC:-5}"

set_engine_config() {
# Default Copilot model — ensures the variable is bound for set -u
COPILOT_API_MODEL="${COPILOT_API_MODEL:-gpt-5.4}"

case "$REVIEW_ENGINE" in
claude)
ENGINE_TRIAGE_MODEL="claude-haiku-4-5-20251001"
ENGINE_DEEP_MODEL="claude-sonnet-4-6"
ENGINE_AUDIT_MODEL="claude-opus-4-7"
ENGINE_ACTION_MODEL="claude-sonnet-4-6"
ENGINE_SINGLE_MODEL="claude-opus-4-7"
ENGINE_LABEL="triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.7"
ENGINE_LABEL="triage: haiku 4.5 → deep: sonnet 4.6 + duck: o4-mini → audit: opus 4.7"
ENGINE_SINGLE_LABEL="single-reviewer mode: opus 4.7"
# Cross-engine rubber duck: always the opposite engine
# Cross-engine rubber duck: use Copilot when Claude is primary
DUCK_ENGINE="copilot"
DUCK_MODEL="gpt-5.4"
DUCK_MODEL="o4-mini"
;;
gemini)
ENGINE_TRIAGE_MODEL="auto"
ENGINE_DEEP_MODEL="auto"
ENGINE_AUDIT_MODEL="auto"
ENGINE_ACTION_MODEL="auto"
ENGINE_SINGLE_MODEL="auto"
ENGINE_LABEL="auto (Gemini 2.5/3 balanced)"
ENGINE_SINGLE_LABEL="single-reviewer mode: auto"
ENGINE_TRIAGE_MODEL="gemini-2.0-flash"
ENGINE_DEEP_MODEL="gemini-1.5-pro"
ENGINE_AUDIT_MODEL="gemini-1.5-pro"
ENGINE_ACTION_MODEL="gemini-1.5-pro"
ENGINE_SINGLE_MODEL="gemini-1.5-pro"
ENGINE_LABEL="triage: gemini-2.0-flash → deep: gemini-1.5-pro + duck: sonnet 4.6 → audit: gemini-1.5-pro"
ENGINE_SINGLE_LABEL="single-reviewer mode: gemini-1.5-pro"
# Cross-engine rubber duck: use Claude for diversity
DUCK_ENGINE="claude"
DUCK_MODEL="claude-sonnet-4-6"
;;
copilot)
ENGINE_TRIAGE_MODEL="gpt-5.4"
ENGINE_DEEP_MODEL="gpt-5.4"
ENGINE_AUDIT_MODEL="gpt-5.4"
ENGINE_ACTION_MODEL="gpt-5.4"
ENGINE_SINGLE_MODEL="gpt-5.4"
ENGINE_LABEL="triage: gpt-5.4 → deep: gpt-5.4 + duck: sonnet 4.6 → audit: gpt-5.4 (GitHub Copilot CLI)"
ENGINE_SINGLE_LABEL="single-reviewer mode: gpt-5.4 (GitHub Copilot CLI)"
# Cross-engine rubber duck: use Claude for diversity
DUCK_ENGINE="claude"
DUCK_MODEL="claude-sonnet-4-6"
ENGINE_TRIAGE_MODEL="o4-mini"
ENGINE_DEEP_MODEL="o4-mini"
ENGINE_AUDIT_MODEL="o4-mini"
ENGINE_ACTION_MODEL="o4-mini"
ENGINE_SINGLE_MODEL="o4-mini"
# GitHub Models API model identifier — must match a model available at
# https://models.github.ai (see GitHub Models marketplace).
# Override via COPILOT_API_MODEL env var if the default is unavailable.
# openai/o4-mini is the April-2025 o4-generation reasoning model; it is
# not a typo for o1-mini or gpt-4o-mini.
COPILOT_API_MODEL="${COPILOT_API_MODEL:-openai/o4-mini}"
export COPILOT_API_MODEL
ENGINE_LABEL="triage: o4-mini → deep: o4-mini + duck: gemini-2.0-flash → audit: o4-mini (GitHub Models API)"
ENGINE_SINGLE_LABEL="single-reviewer mode: o4-mini (GitHub Models API)"
# Cross-engine rubber duck: use Gemini when Copilot is primary
DUCK_ENGINE="gemini"
DUCK_MODEL="gemini-2.0-flash"
;;
*)
echo "::error::Unknown REVIEW_ENGINE='$REVIEW_ENGINE' (expected: claude, gemini, or copilot)"
Expand Down Expand Up @@ -296,8 +300,10 @@ sys.exit(1)

# run_duck <prompt_file> <model>
# Cross-engine adversarial "rubber duck" review.
# Always uses a different model family from REVIEW_ENGINE. Output to stdout.
# Strips the opposing engine's credentials to prevent cross-engine leakage.
# DUCK_ENGINE is set by engine.sh init: claude→copilot, gemini→claude, copilot→gemini.
# All three engine branches (claude, gemini, copilot) are reachable — the gemini
# branch executes when REVIEW_ENGINE=copilot (copilot primary → gemini duck).
# Output to stdout. Strips non-selected engine credentials to prevent cross-engine leakage.
run_duck() {
local prompt_file="$1"
local model="$2"
Expand Down
4 changes: 2 additions & 2 deletions scripts/review-batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# PRS_FILE — path to candidate list (default: prs.txt)
# MAX_PRS — stop after this many actual reviews (no-ops don't count)
# CANDIDATE_LIMIT — hard cap on candidates inspected (timeout backstop)
# REVIEW_ENGINE — primary engine (claude|copilot); may be flipped on
# rate-limit fallback
# REVIEW_ENGINE — primary engine (claude|gemini|copilot); may follow
# fallback chain claude -> gemini -> copilot
# GH_TOKEN — workflow auth (set at job level)
#
# Exit:
Expand Down
Loading