thedotmack/claude-mem · error · Error
Cannot process summary: memorySessionId not yet captured…
Error message
Cannot process summary: memorySessionId not yet captured. This session may need to be reinitialized.
What it means
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.
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)
Example fix
// before
await processSummaryMessage(session, config, mode, originalTimestamp, lastCwd);
// after
if (!session.memorySessionId) {
await reinitializeSession(session); // recaptures memorySessionId
}
await processSummaryMessage(session, config, mode, originalTimestamp, lastCwd); Defensive patterns
Strategy: validation
Validate before calling
function canProcessSummary(session: { memorySessionId?: string | null }): boolean {
return typeof session.memorySessionId === 'string' && session.memorySessionId.length > 0;
} Type guard
function hasMemorySession(s: { memorySessionId?: string | null }): s is typeof s & { memorySessionId: string } {
return typeof s.memorySessionId === 'string' && s.memorySessionId.length > 0;
} Try / catch
try {
await processSummaryMessage(session, config, mode, ts, lastCwd);
} catch (err) {
if (err instanceof Error && err.message.includes('memorySessionId not yet captured')) {
await reinitializeSession(session); // recapture the id, then requeue the summary
return;
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Cannot process observations: memorySessionId not yet…
- Context requested before initialization complete, returning…
- Corpus " " has no session — call prime first
- Dependency preflight found degraded optional setup
- Failed to capture session_id while priming corpus
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/12a549950303aef5.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker/OpenAICompatibleProvider.ts:351
);
} 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 d8bc9755e7)