{"record":{"id":"12a549950303aef5","repo":"thedotmack/claude-mem","slug":"cannot-process-summary-memorysessionid-not-yet-captured-this","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":351,"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":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker/OpenAICompatibleProvider.ts#L333-L369","documentation":"processSummaryMessage refuses to run when the session's memorySessionId has not been captured yet. memorySessionId is the identifier linking this worker session to its memory backend and is normally set during session initialization. The library throws this instead of sending a malformed summary request to the LLM/memory pipeline, signaling the session must be reinitialized so initialization can capture the id.","triggerScenarios":"A summary message arrives in runMessageLoop before the session was ever initialized (e.g. the worker was restarted mid-session and resumed from persisted state that lacks memorySessionId), or initialization failed silently but the message loop kept consuming messages.","commonSituations":"Worker process crash/restart losing in-memory session state; DB row created before the memory backend handshake completed; clock-skew or race where a summary is queued before init returns; a corrupted or older-version session record without memory_session_id.","solutions":["Reinitialize the session so initialization runs and captures memorySessionId, then retry the summary","Inspect the session record/state to confirm whether the memory backend handshake ran at all","Check worker logs around session startup for a failed or skipped init step","Ensure summary messages cannot be processed before init completes (gate on an initialized flag)"],"exampleFix":"// before\nawait processSummaryMessage(session, config, mode, originalTimestamp, lastCwd);\n// after\nif (!session.memorySessionId) {\n  await reinitializeSession(session); // recaptures memorySessionId\n}\nawait processSummaryMessage(session, config, mode, originalTimestamp, lastCwd);","handlingStrategy":"validation","validationCode":"function canProcessSummary(session: { memorySessionId?: string | null }): boolean {\n  return typeof session.memorySessionId === 'string' && session.memorySessionId.length > 0;\n}","typeGuard":"function hasMemorySession(s: { memorySessionId?: string | null }): s is typeof s & { memorySessionId: string } {\n  return typeof s.memorySessionId === 'string' && s.memorySessionId.length > 0;\n}","tryCatchPattern":"try {\n  await processSummaryMessage(session, config, mode, ts, lastCwd);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('memorySessionId not yet captured')) {\n    await reinitializeSession(session); // recapture the id, then requeue the summary\n    return;\n  }\n  throw err;\n}","preventionTips":["Gate all summary processing behind an explicit 'session initialized' flag","Persist memorySessionId as soon as init captures it, so worker restarts can resume","Fail fast at startup if init did not produce a memorySessionId","Monitor init failures so silent init misses surface before summaries arrive"],"tags":["state-management","initialization","session"],"backgroundTag":"missing-required-config-field","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}