diff --git a/extensions/active-memory/index.test.ts b/extensions/active-memory/index.test.ts index 7ce61dc3c5f..9e51e78c900 100644 --- a/extensions/active-memory/index.test.ts +++ b/extensions/active-memory/index.test.ts @@ -859,6 +859,26 @@ describe("active-memory plugin", () => { expect(runEmbeddedAgent).not.toHaveBeenCalled(); }); + it("does not run when a session id resolves to a dreaming-narrative cron session key", async () => { + hoisted.sessionStore["agent:main:dreaming-narrative-light-abc123"] = { + sessionId: "dreaming-session", + updatedAt: 1, + }; + + const result = await hooks.before_prompt_build( + { prompt: "what wings should i order?", messages: [] }, + { + agentId: "main", + trigger: "user", + sessionId: "dreaming-session", + messageProvider: "webchat", + }, + ); + + expect(result).toBeUndefined(); + expect(runEmbeddedAgent).not.toHaveBeenCalled(); + }); + it("allows non-canonical session keys that merely contain the dreaming-narrative substring", async () => { const result = await hooks.before_prompt_build( { prompt: "what wings should i order?", messages: [] }, diff --git a/extensions/active-memory/index.ts b/extensions/active-memory/index.ts index 2911cc03e35..2f4b30b8ab1 100644 --- a/extensions/active-memory/index.ts +++ b/extensions/active-memory/index.ts @@ -3630,7 +3630,12 @@ export default definePluginEntry({ }); return undefined; } - if (!isEligibleInteractiveSession(ctx)) { + if ( + !isEligibleInteractiveSession({ + ...ctx, + sessionKey: resolvedSessionKey ?? ctx.sessionKey, + }) + ) { await persistPluginStatusLines({ api, agentId: effectiveAgentId,