thedotmack/claude-mem · error · Error
Cannot process summary: memorySessionId not yet captured. Th
Error message
Cannot process summary: memorySessionId not yet captured. This session may need to be reinitialized.
What it means
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.
Source
Thrown at src/services/worker/OpenAICompatibleProvider.ts:253
);
} else {
logger.warn('SDK', `Empty ${this.providerName} observation response, leaving queue intact`, {
sessionId: session.sessionDbId
});
}
}
private async processSummaryMessage(
session: ActiveSession,
message: { last_assistant_message?: string },
worker: WorkerRef | undefined,
config: TConfig,
mode: ModeConfig,
originalTimestamp: number | null,
lastCwd: string | undefined
): Promise<void> {
if (!session.memorySessionId) {
throw new Error('Cannot process summary: memorySessionId not yet captured. This session may need to be reinitialized.');
}
const summaryPrompt = buildSummaryPrompt({
id: session.sessionDbId,
memory_session_id: session.memorySessionId,
project: session.project,
user_prompt: session.userPrompt,
last_assistant_message: message.last_assistant_message || ''
}, mode);
const responseContext = snapshotResponseContext(session);
session.conversationHistory.push({ role: 'user', content: summaryPrompt });
session.lastPromptSentAt = Date.now();
session.lastGeneratorSource = 'summarize';
const settings = SettingsDefaultsManager.loadFromFile(USER_SETTINGS_PATH);
const summaryModel = resolveSummaryTierModel(config.model, settings);
const summaryConfig = summaryModel === config.model ? config : { ...config, model: summaryModel };
if (summaryConfig !== config) {View on GitHub (pinned to d768ba3643)
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.
Example fix
// before
await provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd);
// after
if (!session.memorySessionId) {
throw new Error('Cannot summarize: session not initialized');
}
await provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd); Defensive patterns
Strategy: validation
Validate before calling
function canSummarize(session: ActiveSession): boolean {
return typeof session.memorySessionId === 'string' && session.memorySessionId.length > 0;
}
if (!canSummarize(session)) {
throw new Error('Cannot summarize: session missing memorySessionId');
} Type guard
function hasMemorySessionId(s: ActiveSession): s is ActiveSession & { memorySessionId: string } {
return typeof s.memorySessionId === 'string' && s.memorySessionId.length > 0;
} Try / catch
try {
await provider.processSummaryMessage(session, msg, worker, config, mode, ts, cwd);
} catch (err) {
if (err instanceof Error && /memorySessionId not yet captured/.test(err.message)) {
logger.warn('SDK', 'Summary deferred — session not initialized', { id: session.sessionDbId });
return;
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot process observations: memorySessionId not yet capture
- SSE stream returned HTTP ${response.status}
- ${timeoutMessage} (timed out after ${timeoutMs}ms)
- Failed to get processing status: ${res.status}
- Failed to trigger processing: ${res.status}
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/12a549950303aef5.
Report an issue: GitHub.