Skip to content

Onboarding: retry LLM suggestion calls, then fall back to manual entry when they fail #379

Closed

Description

@gkhngyk

Problem

The LLM-backed onboarding steps make a single round-trip with no retry, so one transient failure drops the whole step. A user hit this on the Competitors step recently — the model returned nothing and they were left with an empty list and a bare error toast.

Three steps call the LLM:

  • Topics — server/src/routes/topics.js (generateText + generateObject)
  • Prompts — server/src/routes/prompts.js (generateObject)
  • Competitors — server/src/routes/competitors.js (two-phase: generateText with search grounding → generateObject, schema .min(3).max(10))

None are wrapped in a retry. The AI SDK's built-in maxRetries only covers provider-classified transient errors (429/5xx/network) — it does not retry a schema-validation miss (e.g. the model returns fewer than 3 competitors) or a NoObjectGeneratedError. Those throw immediately, the route returns 500, and the frontend (web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx) just shows a toast with an empty suggestion list.

This is made worse by #377/#378: the Competitors CTA is now disabled until at least one competitor exists, so a failed suggestion hard-blocks the step unless the user manually types one — with no clear prompt telling them to.

Desired behavior

Server (retry):

  • Wrap the LLM calls in the three onboarding routes with a bounded retry (3 attempts, exponential backoff). A shared helper already exists at server/src/lib/audit/retry.js (withRetry(fn, { attempts, baseDelayMs })) — promote it to a shared location (e.g. server/src/lib/retry.js) and reuse it.
  • For Competitors, wrap the whole two-phase op so a Phase-2 schema miss (< 3 results / malformed object) also re-runs, not just Phase 1.
  • After 3 failed attempts, return the error as today (500 with a clear message).

Frontend (graceful fallback):

  • When suggestions fail after the server has exhausted its retries, do not leave the user stuck. Replace the bare error toast with an inline message on the step, e.g. "Couldn't fetch suggestions right now — add your own below."
  • Keep the manual add path fully usable in that state (it already exists for competitors; make sure the empty-suggestion + disabled-CTA combo still lets the user add manually and continue).

Acceptance criteria

  • Each onboarding LLM call retries up to 3 times with backoff before failing.
  • A single transient LLM failure (429/5xx/timeout/empty or under-count structured output) is recovered automatically without the user noticing.
  • After 3 genuine failures, the step shows a clear "add your own" message and the manual-entry form remains usable — the user can finish onboarding without suggestions.
  • The shared retry helper is used by all three routes (no duplicated retry logic).

Notes

  • Do not retry our own input-validation 400s (e.g. missing brandName) — those return before the LLM call and are correct as-is.
  • Presentation/reliability only; no change to what the suggestions contain when they succeed.

Activity

  1. added
    enhancement
    on Jul 9, 2026
  2. Sam-syntax35 commented on Jul 9, 2026

    @Sam-syntax35
    Contributor

    hey @gkhngyk !plz assign this to me

  3. added a commit that references this issue on Jul 16, 2026
    48e9f06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions