thedotmack/claude-mem · warning
Skipping resume for INIT prompt despite existing memorySessi
Error message
Skipping resume for INIT prompt despite existing memorySessionId=${session.memorySessionId} - SDK context was lost (worker restart or crash recovery) What it means
The observer resumes SDK sessions via memorySessionId, but only when the current prompt is a continuation (lastPromptNumber > 1). On the first (INIT) prompt it always starts fresh and captures a new session id; if a stale memorySessionId already exists at prompt #1, the prior SDK context is unrecoverable (typically the worker restarted or crashed between session creation and the first prompt), so this warning records the discarded resume.
Source
Thrown at src/services/worker/ClaudeProvider.ts:269
logger.info('SDK', 'Starting SDK query', {
sessionDbId: session.sessionDbId,
contentSessionId: session.contentSessionId,
memorySessionId: session.memorySessionId ?? undefined,
hasRealMemorySessionId,
shouldResume,
resume_parameter: shouldResume ? session.memorySessionId : '(none - fresh start)',
lastPromptNumber: session.lastPromptNumber,
authMethod
});
if (session.lastPromptNumber > 1) {
logger.debug('SDK', `[ALIGNMENT] Resume Decision | contentSessionId=${session.contentSessionId} | memorySessionId=${session.memorySessionId} | prompt#=${session.lastPromptNumber} | hasRealMemorySessionId=${hasRealMemorySessionId} | shouldResume=${shouldResume} | resumeWith=${shouldResume ? session.memorySessionId : 'NONE'}`);
} else {
const hasStaleMemoryId = hasRealMemorySessionId;
logger.debug('SDK', `[ALIGNMENT] First Prompt (INIT) | contentSessionId=${session.contentSessionId} | prompt#=${session.lastPromptNumber} | hasStaleMemoryId=${hasStaleMemoryId} | action=START_FRESH | Will capture new memorySessionId from SDK response`);
if (hasStaleMemoryId) {
logger.warn('SDK', `Skipping resume for INIT prompt despite existing memorySessionId=${session.memorySessionId} - SDK context was lost (worker restart or crash recovery)`);
}
}
ensureDir(OBSERVER_SESSIONS_DIR);
const queryResult = query({
prompt: messageGenerator,
options: buildHardenedSdkOptions({
source: 'Observer',
sessionDbId: session.sessionDbId,
contentSessionId: session.contentSessionId,
project: session.project,
model: modelId,
env: isolatedEnv, // Use isolated credentials from ~/.claude-mem/.env, not process.env
pathToClaudeCodeExecutable: claudePath,
abortController: session.abortController,
...(shouldResume && session.memorySessionId ? { resume: session.memorySessionId } : {}),
spawnClaudeCodeProcess: createSdkSpawnFactory(session.sessionDbId, slotReservation, observerExtraArgs),
}),View on GitHub (pinned to 8bc631a71a)
Solutions
- No data is lost from claude-mem's own DB — the observer starts a new SDK session and continues capturing
- To avoid it, keep the worker stable across session starts (check restart/crash logs around the timestamp)
- If it happens constantly, look for a crash loop in worker logs and fix the underlying startup failure
Defensive patterns
Strategy: validation
Validate before calling
function shouldResumeSdkSession(session: { lastPromptNumber: number; memorySessionId: string | null }): session is { lastPromptNumber: number; memorySessionId: string } {
return session.lastPromptNumber > 1 && Boolean(session.memorySessionId);
} Type guard
function isFirstPrompt(session: { lastPromptNumber: number }): boolean {
return session.lastPromptNumber <= 1;
} Prevention
- Expect a fresh SDK session on the INIT prompt — never assume memorySessionId survives worker restarts
- Keep the worker running across session starts to avoid the crash/restart window
- Monitor worker stability (restart logs) if this warning appears frequently
When it happens
Trigger: Worker restart or crash after a session row was created but before its first prompt completed; a session-init hook running twice creating a reused row; database restored from a backup mid-session.
Common situations: Restarting claude-mem or the machine right after starting a coding session; worker crash loops; killing the worker between session-init and the first observation.
Related errors
- Bun installation completed but binary not found. Please rest
- Failed to install Bun. Please install manually: ${manualInst
- uv installation completed but binary not found. Please resta
- Failed to capture session_id while priming corpus "${corpus.
- Invalid API key: check your API key configuration in ~/.clau
AI-assisted analysis of thedotmack/claude-mem@8bc631a71a (2026-08-20).
Data as JSON: /api/errors/7e5c52b136013bb7.
Report an issue: GitHub.