fix(session): Semantic renaming and memory session ID capture for resume
This commit fixes the session ID confusion identified in PR #475: PROBLEM: - Using contentSessionId (user's Claude Code session) for SDK resume was wrong - Memory agent conversation should persist across the entire user session - Each SDK call was starting fresh, losing memory agent continuity SOLUTION: 1. Semantic Renaming (clarity): - claudeSessionId → contentSessionId (user's observed session) - sdkSessionId → memorySessionId (memory agent's session for resume) - Database migration 17 renames columns accordingly 2. Memory Session ID Capture: - SDKAgent captures session_id from first SDK message - Persists to database via updateMemorySessionId() - SessionManager loads memorySessionId on session init 3. Resume Logic Fixed: - Only resume if memorySessionId captured from previous interaction - Enables memory agent continuity across user prompts Files changed: 33 (types, database, agents, hooks, routes) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+5
-5
@@ -17,7 +17,7 @@ export interface Observation {
|
||||
|
||||
export interface SDKSession {
|
||||
id: number;
|
||||
sdk_session_id: string | null;
|
||||
memory_session_id: string | null;
|
||||
project: string;
|
||||
user_prompt: string;
|
||||
last_user_message?: string;
|
||||
@@ -148,14 +148,14 @@ ${mode.prompts.summary_footer}`;
|
||||
/**
|
||||
* Build prompt for continuation of existing session
|
||||
*
|
||||
* CRITICAL: Why claudeSessionId Parameter is Required
|
||||
* CRITICAL: Why contentSessionId Parameter is Required
|
||||
* ====================================================
|
||||
* This function receives claudeSessionId from SDKAgent.ts, which comes from:
|
||||
* This function receives contentSessionId from SDKAgent.ts, which comes from:
|
||||
* - SessionManager.initializeSession (fetched from database)
|
||||
* - SessionStore.createSDKSession (stored by new-hook.ts)
|
||||
* - new-hook.ts receives it from Claude Code's hook context
|
||||
*
|
||||
* The claudeSessionId is the SAME session_id used by:
|
||||
* The contentSessionId is the SAME session_id used by:
|
||||
* - NEW hook (to create/fetch session)
|
||||
* - SAVE hook (to store observations)
|
||||
* - This continuation prompt (to maintain session context)
|
||||
@@ -166,7 +166,7 @@ ${mode.prompts.summary_footer}`;
|
||||
* Called when: promptNumber > 1 (see SDKAgent.ts line 150)
|
||||
* First prompt: Uses buildInitPrompt instead (promptNumber === 1)
|
||||
*/
|
||||
export function buildContinuationPrompt(userPrompt: string, promptNumber: number, claudeSessionId: string, mode: ModeConfig): string {
|
||||
export function buildContinuationPrompt(userPrompt: string, promptNumber: number, contentSessionId: string, mode: ModeConfig): string {
|
||||
return `${mode.prompts.continuation_greeting}
|
||||
|
||||
<observed_from_primary_session>
|
||||
|
||||
Reference in New Issue
Block a user