From b3b6d421cccc9aa4becbd74f5dd651a5733a23ad Mon Sep 17 00:00:00 2001 From: Yurii Chukhlib Date: Fri, 16 Jan 2026 19:45:05 +0100 Subject: [PATCH] fix(session): reset compactionCount on /new and /reset --- src/auto-reply/reply/session.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/auto-reply/reply/session.ts b/src/auto-reply/reply/session.ts index e28ea4dea..35ee66b71 100644 --- a/src/auto-reply/reply/session.ts +++ b/src/auto-reply/reply/session.ts @@ -278,7 +278,10 @@ export async function initSessionState(params: { ctx.MessageThreadId, ); } - sessionStore[sessionKey] = { ...sessionStore[sessionKey], ...sessionEntry }; + // Fresh start for new sessions - don't inherit old state like compactionCount + sessionStore[sessionKey] = isNewSession + ? sessionEntry + : { ...sessionStore[sessionKey], ...sessionEntry }; await updateSessionStore(storePath, (store) => { if (groupResolution?.legacyKey && groupResolution.legacyKey !== sessionKey) { if (store[groupResolution.legacyKey] && !store[sessionKey]) { @@ -286,7 +289,10 @@ export async function initSessionState(params: { } delete store[groupResolution.legacyKey]; } - store[sessionKey] = { ...store[sessionKey], ...sessionEntry }; + // Fresh start for new sessions - don't inherit old state like compactionCount + store[sessionKey] = isNewSession + ? sessionEntry + : { ...store[sessionKey], ...sessionEntry }; }); const sessionCtx: TemplateContext = {