mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
fix(active-memory): anchor dreaming-narrative key guard to canonical key shapes
This commit is contained in:
@@ -878,6 +878,25 @@ describe("active-memory plugin", () => {
|
||||
expect(result).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows real webchat session keys whose peer id starts with a phased dreaming-narrative prefix", async () => {
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order?", messages: [] },
|
||||
{
|
||||
agentId: "main",
|
||||
trigger: "user",
|
||||
sessionKey: "agent:main:webchat:dreaming-narrative-light-room",
|
||||
messageProvider: "webchat",
|
||||
},
|
||||
);
|
||||
|
||||
// A real webchat session key whose peer id begins with a phased dreaming-narrative
|
||||
// phrase must not be excluded. Only the canonical bare or agent-prefixed key
|
||||
// shape (dreaming-narrative-<phase>-<hash> directly after agentId or bare) should
|
||||
// be rejected — not the same phrase appearing deeper in the key as a peer id.
|
||||
expect(runEmbeddedAgent).toHaveBeenCalledTimes(1);
|
||||
expect(result).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("defaults to direct-style sessions only", async () => {
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should we order?", messages: [] },
|
||||
|
||||
@@ -1156,9 +1156,16 @@ function isEligibleInteractiveSession(ctx: {
|
||||
return false;
|
||||
}
|
||||
// Exclude only canonical dreaming-narrative session keys (bare or agent-prefixed).
|
||||
// Broad substring match would also exclude real chat session ids that happen to
|
||||
// contain the phrase (e.g. telegram:group:dreaming-narrative-room).
|
||||
if (/(?:^|:)dreaming-narrative-(?:light|rem|deep)-/i.test(ctx.sessionKey ?? "")) {
|
||||
// Canonical forms: "dreaming-narrative-<phase>-<hash>" or
|
||||
// "agent:<agentId>:dreaming-narrative-<phase>-<hash>".
|
||||
// A colon-delimited match would also exclude real chat session ids whose peer id
|
||||
// begins with a phased dreaming-narrative phrase (e.g.
|
||||
// "agent:main:feishu:group:dreaming-narrative-light-room").
|
||||
const sessionKey = ctx.sessionKey ?? "";
|
||||
if (
|
||||
/^dreaming-narrative-(light|rem|deep)-/i.test(sessionKey) ||
|
||||
/^agent:[^:]+:dreaming-narrative-(light|rem|deep)-/i.test(sessionKey)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!ctx.sessionKey && !ctx.sessionId) {
|
||||
|
||||
Reference in New Issue
Block a user