From 7a81cc94d3c9d73fc261e91980dd57b49b609c41 Mon Sep 17 00:00:00 2001 From: zeroaltitude Date: Fri, 6 Mar 2026 15:58:37 -0700 Subject: [PATCH] fix(session-memory): add debug log for custom content, tighten test assertion - Add log.debug when sessionSaveContent override is used (symmetric with blockSessionSave) - Change override test assertion from toContain to toBe for precision --- src/hooks/bundled/session-memory/handler.test.ts | 2 +- src/hooks/bundled/session-memory/handler.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/bundled/session-memory/handler.test.ts b/src/hooks/bundled/session-memory/handler.test.ts index b5b5ef3ce13..c2a7e07b79c 100644 --- a/src/hooks/bundled/session-memory/handler.test.ts +++ b/src/hooks/bundled/session-memory/handler.test.ts @@ -618,7 +618,7 @@ describe("session-memory hook", () => { const files = (await fs.readdir(memoryDir)).filter((f) => f.endsWith(".md")); expect(files.length).toBeGreaterThan(0); const content = await fs.readFile(path.join(memoryDir, files[0]), "utf-8"); - expect(content).toContain("Custom summary from upstream hook"); + expect(content).toBe("Custom summary from upstream hook"); expect(content).not.toContain("original"); }); diff --git a/src/hooks/bundled/session-memory/handler.ts b/src/hooks/bundled/session-memory/handler.ts index c6bfa6d0a9a..94cbf9791d7 100644 --- a/src/hooks/bundled/session-memory/handler.ts +++ b/src/hooks/bundled/session-memory/handler.ts @@ -353,6 +353,11 @@ const saveSessionToMemory: HookHandler = async (event) => { // An empty string is a valid redaction signal — hooks may intentionally // set it to persist a blank marker while avoiding transcript retention. const customContent = context.sessionSaveContent; + if (typeof customContent === "string") { + log.debug("Using custom session content from upstream hook", { + length: customContent.length, + }); + } const entry = typeof customContent === "string" ? customContent : entryParts.join("\n"); // Write under memory root with alias-safe file validation.