Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(review-hog): review independently of other pr comments in flash (#114343)

Julian Bez37d4f62b8566
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.md
index 76b0263af589..e605bbafa95b 100644
--- a/products/review_hog/ARCHITECTURE.md
+++ b/products/review_hog/ARCHITECTURE.md
@@ -258,7 +258,7 @@ flowchart TD
### Single-agent Flash (the Flash default)
A Flash turn runs one of two designs, picked by the fetch activity (`select_review_design`, `reviewer/constants.py`).
-The **single-agent design** (`reviewhog-flash-2-1`) replaces steps 4, 5, and 8 below with parallel Codex sandbox
+The **single-agent design** (`reviewhog-flash-2-2`) replaces steps 4, 5, and 8 below with parallel Codex sandbox
sessions, all on `SINGLE_AGENT_FLASH_ARM` (`gpt-6.1-sol` @ medium) and all returning `SingleAgentReview`:
- **The main session** (`single_agent_review_activity`) reviews the whole PR. Its system prompt is `core.md` (the
@@ -291,8 +291,11 @@ lines from any code that changed since `completed_head_sha` drops as `old_code`
heads' PR snapshots are compared by line content per file, so lines a base merge only moved stay old. P0 and P1
findings, files whose patch GitHub left out, a first review, and a re-run at the reviewed head skip the check. Step 7 then runs as two dedup calls in parallel (`dedupe_flash_findings`,
`tools/single_agent_review.py`), both one-shot OpenAI calls on `FLASH_DEDUP_MODEL` (`gpt-6-luna` @ medium,
-`run_oneshot_openai_review`): the main findings against PR comments and earlier turns, and the lens findings against
-the same plus the main findings as anchors, so a lens finding can lose to a main finding but never the reverse.
+`run_oneshot_openai_review`): the main findings against earlier turns, and the lens findings against the same plus
+the main findings as anchors, so a lens finding can lose to a main finding but never the reverse. PR comments from
+people and other bots join the dedup only when the trigger asks for additional findings
+(`dedupe_against_pr_comments`, off by default), so a review posts what it finds whatever other comments say. In that
+mode the status comment counts the findings skipped because a PR comment already raises them.
Both calls send every finding to the LLM; the pipeline's positional pre-filter does not apply to Flash.
The Flash dedup output (`FlashIssueDeduplication`) names what each duplicate repeats (`duplicate_of`: the finding kept
in its place, an earlier turn's finding by its issue key, or a PR comment id). A finding that survives takes the
@@ -460,7 +463,7 @@ pr_metadata.head_branch` is threaded (as explicit kwargs, alongside `team_id` /
Turn event IDs distinguish Full and Flash, and the single-agent design from the pipeline, while preserving the legacy Full and pipeline Flash IDs across deployments.
Completion-rate calculations match failures and completions by report, turn, and mode; an absent mode means Full for legacy events.
After the skill sync, `record_turn_marker_activity` records the turn's version marker: a version id per review mode
- and design (`reviewhog-flash-2-1`, built by `reviewhog_version_for_mode` from the manual (major, minor) bumps in
+ and design (`reviewhog-flash-2-2`, built by `reviewhog_version_for_mode` from the manual (major, minor) bumps in
`REVIEWHOG_VERSIONS`, `reviewer/constants.py`) plus a 7-character fingerprint (`reviewer/fingerprint.py`).
Full, Flash pipeline, and Flash single agent evolve separately, so each bumps its own version.
The fingerprint hashes the review mode, the review and validator arms, the chunking / dedup / one-shot pins,
diff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.md
index ea32144978c9..5abd75a5c6cb 100644
--- a/products/review_hog/DECISIONS.md
+++ b/products/review_hog/DECISIONS.md
@@ -198,6 +198,21 @@ read `FINAL_REPORT.md` there first (config glossary + coverage matrix + ranking)
rate drops materially (toward ≤50%) on frozen-PR evals with the valid-finding set intact (item 5's
coverage matrix as the guard); kill if valid findings drop with the noise.
+### ✅ BUILT 2026-10-09 — Flash reviews independently of other PR comments (`reviewhog-flash-2-2`)
+
+- **What.** Flash dedup no longer reads the PR's comments, from people or other bots. It still drops repeats of
+ ReviewHog's own earlier findings. A per-trigger switch on the review input, `dedupe_against_pr_comments` (default
+ off), brings the old behavior back for a review that should add only what is not on the PR yet; the status comment
+ then counts the findings it skipped. No setting stores it. The `@posthog review` comment command is the planned way
+ to set it.
+- **Why.** A finding that repeated another bot's comment dropped silently, so the PR showed that bot's P1 next to
+ ReviewHog's "Nothing worth raising" although ReviewHog found the same issue. No vendor we checked dedups against
+ other bots' comments; each dedups only against its own earlier comments. On PostHog PRs, 16% of bot comments repeat
+ another bot's, almost all from bots running in parallel on the same commit, and no bot acknowledged another.
+- **Not chosen.** A reply in the other bot's thread (Greptile answers bot replies about half the time, which starts
+ a bot exchange) and a stored per-user preference (only if someone asks). Full mode keeps its comment dedup for now:
+ its chunker and dedup prompts both read PR comments, so it is a separate change.
+
### ✅ BUILT 2026-10-09 — Flash follow-up turns drop P2 and P3 findings on unchanged code (`reviewhog-flash-2-1`)
- **What.** On a follow-up turn, a P2 or P3 finding that sits more than `FLASH_FOLLOW_UP_CHANGE_MARGIN_LINES` (3)
diff --git a/products/review_hog/backend/reviewer/constants.py b/products/review_hog/backend/reviewer/constants.py
index c1b8a7045923..a17f3d64ccb4 100644
--- a/products/review_hog/backend/reviewer/constants.py
+++ b/products/review_hog/backend/reviewer/constants.py
@@ -114,12 +114,12 @@ def select_review_design(review_mode: str, *, kill_switch_on: bool) -> ReviewDes
REVIEWHOG_VERSIONS: dict[tuple[str, str], tuple[int, int]] = {
(REVIEW_MODE_FULL, REVIEW_DESIGN_PIPELINE): (1, 2),
(REVIEW_MODE_FLASH, REVIEW_DESIGN_PIPELINE): (1, 2),
- (REVIEW_MODE_FLASH, REVIEW_DESIGN_SINGLE_AGENT): (2, 1),
+ (REVIEW_MODE_FLASH, REVIEW_DESIGN_SINGLE_AGENT): (2, 2),
}
def reviewhog_version_for_mode(review_mode: str, review_design: str = REVIEW_DESIGN_PIPELINE) -> str:
- """The version id a turn of this mode and design reports, like a model id: `reviewhog-flash-2-1`."""
+ """The version id a turn of this mode and design reports, like a model id: `reviewhog-flash-2-2`."""
major, minor = REVIEWHOG_VERSIONS[(review_mode, review_design)]
return f"reviewhog-{review_mode}-{major}-{minor}"
diff --git a/products/review_hog/backend/reviewer/status_comment.py b/products/review_hog/backend/reviewer/status_comment.py
index 7d8c7d33e636..74d510852d89 100644
--- a/products/review_hog/backend/reviewer/status_comment.py
+++ b/products/review_hog/backend/reviewer/status_comment.py
@@ -229,6 +229,7 @@ def render_final_body(
celebrate_clean_reviews: bool = True,
marker: ReviewHogMarker | None = None,
capped_lens_parts: int | None = None,
+ already_raised: int = 0,
) -> str:
"""The completed-state body: the full found counts, and how many the threshold held back.
@@ -238,7 +239,8 @@ def render_final_body(
and links to the report in PostHog (`report_url`, auth-gated) — the PR is otherwise the only
place the author hears about held-back findings, so the comment must not dead-end.
`capped_lens_parts` is set when a single-agent turn reviewed a PR past the lens part cap. The
- note goes here and not in the review body, because a clean turn posts no review.
+ note goes here and not in the review body, because a clean turn posts no review. `already_raised`
+ counts the findings a review asked for additional findings skipped because a PR comment raises them.
"""
found_total = sum(counts.values())
found_line = "Found " + ", ".join(
@@ -285,6 +287,13 @@ def render_final_body(
f"This pull request is large, so the review ran in {capped_lens_parts} parts with less depth than usual.",
]
)
+ if already_raised > 0:
+ lines.extend(
+ [
+ "",
+ f"Skipped {_plural(already_raised, 'finding')} that other comments on this pull request already raise.",
+ ]
+ )
lines.extend(["", status_marker(report_id)])
if marker is not None:
lines.append(marker.hidden_comment())
@@ -583,6 +592,7 @@ class FinalizeStatusCommentInput:
celebrate_clean_reviews: bool = True
marker: ReviewHogMarker | None = None
capped_lens_parts: int | None = None
+ already_raised: int = 0
def finalize_status_comment(input: FinalizeStatusCommentInput) -> None:
@@ -613,6 +623,7 @@ def finalize_status_comment(input: FinalizeStatusCommentInput) -> None:
celebrate_clean_reviews=input.celebrate_clean_reviews,
marker=input.marker,
capped_lens_parts=input.capped_lens_parts,
+ already_raised=input.already_raised,
)
_edit_and_stamp(input.team_id, report, body)
except Exception:
diff --git a/products/review_hog/backend/reviewer/tests/test_single_agent_review.py b/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
index ce4046f7c4c7..6744d7fd9c08 100644
--- a/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
+++ b/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
@@ -247,6 +247,7 @@ class TestDedupeFlashFindings:
prior_findings: list[ReviewIssueFinding] | None = None,
pr_comments: list[PRComment] | None = None,
changed_since: ChangedSinceReview | None = None,
+ against_pr_comments: bool = False,
) -> FlashSelection:
with patch(f"{_DEDUP_MODULE}.run_oneshot_openai_review", mock_llm):
return await dedupe_flash_findings(
@@ -260,6 +261,7 @@ class TestDedupeFlashFindings:
repository="o/r",
lens_part_count=1,
changed_since=changed_since,
+ against_pr_comments=against_pr_comments,
)
@pytest.mark.asyncio
@@ -393,7 +395,9 @@ class TestDedupeFlashFindings:
comment = PRComment(id=77, path="a.py", line=10, body="x", diff_hunk="", user="reviewer", created_at="c")
mock_llm = _flash_dedup(("2002-1-1", named))
- selection = await self._dedupe(pr_metadata, issues, mock_llm, prior_findings=[prior], pr_comments=[comment])
+ selection = await self._dedupe(
+ pr_metadata, issues, mock_llm, prior_findings=[prior], pr_comments=[comment], against_pr_comments=True
+ )
[drop] = selection.dropped
recorded = drop.duplicate_of.id if isinstance(drop.duplicate_of, Issue) else drop.duplicate_of
@@ -401,6 +405,33 @@ class TestDedupeFlashFindings:
# The dedup can only name an earlier finding it was shown with its key.
assert all(_PRIOR_KEY in call.kwargs["prompt"] for call in mock_llm.call_args_list)
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize(
+ "against_pr_comments,posts",
+ [
+ pytest.param(False, True, id="independent_review_posts_what_a_comment_already_says"),
+ pytest.param(True, False, id="additional_review_skips_it"),
+ ],
+ )
+ async def test_pr_comments_count_as_earlier_findings_only_when_asked(
+ self, pr_metadata: PRMetadata, against_pr_comments: bool, posts: bool
+ ) -> None:
+ # By default a review reports what it finds, so a finding another reviewer already posted must still
+ # post. Only a review asked for additional findings skips what a PR comment already raises.
+ comment = PRComment(id=77, path="a.py", line=10, body="x", diff_hunk="", user="other-bot", created_at="c")
+ mock_llm = _flash_dedup(("2000-1-1", "77"))
+
+ selection = await self._dedupe(
+ pr_metadata,
+ [_issue("2000-1-1", IssuePriority.SHOULD_FIX)],
+ mock_llm,
+ pr_comments=[comment],
+ against_pr_comments=against_pr_comments,
+ )
+
+ assert [issue.id for issue in selection.kept] == (["2000-1-1"] if posts else [])
+ assert all(("77" in call.kwargs["prompt"]) is against_pr_comments for call in mock_llm.call_args_list)
+
@pytest.mark.asyncio
@pytest.mark.parametrize(
"llm_duplicates,expected_kept,expected_drops",
diff --git a/products/review_hog/backend/reviewer/tools/single_agent_review.py b/products/review_hog/backend/reviewer/tools/single_agent_review.py
index b71dbef7979e..865dee66f87f 100644
--- a/products/review_hog/backend/reviewer/tools/single_agent_review.py
+++ b/products/review_hog/backend/reviewer/tools/single_agent_review.py
@@ -605,10 +605,12 @@ async def dedupe_flash_findings(
workflow_id_prefix: str | None = None,
fall_back_on_any_error: bool = False,
changed_since: ChangedSinceReview | None = None,
+ against_pr_comments: bool = False,
) -> FlashSelection:
"""Deduplicate a single-agent turn's main and lens findings, then keep the few it posts.
- Two dedup calls run in parallel. The main findings dedup against PR comments and earlier turns.
+ Two dedup calls run in parallel. The main findings dedup against earlier turns, and against PR comments
+ only with `against_pr_comments`: by default a review posts what it finds whatever other comments say.
The lens findings dedup against those too and against the main findings as anchors, so a lens
finding can lose to a main finding but never the other way around. A removal holds only when what
it repeats survives (`_resolve_duplicates`). A finding that survives takes the priority of the most
@@ -616,6 +618,8 @@ async def dedupe_flash_findings(
call fall back to the positional pre-filter on any failure, for the activity's last attempt.
On a follow-up turn, `changed_since` drops the P2 and P3 findings on unchanged code before dedup.
"""
+ if not against_pr_comments:
+ pr_comments = []
old_code = _old_code_findings(issues, changed_since)
old_code_ids = {issue.id for issue in old_code}
reviewed = [issue for issue in issues if issue.id not in old_code_ids]
diff --git a/products/review_hog/backend/temporal/activities.py b/products/review_hog/backend/temporal/activities.py
index e9bea4c0db67..8612f86d11ea 100644
--- a/products/review_hog/backend/temporal/activities.py
+++ b/products/review_hog/backend/temporal/activities.py
@@ -339,6 +339,7 @@ class SandboxStageInput:
review_mode: str = field(default=REVIEW_MODE_FULL, kw_only=True)
flash_reasoning_effort: str = field(default=ReasoningEffort.MEDIUM.value, kw_only=True)
review_design: str = field(default=REVIEW_DESIGN_PIPELINE, kw_only=True)
+ dedupe_against_pr_comments: bool = field(default=False, kw_only=True)
@dataclass
@@ -1486,6 +1487,7 @@ async def dedup_activity(input: SandboxStageInput) -> DedupResult:
workflow_id_prefix=_sandbox_workflow_id_prefix("dedup"),
fall_back_on_any_error=_is_final_attempt(),
changed_since=changed_since,
+ against_pr_comments=input.dedupe_against_pr_comments,
)
survivors = flash_selection.kept
flash_stats = flash_turn_stats(issues, flash_selection, reviewable_lines=lens_plan.reviewable_lines)
diff --git a/products/review_hog/backend/temporal/scheduling.py b/products/review_hog/backend/temporal/scheduling.py
index 095e85376c70..3142bd0b3431 100644
--- a/products/review_hog/backend/temporal/scheduling.py
+++ b/products/review_hog/backend/temporal/scheduling.py
@@ -38,6 +38,7 @@ class ReviewRequestQueue:
and request.publish == self.active.publish
and request.acting_user_id == self.active.acting_user_id
and request.resolve_comments == self.active.resolve_comments
+ and request.dedupe_against_pr_comments == self.active.dedupe_against_pr_comments
and (request.trigger_source == TRIGGER_AUTOMATIC) == (self.active.trigger_source == TRIGGER_AUTOMATIC)
):
return
diff --git a/products/review_hog/backend/temporal/types.py b/products/review_hog/backend/temporal/types.py
index 1d1aadbc03fe..b3ad67ecf3df 100644
--- a/products/review_hog/backend/temporal/types.py
+++ b/products/review_hog/backend/temporal/types.py
@@ -74,6 +74,9 @@ class ReviewPRWorkflowInputs:
# payloads from before the field still deserialize as full reviews.
review_mode: str = REVIEW_MODE_FULL
requested_head_sha: str | None = None
+ # Off by default, so a review posts what it finds whatever other comments on the PR say. A trigger that
+ # asks for only the findings not on the PR yet turns it on.
+ dedupe_against_pr_comments: bool = False
@property
def repository(self) -> str:
diff --git a/products/review_hog/backend/temporal/workflow.py b/products/review_hog/backend/temporal/workflow.py
index 8502e56af1af..2722d4cc10b4 100644
--- a/products/review_hog/backend/temporal/workflow.py
+++ b/products/review_hog/backend/temporal/workflow.py
@@ -686,6 +686,7 @@ class ReviewPRWorkflow:
review_mode=inputs.review_mode,
flash_reasoning_effort=acting.flash_reasoning_effort,
review_design=review_design,
+ dedupe_against_pr_comments=inputs.dedupe_against_pr_comments,
)
if review_design == REVIEW_DESIGN_SINGLE_AGENT:
@@ -860,6 +861,11 @@ class ReviewPRWorkflow:
celebrate_clean_reviews=acting.celebrate_clean_reviews,
marker=marker,
capped_lens_parts=meta.lens_chunk_count if meta.lens_chunks_capped else None,
+ already_raised=(
+ dedup.flash_stats.dropped.get("dedup_comment", 0)
+ if dedup is not None and dedup.flash_stats is not None
+ else 0
+ ),
),
start_to_close_timeout=_QUICK_TIMEOUT,
retry_policy=_RETRY,
diff --git a/products/review_hog/backend/tests/test_constants.py b/products/review_hog/backend/tests/test_constants.py
index 2d2bf3a782b0..f34286f62e7f 100644
--- a/products/review_hog/backend/tests/test_constants.py
+++ b/products/review_hog/backend/tests/test_constants.py
@@ -71,7 +71,7 @@ class TestSelectReviewDesign:
@parameterized.expand(
[
# Dashboards split Flash by version, so a v2 turn must never report the v1 id or the reverse.
- ("flash_single_agent", REVIEW_MODE_FLASH, REVIEW_DESIGN_SINGLE_AGENT, "reviewhog-flash-2-1"),
+ ("flash_single_agent", REVIEW_MODE_FLASH, REVIEW_DESIGN_SINGLE_AGENT, "reviewhog-flash-2-2"),
("flash_pipeline", REVIEW_MODE_FLASH, REVIEW_DESIGN_PIPELINE, "reviewhog-flash-1-2"),
("full_pipeline", REVIEW_MODE_FULL, REVIEW_DESIGN_PIPELINE, "reviewhog-full-1-2"),
]
diff --git a/products/review_hog/backend/tests/test_fingerprint.py b/products/review_hog/backend/tests/test_fingerprint.py
index 8fc2efafa44d..5786b7de56a3 100644
--- a/products/review_hog/backend/tests/test_fingerprint.py
+++ b/products/review_hog/backend/tests/test_fingerprint.py
@@ -100,7 +100,7 @@ class TestRecordTurnMarker(BaseTest):
self._edit_single_agent_prompt(f"{prompt_name}.md")
changed = self._record_single_agent(run_index=2)
- assert original.version == "reviewhog-flash-2-1"
+ assert original.version == "reviewhog-flash-2-2"
assert changed.fingerprint != original.fingerprint
@parameterized.expand(
diff --git a/products/review_hog/backend/tests/test_review_scheduling.py b/products/review_hog/backend/tests/test_review_scheduling.py
index 9cf3a27c6d69..f7b3944af22b 100644
--- a/products/review_hog/backend/tests/test_review_scheduling.py
+++ b/products/review_hog/backend/tests/test_review_scheduling.py
@@ -141,9 +141,12 @@ async def test_automatic_review_waits_for_resolution_before_starting() -> None:
assert probes == 2
[email protected]("resolve_comments,expect_pending", [(False, False), (None, True)])
-def test_a_repeated_full_request_waits_when_it_changes_comment_resolution(
- resolve_comments: bool | None, expect_pending: bool
+ "resolve_comments,dedupe_against_pr_comments,expect_pending",
+ [(False, False, False), (None, False, True), (False, True, True)],
+)
+def test_a_repeated_request_waits_when_it_changes_what_the_review_does(
+ resolve_comments: bool | None, dedupe_against_pr_comments: bool, expect_pending: bool
) -> None:
active = ReviewPRWorkflowInputs(
team_id=1,
@@ -158,7 +161,7 @@ def test_a_repeated_full_request_waits_when_it_changes_comment_resolution(
acting_user_id=1,
resolve_comments=False,
)
- request = replace(active, resolve_comments=resolve_comments)
+ request = replace(active, resolve_comments=resolve_comments, dedupe_against_pr_comments=dedupe_against_pr_comments)
queue = ReviewRequestQueue(active=active)
queue.add(request)
diff --git a/products/review_hog/backend/tests/test_status_comment.py b/products/review_hog/backend/tests/test_status_comment.py
index d6f2895b299d..82fa15c4ae96 100644
--- a/products/review_hog/backend/tests/test_status_comment.py
+++ b/products/review_hog/backend/tests/test_status_comment.py
@@ -241,14 +241,21 @@ class TestRenderFinalBody:
@parameterized.expand(
[
- # A clean turn posts no review, so the status comment is the only place the note can appear.
- ("clean_large_pr", 0, 4, True),
- ("large_pr_with_findings", 2, 4, True),
- ("normal_pr", 2, None, False),
+ # A clean turn posts no review, so the status comment is the only place a note can appear.
+ ("clean_large_pr", 0, 4, 0, True, False),
+ ("large_pr_with_findings", 2, 4, 0, True, False),
+ ("normal_pr", 2, None, 0, False, False),
+ ("clean_additional_review", 0, None, 2, False, True),
]
)
- def test_large_pr_note_shows_whether_or_not_a_review_posts(
- self, _name: str, must_fix: int, capped_lens_parts: int | None, expect_note: bool
+ def test_turn_notes_show_whether_or_not_a_review_posts(
+ self,
+ _name: str,
+ must_fix: int,
+ capped_lens_parts: int | None,
+ already_raised: int,
+ expect_large_note: bool,
+ expect_skipped_note: bool,
) -> None:
body = render_final_body(
"rid",
@@ -259,10 +266,12 @@ class TestRenderFinalBody:
review_url=None,
review_mode=REVIEW_MODE_FLASH,
capped_lens_parts=capped_lens_parts,
+ already_raised=already_raised,
)
- note = "This pull request is large, so the review ran in 4 parts with less depth than usual."
- assert (note in body) is expect_note
+ large_note = "This pull request is large, so the review ran in 4 parts with less depth than usual."
+ skipped_note = "Skipped 2 findings that other comments on this pull request already raise."
+ assert ((large_note in body), (skipped_note in body)) == (expect_large_note, expect_skipped_note)
def _pr_metadata(pr_number: int = 123) -> PRMetadata: