Repository navigation
fix(onboarding): retry LLM suggestion calls and add fallback - #385
Sam-syntax35 wants to merge 2 commits into
Conversation
e074e09 to
3341cc1
Compare
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks for this — the Topics and Competitors steps are wrapped correctly, the shared withRetry move is clean, and the inline fallback pattern is exactly right. One blocker before merge, though: the Prompts step targets the wrong route, so #379's most likely failure case is still unguarded.
The route onboarding actually calls is /from-topics, not /suggest.
- Onboarding generates prompts via
POST /api/prompts/from-topics(web/.../onboarding/page.tsx:651). There is zero reference to/api/prompts/suggestanywhere inweb/src—/suggestis the dashboard "prompt suggestions" feature (it's even gated behindrequireFeature('prompt_suggestions')), which onboarding never hits. - So the
withRetryyou added inprompts.jssits on a route onboarding doesn't use, while the real onboarding route (/from-topics, thegenerateObjectat ~line 499) is still a bare call with no retry. - This matters because
topicPromptSchemarequires exactly 5 prompts per topic (z.array(...).length(5)). That's the strictest schema in the flow and the single most likely place to throwNoObjectGeneratedErrorand 500 without a retry — precisely the scenario in #379.
Two changes requested:
- Move the
withRetrywrapper from the/suggestroute to the/from-topicsroute (wrap thegenerateObjectat ~line 499 withtopicPromptSchema). Wrapping/suggesttoo is harmless, but/from-topicsis the one that must be covered. - Add the same inline fallback UI to the Prompts step. Right now that step still shows a bare
toast.error('Failed to generate prompts from topics')(page.tsx:683) with no manual path forward — unlike the Topics/Competitors steps you fixed. After retries are exhausted the user should be able to continue (e.g. add prompts manually) instead of being stuck on the topics step.
Everything else looks good. Once the retry lands on /from-topics and the Prompts step gets the same fallback treatment, this is good to go.
|
I updated the retry logic and moved it to /from-topics. For the frontend, I now show an inline error and navigate to the prompt review step when generation fails. I noticed the onboarding prompt review doesn't currently have a manual prompt entry UI when there are no prompts. Would you like me to add manual prompt creation to that step as part of this PR? |
|
Thanks — pushing those changes will let me re-verify the And yes, please add manual prompt creation to the review step as part of this PR — that's exactly what closes #379 for the prompts path. Keep it minimal: when |
|
done !! can you please check now????? |
|
Just checking in — the |
…ntry (#443) Closes #379. Supersedes the stalled #385. Server: the shared withRetry helper moves from lib/audit to lib/retry (audit imports updated) and now wraps every onboarding LLM call with 3 attempts + exponential backoff: topics /suggest and competitors /suggest wrap their WHOLE two-phase flow (research + structuring), so a Phase-2 schema miss like competitors' .min(3) under-count re-runs the research too; prompts /suggest AND /from-topics — the generator the onboarding prompts step actually uses, which the previous attempt missed — get the same treatment. Input-validation 400s still return before any LLM call and are never retried. Web: when suggestions fail after the server exhausts its retries, the bare error toasts are replaced with inline fallbacks that keep the manual path usable. Topics and competitors steps show an amber 'add your own below' notice with a Try again button; a prompts-step failure no longer strands the user on the topics step — they advance with empty per-topic groups, an inline notice, and the existing per-topic add inputs (Continue stays disabled until at least one prompt exists).
Summary
This PR improves the reliability of onboarding LLM suggestion generation.
Backend
withRetryhelper inserver/src/lib/retry.js.Frontend
Related issue
Closes #379
Type of change
Testing