feat(onboarding): write a question for every consultation domain and stop generating an unread greeting

The home screen renders all ten domains from the consultation registry,
but the Agent only ever wrote three of them; the other seven were static
registry prompts dressed up as personalized starting points. The payload
now has to cover every domain in registry order, validated as a set
rather than per item, so a short or misordered answer is rejected whole
instead of silently leaving cards on static copy.

The greeting went the other way. Nothing has rendered it since the hero
note was removed, so it leaves the schema, the prompt, and the client
contract rather than costing tokens for text no one reads.

Ten questions take much longer to generate than three, so the route,
the server generation budget, and the client request deadline all grow
together, and the cache version bump forces existing payloads to be
regenerated once under the new shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-18 15:18:09 +08:00
parent fc811d2c39
commit a6d4473ef0
10 changed files with 170 additions and 82 deletions
+10 -2
View File
@@ -2,13 +2,16 @@ import {
createOnboardingPost,
type OnboardingProfileRepository,
} from "@/lib/onboarding-post";
import { consultationDomainDefinition } from "@/lib/consultation-domain-registry";
import { onboardingSuggestionThemes } from "@/lib/onboarding-payload";
import { createAdminSupabaseClient } from "@/lib/supabase/admin";
import { createServerSupabaseClient } from "@/lib/supabase/server";
import { getOnboardingAgent } from "@/mastra";
import { loadLanguageModelCatalog } from "@/lib/model-catalog";
export const runtime = "nodejs";
export const maxDuration = 30;
// Ten questions in one call take materially longer than the previous three.
export const maxDuration = 60;
function createProfileRepository(
admin: ReturnType<typeof createAdminSupabaseClient>,
@@ -76,7 +79,12 @@ export const POST = createOnboardingPost({
role: "user",
content: [
name ? `用户称呼:${name.slice(0, 80)}` : "用户未填写称呼。",
"请生成首次欢迎语和三个入门问题。欢迎语直接邀请用户提问,不要提到出生资料、资料准备或系统处理过程。",
`需要的主题,按此顺序各写一个问题:${onboardingSuggestionThemes.join("、")}`,
...onboardingSuggestionThemes.map((theme) => {
const domain = consultationDomainDefinition(theme);
return `- ${theme}${domain.label}):${domain.claimBoundary}`;
}),
"只返回 suggestions 数组,不要欢迎语。",
].join("\n"),
},
], { abortSignal: signal });