: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(review_hog): space one-shot LLM retries across overload spells (#71825)
Alex Lebedevca8c362d3805
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex 388c2058eb79..64720e44597e 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -265,6 +265,22 @@ 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'scoverage matrix as the guard); kill if valid findings drop with the noise.+### ✅ BUILT 2026-07-17 — one-shot LLM stages retry across provider overload spells++First cross-repo dogfood run (a `PostHog/billing` PR via the Stage 5c UI trigger) died in dedup on+Anthropic 529s — nothing repo-specific: the review wave completed 9/9, then all four dedup attempts+(2 activity attempts × 2 parent-workflow retries, ~40s apart) landed inside the same overload spell+and the run failed within 2 minutes flat. The same spell had hit chunking ~17 minutes earlier and+recovered on its immediate retry, so overload is intermittent-but-minutes-long — the failure mode is+retry _spacing_, not retry _count_. Fix: the fatal one-shot LLM stages (chunking, selection, dedup)+now run under `_ONESHOT_RETRY` (5 attempts, 30s initial, ×2 backoff capped at 4m — ~7.5m of waits+per run, ~2× with the parent retry) instead of `_RETRY`'s two back-to-back attempts. Failed 529+attempts are free (the call aborts before persistence) and the non-retryable classes (4xx,+max_tokens truncation) still fail fast. The gateway's Bedrock fallback was NOT the lever: it's+deliberately off for one-shot calls, whose `output_config` (effort pin + schema constraint) the+Bedrock path would silently strip. Sandbox-stage units keep `_RETRY` — their overload exposure is+absorbed by the best-effort fan-out + failure floor, not by a single fatal call.+### ✅ BUILT 2026-07-16 — inline finding comments: colored severity badges replace the text metaThe inline comment `_format_issue_comment` builds (`publish_review.py`) had its meta line recolored after comparing it against Greptile's PR comments — a deliberately minimal change that leaves the four collapsed sections (`Issue description`, `Suggested fix`, `Why we think it's a valid issue`, `Prompt to fix with AI`) exactly as they were.diff --git a/products/review_hog/backend/temporal/workflow.py b/products/review_hog/backend/temporal/workflow.pyindex e2d078953f64..e8ee653af6ca 100644--- a/products/review_hog/backend/temporal/workflow.py+++ b/products/review_hog/backend/temporal/workflow.py@@ -88,6 +88,18 @@ _FETCH_TIMEOUT = timedelta(minutes=5)_RETRY = RetryPolicy(maximum_attempts=2)# The validate activity's final-attempt fallback keys off the same constant — don't let them drift._VALIDATE_RETRY = RetryPolicy(maximum_attempts=VALIDATION_MAX_ATTEMPTS)+# The one-shot LLM stages (chunking, selection, dedup): provider overload (529) spells last+# minutes, so back-to-back attempts all land inside the same spell and the run dies in ~2 minutes+# flat (observed). Spaced escalating attempts ride the spell out — waits total ~7.5m per run, ~2×+# that with the parent retry. Overload-failed attempts are cheap (the provider call dies before+# anything persists; a rare failure after persistence redoes the LLM call, superseded latest-wins+# per issue_key). Non-retryable failures (4xx, max_tokens truncation) still fail fast.+_ONESHOT_RETRY = RetryPolicy(+ maximum_attempts=5,+ initial_interval=timedelta(seconds=30),+ backoff_coefficient=2.0,+ maximum_interval=timedelta(minutes=4),+)def _enforce_failure_floor(stage: str, failed: int, total: int) -> None:@@ -162,7 +174,7 @@ class ReviewPerspectivesWorkflow:),start_to_close_timeout=_SANDBOX_TIMEOUT,heartbeat_timeout=_SANDBOX_HEARTBEAT,- retry_policy=_RETRY,+ retry_policy=_ONESHOT_RETRY,)except ActivityError:# Selection is an optimization; failing it must never cost the review.@@ -471,7 +483,7 @@ class ReviewPRWorkflow:stage,start_to_close_timeout=_SANDBOX_TIMEOUT,heartbeat_timeout=_SANDBOX_HEARTBEAT,- retry_policy=_RETRY,+ retry_policy=_ONESHOT_RETRY,)parent_id = workflow.info().workflow_id@@ -502,7 +514,7 @@ class ReviewPRWorkflow:stage,start_to_close_timeout=_SANDBOX_TIMEOUT,heartbeat_timeout=_SANDBOX_HEARTBEAT,- retry_policy=_RETRY,+ retry_policy=_ONESHOT_RETRY,)workflow.logger.info(f"Persisted {len(dedup.issue_ids)} finding(s) to the review report")