{"record":{"id":"12a549950303aef5","repo":"thedotmack/claude-mem","slug":"cannot-process-summary-memorysessionid-not-yet-ca","errorCode":null,"errorMessage":"Cannot process summary: memorySessionId not yet captured. This session may need to be reinitialized.","messagePattern":"Cannot process summary: memorySessionId not yet captured\\. This session may need to be reinitialized\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/worker/OpenAICompatibleProvider.ts","lineNumber":253,"sourceCode":"      );\n    } else {\n      logger.warn('SDK', `Empty ${this.providerName} observation response, leaving queue intact`, {\n        sessionId: session.sessionDbId\n      });\n    }\n  }\n\n  private async processSummaryMessage(\n    session: ActiveSession,\n    message: { last_assistant_message?: string },\n    worker: WorkerRef | undefined,\n    config: TConfig,\n    mode: ModeConfig,\n    originalTimestamp: number | null,\n    lastCwd: string | undefined\n  ): Promise<void> {\n    if (!session.memorySessionId) {\n      throw new Error('Cannot process summary: memorySessionId not yet captured. This session may need to be reinitialized.');\n    }\n\n    const summaryPrompt = buildSummaryPrompt({\n      id: session.sessionDbId,\n      memory_session_id: session.memorySessionId,\n      project: session.project,\n      user_prompt: session.userPrompt,\n      last_assistant_message: message.last_assistant_message || ''\n    }, mode);\n    const responseContext = snapshotResponseContext(session);\n\n    session.conversationHistory.push({ role: 'user', content: summaryPrompt });\n    session.lastPromptSentAt = Date.now();\n    session.lastGeneratorSource = 'summarize';\n    const settings = SettingsDefaultsManager.loadFromFile(USER_SETTINGS_PATH);\n    const summaryModel = resolveSummaryTierModel(config.model, settings);\n    const summaryConfig = summaryModel === config.model ? config : { ...config, model: summaryModel };\n    if (summaryConfig !== config) {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/src/services/worker/OpenAICompatibleProvider.ts#L235-L271","documentation":"Thrown by processSummaryMessage for the same root cause as 140 but on the summary path. The summary prompt is built with session.memorySessionId (passed into buildSummaryPrompt as memory_session_id), so a missing id makes the prompt unconstructable. The guard fails fast rather than emitting a malformed summary.","triggerScenarios":"A 'last_assistant_message' summary message is processed for a session whose memorySessionId was never captured (null/undefined) — e.g., summary triggered immediately after a failed/empty init.","commonSituations":"Session summarization kicked off before init completed; worker recovered a session from DB where memorySessionId is null; provider init returned empty content so the id was never stored.","solutions":["Reinitialize the session so memorySessionId is captured before summary processing.","Inspect logs for the empty-init-response error to find why the id is missing.","Confirm the DB session row carries a non-null memory_session_id; restart the worker if it was lost.","In tests, drive the init handshake (returning a session_id) before sending summary messages."],"exampleFix":"// before\nawait provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd);\n\n// after\nif (!session.memorySessionId) {\n  throw new Error('Cannot summarize: session not initialized');\n}\nawait provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd);","handlingStrategy":"validation","validationCode":"function canSummarize(session: ActiveSession): boolean {\n  return typeof session.memorySessionId === 'string' && session.memorySessionId.length > 0;\n}\nif (!canSummarize(session)) {\n  throw new Error('Cannot summarize: session missing memorySessionId');\n}","typeGuard":"function hasMemorySessionId(s: ActiveSession): s is ActiveSession & { memorySessionId: string } {\n  return typeof s.memorySessionId === 'string' && s.memorySessionId.length > 0;\n}","tryCatchPattern":"try {\n  await provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd);\n} catch (err) {\n  if (err instanceof Error && /memorySessionId not yet captured/.test(err.message)) {\n    logger.warn('SDK', 'Summary deferred — session not initialized', { id: session.sessionDbId });\n    return;\n  }\n  throw err;\n}","preventionTips":["Gate summarization behind the same memorySessionId check used for observations.","Don't trigger summaries from a session that failed init.","Persist memory_session_id to DB on capture so restarts retain it."],"tags":["session-state","worker","openai-provider","summarization","initialization"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}