{"record":{"id":"11c815d630cadb76","repo":"mastra-ai/mastra","slug":"this-conversation-has-no-message-to-name-it-from-y","errorCode":null,"errorMessage":"This conversation has no message to name it from yet.","messagePattern":"This conversation has no message to name it from yet\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agent-controller/agent-controller.ts","lineNumber":1285,"sourceCode":"    scope,\n    model,\n    requestContext: callerContext,\n  }: {\n    threadId: string;\n    resourceId?: string;\n    scope?: string;\n    /** Overrides the memory-configured title model — for hosts that resolve it themselves. */\n    model?: DynamicArgument<MastraModelConfig>;\n    /** The caller's context — carries the identity model resolution bills to. */\n    requestContext?: RequestContext;\n  }): Promise<string | undefined> {\n    const thread = await this.queryThreadById({ threadId });\n    if (!thread) throw new Error(`Thread not found: ${threadId}`);\n\n    const recent = await this.queryThreadMessages({ threadId, limit: TITLE_WINDOW_MESSAGES });\n    const messages = new MessageList().add(recent, 'memory').get.all.ui();\n    if (!messages.some(message => message.role === 'user')) {\n      throw new Error('This conversation has no message to name it from yet.');\n    }\n\n    const session = resourceId ? await this.getSessionByResource(resourceId, scope) : undefined;\n    const agent = session\n      ? this.getCurrentAgent(session)\n      : this.propagateRuntimeServicesToAgent(this.getAgentForMode(this.#defaultMode));\n    const requestContext = session\n      ? await this.buildRequestContext(session, callerContext)\n      : (callerContext ?? new RequestContext());\n    const configured = (await agent.getMemory({ requestContext }))?.getMergedThreadConfig().generateTitle;\n    const titleConfig = typeof configured === 'object' ? configured : undefined;\n\n    const title = (\n      await agent.generateTitleFromUserMessage({\n        messages,\n        requestContext,\n        model: model ?? titleConfig?.model,\n        instructions: titleConfig?.instructions,","sourceCodeStart":1267,"sourceCodeEnd":1303,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent-controller/agent-controller.ts#L1267-L1303","documentation":"After loading the thread's recent messages, the title generator requires at least one user message to derive a title from. If the title window (TITLE_WINDOW_MESSAGES) contains no user-role message, it throws instead of producing a meaningless title.","triggerScenarios":"Requesting a thread title for a thread that only contains system/assistant/developer messages (e.g. a freshly created thread seeded with an assistant greeting, or messages pruned below the window).","commonSituations":"Auto-titling threads immediately after creation before the first user turn; threads created via API with only assistant messages; tests seeding synthetic non-user messages.","solutions":["Generate the title only after the first user message has been stored in the thread","Send at least one user message to the thread before titling","Catch this error and retry titling later in the conversation lifecycle"],"exampleFix":"// before\nawait controller.generateThreadTitle({ threadId }); // thread has no user messages yet\n// after\nconst msgs = await controller.queryThreadMessages({ threadId, limit: 10 });\nif (msgs.some(m => m.role === 'user')) {\n  await controller.generateThreadTitle({ threadId });\n}","handlingStrategy":"try-catch","validationCode":"const recent = await controller.queryThreadMessages({ threadId, limit: 5 });\nif (!recent.some(m => m.role === 'user')) return; // not titlable yet","typeGuard":null,"tryCatchPattern":"try {\n  await controller.generateThreadTitle({ threadId });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('no message to name it from')) {\n    scheduleRetryAfterNextUserMessage(threadId);\n    return;\n  }\n  throw e;\n}","preventionTips":["Trigger title generation on/after the first user turn, not at thread creation","Queue titling jobs and skip threads with no user messages","In tests, seed at least one user message before asserting titles"],"tags":["memory","title-generation","messages"],"backgroundTag":"no-user-message-yet","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}