fix(review): short-circuit the retry loop on a deliberate INCOHERENT_DIFF_ASSESSMENT bail - #7520
Merged
Merged
Conversation
…DIFF_ASSESSMENT bail (#7518) parseModelReview collapses a model's deliberate INCOHERENT_DIFF_ASSESSMENT bail (its prompt instructs it to emit this exact text rather than rubber-stamp a diff it can't map to the PR) into the same null as a genuine parse failure -- correct for its own contract, since neither yields a usable review. But the retry loop didn't distinguish the two, so it burned the full 3-attempt-per-model budget (6 attempts across primary + fallback) re-asking the same model the same question before giving up (Sentry: ai_review_inconclusive / ai_review_provider_unparseable_exhausted, LOOPOVER-1P/2B/29). Adds isIncoherentDiffBail, a small standalone check mirroring parseModelReview's own JSON extraction (so it can never disagree with what that function actually parsed), and short-circuits runWorkersOpinion's retry loop on it -- same reasoning as the existing CLI-timeout/429/ structural-config breaks: the model's answer about THIS diff is deliberate and won't change on a same-model retry, but the fallback model still gets its own full budget since it may reach a different verdict. Closes #7518
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7520 +/- ##
==========================================
- Coverage 88.48% 88.46% -0.02%
==========================================
Files 720 720
Lines 75718 75725 +7
Branches 22540 22543 +3
==========================================
- Hits 66997 66993 -4
- Misses 7677 7684 +7
- Partials 1044 1048 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ai_review_inconclusiveandai_review_provider_unparseable_exhaustederrors have been recurring (Sentry LOOPOVER-1P/2B/29). One observed case shows the model returning a clean, well-formed response with"assessment": "Cannot review — the diff appears out of sync with the PR head.", "blockers": [], "nits": [], "suggestions": []— the model's own deliberateINCOHERENT_DIFF_ASSESSMENTbail (its prompt explicitly instructs it to emit this exact text rather than rubber-stamp a diff it can't map to the PR).parseModelReviewcorrectly treats this the same as a genuine parse failure (null, since neither yields a usable review) — but the retry loop doesn't distinguish the two, so it burns the full 3-attempt-per-model retry budget (6 attempts across primary + fallback) re-asking the same model the same question before giving up.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Closes #7518
Validation
git diff --checknpm run typechecknpm run test:coveragelocally — 3 new tests intest/unit/ai-review.test.ts: the retry loop stops after one bail (fallback still gets its own full budget), both models bailing exhausts in 2 attempts total (not 6), and a dedicated unit test for the newisIncoherentDiffBailhelper covering the JSON-shape edge cases (no JSON object, malformed JSON hitting the parse catch, a non-stringassessment, a look-alike-but-different assessment). New code is 100% covered (verified via targeted per-line coverage analysis); fullai-review.test.ts(204 tests) passes.npm run branding-drift:checkIf any required check was skipped, explain why:
Safety
UI Evidencesection. (N/A.)Notes
isIncoherentDiffBailhelper is a small, standalone check that mirrorsparseModelReview's own JSON extraction rather than changing that function's return contract — keeps the change localized to the one retry loop that actually wastes attempts on this (a second, single-shot call site toparseModelReviewhas no retry budget to save, so it's untouched).