Repository navigation
fix(audit): retry LLM calls so transient failures don't drop recommendations - #261
Merged
Merged
Conversation
…als/recommendations A transient provider error (rate limit, blip, occasional malformed structured-output response) on the recommendations or LLM-signals call was caught and turned into [] / 'na' with no retry — silently producing an audit with no AI recommendations. Wrap both generateObject calls in a small withRetry helper (3 attempts, exponential backoff) so a single hiccup no longer drops a whole audit's LLM output.
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
A Site Audit can complete with no AI recommendations even when there are plenty of fixable failing signals. Root cause: a transient provider error (rate limit, a blip, or the occasional malformed structured-output response) on the recommendations call — or the LLM-signals call — was caught and turned into
[]/nawith no retry, silently dropping that part of the audit.Confirmed in practice: one stored audit had 9 recommendable failing signals but
recommendations: []; re-running the exact same page produced recommendations fine — i.e. the original run hit a one-off failure.Fix
Add a small
withRetry(fn, { attempts, baseDelayMs })helper (3 attempts, exponential backoff) and wrap bothgenerateObjectcalls:evaluateLlmSignals(the 13 LLM-judged signals)generateRecommendations(the AI fix recommendations)A single transient hiccup now retries instead of silently dropping the whole call's output. The outer fallback (
na/[]) still applies only after all attempts are exhausted.Tests
Adds 3 unit tests for
withRetry(first-try success, retry-then-succeed, throw-after-exhaustion). Full server suite green (93 tests).Notes