diff --git a/src/hooks/bundled/session-memory/handler.ts b/src/hooks/bundled/session-memory/handler.ts index 4c67f31d5bf..3057d78f170 100644 --- a/src/hooks/bundled/session-memory/handler.ts +++ b/src/hooks/bundled/session-memory/handler.ts @@ -496,7 +496,9 @@ const saveSessionToMemory: HookHandler = async (event) => { if ( event.context.blockSessionSave !== true && typeof postContent === "string" && - postContent !== writtenEntry + // Two distinct intents: write if no inline write happened (writtenEntry + // is null because blockPreSet was true) OR if the content changed. + (writtenEntry === null || postContent !== writtenEntry) ) { // Ensure memoryDir exists — the inline write may have been // skipped (e.g. blockSessionSave was true initially) so mkdir diff --git a/src/hooks/internal-hooks.ts b/src/hooks/internal-hooks.ts index 8bcbb567aed..522406e5d7a 100644 --- a/src/hooks/internal-hooks.ts +++ b/src/hooks/internal-hooks.ts @@ -323,11 +323,13 @@ export async function triggerInternalHook(event: InternalHookEvent): Promise {}` only when intentionally swallowing errors. */ export async function drainPostHookActions( actions: Array<() => Promise | void>, - onError?: (err: unknown) => void, + onError: (err: unknown) => void, ): Promise { const pending = [...actions]; actions.length = 0; @@ -335,7 +337,7 @@ export async function drainPostHookActions( try { await action(); } catch (err) { - onError?.(err); + onError(err); } } }