




















@@ -844,6 +844,79 @@ describe("active-memory plugin", () => {
844844expect(runEmbeddedAgent).not.toHaveBeenCalled();
845845});
846846847+it("does not run for dreaming-narrative cron session keys", async () => {
848+const result = await hooks.before_prompt_build(
849+{ prompt: "what wings should i order?", messages: [] },
850+{
851+agentId: "main",
852+trigger: "user",
853+sessionKey: "agent:main:dreaming-narrative-light-abc123",
854+messageProvider: "webchat",
855+},
856+);
857+858+expect(result).toBeUndefined();
859+expect(runEmbeddedAgent).not.toHaveBeenCalled();
860+});
861+862+it("does not run when a session id resolves to a dreaming-narrative cron session key", async () => {
863+hoisted.sessionStore["agent:main:dreaming-narrative-light-abc123"] = {
864+sessionId: "dreaming-session",
865+updatedAt: 1,
866+};
867+868+const result = await hooks.before_prompt_build(
869+{ prompt: "what wings should i order?", messages: [] },
870+{
871+agentId: "main",
872+trigger: "user",
873+sessionId: "dreaming-session",
874+messageProvider: "webchat",
875+},
876+);
877+878+expect(result).toBeUndefined();
879+expect(runEmbeddedAgent).not.toHaveBeenCalled();
880+});
881+882+it("allows non-canonical session keys that merely contain the dreaming-narrative substring", async () => {
883+const result = await hooks.before_prompt_build(
884+{ prompt: "what wings should i order?", messages: [] },
885+{
886+agentId: "main",
887+trigger: "user",
888+sessionKey: "agent:main:webchat:dreaming-narrative-room",
889+messageProvider: "webchat",
890+},
891+);
892+893+// Real session keys that happen to contain "dreaming-narrative" in a
894+// non-canonical way (not {light|rem|deep} phase suffix) must remain eligible.
895+// The session key "agent:main:webchat:dreaming-narrative-room" is a real chat
896+// whose topic happens to contain the string — not a dreaming cron key.
897+expect(runEmbeddedAgent).toHaveBeenCalledTimes(1);
898+expect(result).not.toBeUndefined();
899+});
900+901+it("allows real webchat session keys whose peer id starts with a phased dreaming-narrative prefix", async () => {
902+const result = await hooks.before_prompt_build(
903+{ prompt: "what wings should i order?", messages: [] },
904+{
905+agentId: "main",
906+trigger: "user",
907+sessionKey: "agent:main:webchat:dreaming-narrative-light-room",
908+messageProvider: "webchat",
909+},
910+);
911+912+// A real webchat session key whose peer id begins with a phased dreaming-narrative
913+// phrase must not be excluded. Only the canonical bare or agent-prefixed key
914+// shape (dreaming-narrative-<phase>-<hash> directly after agentId or bare) should
915+// be rejected — not the same phrase appearing deeper in the key as a peer id.
916+expect(runEmbeddedAgent).toHaveBeenCalledTimes(1);
917+expect(result).not.toBeUndefined();
918+});
919+847920it("defaults to direct-style sessions only", async () => {
848921const result = await hooks.before_prompt_build(
849922{ prompt: "what wings should we order?", messages: [] },
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。