{"record":{"id":"c68865b68cce777d","repo":"CopilotKit/CopilotKit","slug":"thread-name-generation-returned-an-empty-or-invali","errorCode":null,"errorMessage":"Thread name generation returned an empty or invalid title","messagePattern":"Thread name generation returned an empty or invalid title","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/runtime/src/v2/runtime/handlers/intelligence/thread-names.ts","lineNumber":75,"sourceCode":"  }\n\n  let generatedTitle: string | null = null;\n\n  for (let attempt = 1; attempt <= MAX_TITLE_GENERATION_ATTEMPTS; attempt++) {\n    try {\n      generatedTitle = await runTitleGenerationAttempt({\n        runtime,\n        request,\n        agentId,\n        threadId: thread.id,\n        prompt,\n      });\n\n      if (generatedTitle) {\n        break;\n      }\n\n      logger.warn(\n        { agentId, attempt, threadId: thread.id },\n        \"Thread name generation returned an empty or invalid title\",\n      );\n    } catch (error) {\n      logger.warn(\n        { err: error, agentId, attempt, threadId: thread.id },\n        \"Thread name generation attempt failed\",\n      );\n    }\n  }\n\n  await runtime.intelligence.updateThread({\n    threadId: thread.id,\n    userId,\n    agentId,\n    updates: { name: generatedTitle ?? FALLBACK_THREAD_TITLE },\n  });\n}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/CopilotKit/CopilotKit/blob/68fbe97d87420bd84e8196965c71bd6e394a3f7a/packages/runtime/src/v2/runtime/handlers/intelligence/thread-names.ts#L57-L93","documentation":"The runtime's automatic thread-naming feature asks the configured agent to generate a title for a new thread, retrying over multiple attempts. When an attempt completes but yields an empty/invalid title (agent returned empty string or the pipeline validated it away), the runtime logs this warning with agentId, attempt, and threadId and tries again; if all attempts fail, the thread simply keeps its default name.","triggerScenarios":"handleIntelligenceRun -> generateThreadNameForNewThread calls runTitleGenerationAttempt; the agent finishes generation but generatedTitle is falsy — e.g. the model replied with empty output, a title-extraction step stripped everything, or the agent's graph ends without producing a title state.","commonSituations":"Small/weak models returning empty completions for naming prompts; misconfigured title-generation prompts that get filtered out by output validators; token limits truncating the title to nothing; intelligence/thread-naming feature enabled with a model that doesn't handle the naming task.","solutions":["Check the configured naming agent/prompt — make it explicitly return a short non-empty title string","Use a stronger model for title generation if the current one returns empty responses","If thread naming is unimportant, disable the intelligence thread-naming feature to remove the noise","Reproduce with logging on the naming attempt to see the raw model output before validation"],"exampleFix":"// before: naming prompt that invites empty output\n\"Name this conversation.\"\n\n// after\n\"Name this conversation. Respond with ONLY the title, 3-6 words, never empty. Example: 'Bug fix discussion'\"","handlingStrategy":"validation","validationCode":"const isValidTitle = (t: unknown): t is string =>\n  typeof t === \"string\" && t.trim().length > 0 && t.trim().length <= 100;","typeGuard":"const isNonEmptyTitle = (t: unknown): t is string =>\n  typeof t === \"string\" && t.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Prompt the naming model for a mandatory 3-6 word non-empty title","Use a model reliable enough to not return empty completions","Validate and retry naming output agent-side before returning"],"tags":["thread-naming","intelligence","empty-response","v2-runtime"],"backgroundTag":"empty-llm-response","analyzedSha":"68fbe97d87420bd84e8196965c71bd6e394a3f7a","analyzedAt":"2026-08-27T04:03:26.537Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}