## TL;DR

The agent diffed against the merge commit (which includes base-branch changes) instead of the PR head. Summarize the `base...head` diff so the summary covers only what the PR introduces.

## Error

```text
Agent summary describes 12 files; the PR changed 4  -  the other 8 came from the base branch via the merge commit.
```

## Steps

1. Confirm the contamination: compare the summary's file list with the PR's files-changed. Expected: extra files from the base branch.
2. Fix the diff source: use the three-dot `base...head` diff (or the PR's diff API), never the merge commit. Expected: the diff contains only PR changes.
3. Add a validation: every file in the summary must appear in the PR's files-changed list. Expected: contamination is caught before posting.
4. Regenerate the summary. Expected: it describes exactly the PR's changes.

## When to use

- The agent's summary includes changes from the base branch.
- The agent builds its own diff for summarization.

## When not to use

- The summary covers the wrong PR entirely  -  that is a targeting bug.
- The agent uses the PR diff API directly; check which ref it requests.

## Tool compatibility

- Any agent summarizing PRs from git diffs.
- GitHub / GitLab.

## Variant phrasings

### Summary includes reverted commits

Summarize the final head diff, not the commit list  -  reverts cancel out in the diff.

### Merge-queue merge commits

Same fix: the merge commit is never the right summarization input.

## Why it happens

A merge commit's diff against its second parent shows base-branch changes, not the PR's. Summarizing it makes the agent describe code the author never wrote  -  the same failure as reviewing the wrong branch, one step removed.

## Edge cases

- Three-dot diff is the correct input for 'what does this PR change' in almost every review context.
- The validation step (files-changed cross-check) catches this whole bug class for one API call.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_mMCiIrW8l1HvnxWDPRCi8A
