Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions scripts/pr-review/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ When you see code that smells like one of these, call it out as

## Method — do exactly this, in this order

1. **Get the diff**: `gh pr diff ${PR_NUMBER} --patch`. Skim once
for shape (size, languages touched).
1. **Read the diff** — it is pre-fetched and included at the END of
this prompt; no tool call is needed to get it. Skim once for shape
(size, languages touched). (If it was truncated for size, fetch the
rest yourself with `gh pr diff ${PR_NUMBER} --patch`.)

2. **For each changed file** (cap at 25 if there are more — list the
skipped in your output):
Expand Down Expand Up @@ -149,5 +151,6 @@ explicit recommendation: APPROVE / COMMENT / REQUEST_CHANGES.
- **Cap your investigation**: ≤ 60 turns. If you hit the cap, dump
what you have — partial reviews are still useful.

Now start. Your first tool call should be `Bash: gh pr diff
${PR_NUMBER} --patch`.
Now start. The full diff is included at the end of this prompt — review
it directly; use Read / Grep on the changed files for the deeper checks
above. Your output must begin with `### Summary`.
19 changes: 19 additions & 0 deletions scripts/pr-review/run_review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ BASE_REF="$(gh pr view "$PR_NUMBER" --json baseRefName --jq .baseRefName)"
export PR_NUMBER HEAD_SHA BASE_REF
envsubst < "$WORKDIR/prompt.md" > "$PROMPT"

# Pre-fetch the diff and inject it into the prompt. The review must NOT depend
# on the agent issuing its own `gh pr diff` tool call: some model backends emit
# tool calls as plain text (`<tool_call>…`) instead of invoking them natively,
# so the agent never actually receives the diff and produces an empty,
# heading-less review that falls back to COMMENTED on every PR. Injecting the
# diff up front makes the review backend-agnostic — the agent can review
# directly, and Read/Grep stay available for deeper investigation when native
# tool-calling does work. Appended (not via envsubst) because a diff can contain
# `${…}` byte sequences envsubst would mangle; capped so a huge PR can't blow
# the context window (the agent can fetch more itself when tool-calling works).
{
echo
echo '## The diff under review (pre-fetched — review this directly)'
echo
echo '```diff'
gh pr diff "$PR_NUMBER" --patch 2>/dev/null | head -c 800000
echo '```'
} >> "$PROMPT"

# Source the harness adapter — it sources litellm-wait.sh and owns the gateway
# pre-flight wait + the retry-on-gateway-down loop. The CLI is the consumer's
# .agent-ops.json harness.kind (default: claude).
Expand Down
Loading