Skip to content

fix(audit): retry LLM calls so transient failures don't drop recommendations - #261

Merged
gkhngyk merged 1 commit into
mainfrom
fix/audit-llm-retry
Jun 16, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/audit-llm-retry

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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 [] / na with 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 both generateObject calls:

  • 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

  • Server-only runtime change — needs a server redeploy to take effect.
  • Pure reliability fix; no schema or API changes.

…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.
@gkhngyk
gkhngyk merged commit d3b2a94 into main Jun 16, 2026
3 checks passed
@gkhngyk
gkhngyk deleted the fix/audit-llm-retry branch June 16, 2026 13:58
@gkhngyk gkhngyk mentioned this pull request Jun 21, 2026
4 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant