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
This commit is contained in:
zeroaltitude 2026-03-06 15:58:37 -07:00
parent 65fae19fc8
commit 7a81cc94d3
No known key found for this signature in database
GPG Key ID: 77592FB1C703882E
2 changed files with 6 additions and 1 deletions

View File

@ -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");
});

View File

@ -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.