diff --git a/apps/api/src/memory-provider-router-wiring.test.ts b/apps/api/src/memory-provider-router-wiring.test.ts index cf738ce..a185097 100644 --- a/apps/api/src/memory-provider-router-wiring.test.ts +++ b/apps/api/src/memory-provider-router-wiring.test.ts @@ -4,12 +4,20 @@ import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; 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", () => { - const routerSource = readFileSync( - resolve(dirname(fileURLToPath(import.meta.url)), "router.ts"), - "utf8", - ); expect(routerSource).toContain("getMemoryProviderConfig(deps, context.actor)"); 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/, + ); + }); }); diff --git a/apps/api/src/router.ts b/apps/api/src/router.ts index 0040536..47dec1f 100644 --- a/apps/api/src/router.ts +++ b/apps/api/src/router.ts @@ -1484,7 +1484,12 @@ export function createRouter(deps: RouterDeps) { }); const [configuredMemory] = await Promise.all([ 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); return null; })