Semantic dedup: show the model its own earlier findings instead of relying on text hashes
Feature request
Give /review and /improve the findings the bot already posted on this PR/MR, with their thread status, and let the model skip what it has already said.
Today cross-run dedup is purely lexical (pr_agent/algo/inline_comment_dedup.py, from #2037):
- inline suggestions: SHA-256 over (file, anchor line, first 80 normalised chars), OR-matched with a hash of the ```suggestion block; opt-in via
config.persistent_inline_comments(defaultfalse) - key issues: SHA-256 over (file, exact body), no normalisation at all
The model never sees what it said before. The "Previous suggestions" history in /improve is display-only.
Proposal:
- Collect the bot's earlier findings from the existing read-back methods (
get_persistent_comment_bodies, which is already required bycan_verify_inline_comment_publication). For each one, record the file, the line range, the text, and whether its thread is open, resolved by the bot (outdated/fixed), or resolved by a human. - Inject them into the review / improve prompts as a bounded
previous_findingsblock, under a token budget similar torepo_context_max_lines. - Add a prompt rule: do not re-raise a finding that is already open, or that a human resolved, unless the new diff makes it materially worse. Report only new issues or issues whose earlier fix did not hold.
- Keep the hash markers as a cheap safety net after the model call.
Opt-in setting, e.g. pr_reviewer.previous_findings_context = true (and the pr_code_suggestions equivalent). No new infrastructure: everything comes from notes the provider can already list.
Motivation
On every push the bot re-posts findings it already made, because the hash changes whenever:
- the model rewords the finding, which an LLM does on nearly every run
- the push shifts lines, so the anchor line changes (
resolve_outdated_inline_threadscloses the old thread and a new, identical one appears) - a human resolved the thread as "won't fix": the next run, with different wording, brings it back
Reviewers learn to ignore the bot once it repeats itself. /review -i reduces repetition but loses the full-PR context, so it does not replace this.
Seen with pr-agent 0.46.0 on self-managed GitLab CI, running describe review on every MR pipeline.
Happy to open a PR if this approach sounds right.
Source: The-PR-Agent/pr-agent