Skip to content

fix(review): inject the diff into the prompt instead of having the agent fetch it#7

Merged
vaderyang merged 1 commit into
mainfrom
fix/review-inject-diff
Jun 9, 2026
Merged

fix(review): inject the diff into the prompt instead of having the agent fetch it#7
vaderyang merged 1 commit into
mainfrom
fix/review-inject-diff

Conversation

@vaderyang

Copy link
Copy Markdown
Contributor

Problem

The PR-review agent (vivi) returns COMMENTED on every PR, with a body like:

I'll start by getting the PR diff to understand what changes are being proposed.
<tool_call><tool_name>Bash</tool_name>...gh pr diff N --patch...</tool_call>
<tool_result>diff --git a/VERSION ...

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 ### Summary heading, and post_review.py falls 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 diff tool call:

  • run_review.sh pre-fetches gh pr diff and appends it to the prompt (capped at 800 KB; appended rather than envsubst'd, since a diff can contain ${...} byte sequences envsubst would mangle).
  • prompt.md now 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 always-blocking leakage check, which only needs the diff.

Tests

  • scripts/pr-review/test_post_review.py unchanged → 16 pass.
  • bash -n scripts/pr-review/run_review.sh clean.

After merge, cut a tag and bump the consumer's pr-review.yml pin to pick it up.

🤖 Generated with Claude Code

…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>
@vaderyang
vaderyang merged commit d352c0f into main Jun 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant