fix(openclaw): skip runtime setup during metadata registration (#5383)

This commit is contained in:
Yufeng He
2026-06-12 19:32:59 +05:30
committed by GitHub
parent e3f5ce7b41
commit b9ad8fa8b2
3 changed files with 60 additions and 2 deletions
+43 -2
View File
@@ -2,8 +2,8 @@
* Regression tests for per-agent memory isolation helpers and
* message filtering logic.
*/
import { describe, it, expect } from "vitest";
import {
import { describe, it, expect, vi } from "vitest";
import memoryPlugin, {
extractAgentId,
effectiveUserId,
agentUserId,
@@ -16,6 +16,47 @@ import {
filterMessagesForExtraction,
} from "./index.ts";
function createPluginApi(registrationMode?: string) {
return {
pluginConfig: {
mode: "platform",
apiKey: "test-api-key",
userId: "alice",
},
registrationMode,
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
},
resolvePath: vi.fn((p: string) => p),
registerTool: vi.fn(),
on: vi.fn(),
registerCli: vi.fn(),
registerCommand: vi.fn(),
registerService: vi.fn(),
registerMemoryCapability: vi.fn(),
};
}
describe("plugin registration modes", () => {
it("keeps cli-metadata registration free of runtime side effects", () => {
const api = createPluginApi("cli-metadata");
memoryPlugin.register(api as any);
expect(api.registerCli).toHaveBeenCalledTimes(1);
expect(api.registerService).not.toHaveBeenCalled();
expect(api.registerMemoryCapability).not.toHaveBeenCalled();
expect(api.registerTool).not.toHaveBeenCalled();
expect(api.on).not.toHaveBeenCalled();
expect(api.logger.info).not.toHaveBeenCalledWith(
expect.stringContaining("openclaw-mem0: registered"),
);
});
});
// ---------------------------------------------------------------------------
// extractAgentId
// ---------------------------------------------------------------------------