fix(api): pass actor identity when purging memory after thread clear (#62)

threads/clear called memoryProviders.resolve with a bare spaceId string.
The resolver destructures { spaceId, userId }, so both were undefined and
purgeHistory was silently skipped after every clear.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
This commit is contained in:
cynarAI 2026-09-22 10:57:40 +02:00 committed by GitHub
parent db39fe7752
commit 0a3ce24797
2 changed files with 18 additions and 5 deletions

View File

@ -4,12 +4,20 @@ import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
describe("memory provider config router wiring", () => { describe("memory provider config router wiring", () => {
const routerSource = readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), "router.ts"),
"utf8",
);
it("routes providerConfig through owner-gated getMemoryProviderConfig", () => { it("routes providerConfig through owner-gated getMemoryProviderConfig", () => {
const routerSource = readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), "router.ts"),
"utf8",
);
expect(routerSource).toContain("getMemoryProviderConfig(deps, context.actor)"); expect(routerSource).toContain("getMemoryProviderConfig(deps, context.actor)");
expect(routerSource).not.toMatch(/providerConfig:[\s\S]{0,240}findSpaceMemoryConfig/); expect(routerSource).not.toMatch(/providerConfig:[\s\S]{0,240}findSpaceMemoryConfig/);
}); });
it("passes actor space and user when resolving memory after thread clear", () => {
expect(routerSource).not.toMatch(/memoryProviders\.resolve\(context\.actor\.spaceId\)/);
expect(routerSource).toMatch(
/memoryProviders[\s\S]{0,120}\.resolve\(\{[\s\S]{0,120}spaceId: context\.actor\.spaceId[\s\S]{0,120}userId: context\.actor\.userId/,
);
});
}); });

View File

@ -1484,7 +1484,12 @@ export function createRouter(deps: RouterDeps) {
}); });
const [configuredMemory] = await Promise.all([ const [configuredMemory] = await Promise.all([
target.kind === "bot" target.kind === "bot"
? deps.memoryProviders.resolve(context.actor.spaceId).catch((error) => { ? deps.memoryProviders
.resolve({
spaceId: context.actor.spaceId,
userId: context.actor.userId,
})
.catch((error) => {
getLogger().error("semantic memory resolution after thread clear failed", error); getLogger().error("semantic memory resolution after thread clear failed", error);
return null; return null;
}) })