From aa235d774c3ee170590073a545903cf4e0eec566 Mon Sep 17 00:00:00 2001 From: Gagan Date: Thu, 23 Jul 2026 16:24:44 +0530 Subject: [PATCH] feat(x): chat titles must be 2-5 words; few-shot the title prompt Flash-lite under-complied with a bare word-count rule (returned one-word titles). Few-shot examples rein it in; a code guard rejects any remaining single-word output so the placeholder stays instead. --- apps/x/packages/core/src/knowledge/generate_title.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/x/packages/core/src/knowledge/generate_title.ts b/apps/x/packages/core/src/knowledge/generate_title.ts index 72401c88..5b82d968 100644 --- a/apps/x/packages/core/src/knowledge/generate_title.ts +++ b/apps/x/packages/core/src/knowledge/generate_title.ts @@ -7,10 +7,16 @@ import { withUseCase } from '../analytics/use_case.js'; const SYSTEM_PROMPT = `You name chat conversations. Given the user's first message, reply with a concise title for the conversation. Rules: -- 3 to 5 words +- At least 2 words, at most 5 — never a single word - Same language as the message - No quotation marks, no ending punctuation, no emoji -- Output the title and nothing else`; +- Output the title and nothing else + +Examples: +- "who are the investors in supabase" -> Supabase investor list +- "help me write a python script that renames all files in a folder" -> Python file renaming script +- "why is my docker build so slow" -> Slow Docker build debugging +- "draft an email to my landlord about the broken heater" -> Broken heater landlord email`; // Long first messages are usually pasted documents or code; the opening is // enough signal for a title and keeps the call cheap. @@ -53,5 +59,6 @@ export async function generateChatTitle(firstMessage: string): Promise MAX_TITLE_CHARS) return null; + if (!title.includes(' ')) return null; return title; }