fix(session-memory): skip transcript loading and LLM call when blockSessionSave is pre-set

When blockSessionSave is already true, the handler was still loading
session content and potentially calling generateSlugViaLLM — sending
sensitive transcript text to a model provider despite an explicit
block. Short-circuit before transcript loading when the flag is set.

Credit: Codex review.
This commit is contained in:
zeroaltitude 2026-03-07 09:52:48 -07:00
parent 0621de4773
commit 64d52cf2ea
No known key found for this signature in database
GPG Key ID: 77592FB1C703882E

View File

@ -288,7 +288,12 @@ const saveSessionToMemory: HookHandler = async (event) => {
let sessionContent: string | null = null;
const hasCustomContent = typeof context.sessionSaveContent === "string";
if (sessionFile && !hasCustomContent) {
// Short-circuit transcript loading and LLM slug generation when
// blockSessionSave is already set — no point loading sensitive content
// or sending it to a model provider when saving is explicitly blocked.
const blockPreSet = context.blockSessionSave === true;
if (sessionFile && !hasCustomContent && !blockPreSet) {
// Get recent conversation content, with fallback to rotated reset transcript.
sessionContent = await getRecentSessionContentWithResetFallback(sessionFile, messageCount);
log.debug("Session content loaded", {