fix(review): inject the diff into the prompt instead of having the agent fetch it#7
Merged
Merged
Conversation
…ent fetch it
vivi's review came back COMMENTED on every PR with a body like:
I'll start by getting the PR diff...
<tool_call><tool_name>Bash</tool_name>...gh pr diff N --patch...</tool_call>
<tool_result>diff --git ...
The model backend emits tool calls as *plain text* instead of invoking them
natively, so the agent never actually receives the diff, produces no
`### Summary` heading, and post_review falls back to COMMENTED — leaving every
PR blocked on a review that never really ran.
Make the review backend-agnostic: run_review.sh now pre-fetches the diff and
appends it to the prompt (capped at 800 KB; appended, not via envsubst, which
would mangle `${...}` byte sequences in a diff). prompt.md reviews the inline
diff directly instead of instructing a first `gh pr diff` tool call. Read/Grep
stay available for deeper investigation when native tool-calling works; when it
doesn't, the agent still produces a real review from the diff — including the
critical leakage check, which only needs the diff.
post_review tests unchanged (16 pass); run_review.sh shellcheck/`bash -n` clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PR-review agent (vivi) returns COMMENTED on every PR, with a body like:
The model backend emits tool calls as plain text instead of invoking them natively, so the agent never actually receives the diff, never produces a
### Summaryheading, andpost_review.pyfalls back to COMMENTED with "Agent output was missing required heading." Every PR is then blocked on a review that never really ran.Fix
Make the review backend-agnostic — don't depend on the agent issuing its own
gh pr difftool call:run_review.shpre-fetchesgh pr diffand appends it to the prompt (capped at 800 KB; appended rather thanenvsubst'd, since a diff can contain${...}byte sequences envsubst would mangle).prompt.mdnow reviews the inline diff directly instead of instructing a firstgh pr difftool call.Read/Grepstay available for deeper investigation when native tool-calling works; when it doesn't, the agent still produces a real review from the diff — including the always-blocking leakage check, which only needs the diff.Tests
scripts/pr-review/test_post_review.pyunchanged → 16 pass.bash -n scripts/pr-review/run_review.shclean.After merge, cut a tag and bump the consumer's
pr-review.ymlpin to pick it up.🤖 Generated with Claude Code