Skip to content

Commit e036a3e

Browse files
committed
fix: cover independent memory-core registration
1 parent 8189727 commit e036a3e

File tree

8 files changed

+46
-2
lines changed

8 files changed

+46
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Docs: https://docs.openclaw.ai
8080
- Hooks/workspace: keep repo-local `<workspace>/hooks` disabled until explicitly enabled, block workspace hook name collisions from shadowing bundled/managed/plugin hooks, and treat `hooks.internal.load.extraDirs` as trusted managed hook sources.
8181
- Web tools/Exa: add Exa as a bundled web-search plugin with Exa-native date filters, search-mode selection, and optional content extraction under `plugins.entries.exa.config.webSearch.*`. Thanks @V-Gutierrez and @vincentkoc.
8282
- CLI/hooks: route hook-pack install and update through `openclaw plugins`, keep `openclaw hooks` focused on hook visibility and per-hook controls, and show plugin-managed hook details in CLI output.
83+
- Memory/core tools: register `memory_search` and `memory_get` independently so one unavailable memory tool no longer suppresses the other in new sessions. (#50198) Thanks @artwalker.
8384

8485
### Fixes
8586

extensions/memory-core/index.test.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, expect, it } from "vitest";
2-
import { buildPromptSection } from "./index.js";
1+
import { describe, expect, it, vi } from "vitest";
2+
import plugin, { buildPromptSection } from "./index.js";
33

44
describe("buildPromptSection", () => {
55
it("returns empty when no memory tools are available", () => {
@@ -29,4 +29,40 @@ describe("buildPromptSection", () => {
2929
"Citations are disabled: do not mention file paths or line numbers in replies unless the user explicitly asks.",
3030
);
3131
});
32+
33+
it("registers memory tools independently so one unavailable tool does not suppress the other", () => {
34+
const registerTool = vi.fn();
35+
const registerMemoryPromptSection = vi.fn();
36+
const registerCli = vi.fn();
37+
const searchTool = { name: "memory_search" };
38+
const getTool = null;
39+
const api = {
40+
registerTool,
41+
registerMemoryPromptSection,
42+
registerCli,
43+
runtime: {
44+
tools: {
45+
createMemorySearchTool: vi.fn(() => searchTool),
46+
createMemoryGetTool: vi.fn(() => getTool),
47+
registerMemoryCli: vi.fn(),
48+
},
49+
},
50+
};
51+
52+
plugin.register(api as never);
53+
54+
expect(registerMemoryPromptSection).toHaveBeenCalledWith(buildPromptSection);
55+
expect(registerTool).toHaveBeenCalledTimes(2);
56+
expect(registerTool.mock.calls[0]?.[1]).toEqual({ names: ["memory_search"] });
57+
expect(registerTool.mock.calls[1]?.[1]).toEqual({ names: ["memory_get"] });
58+
59+
const searchFactory = registerTool.mock.calls[0]?.[0] as
60+
| ((ctx: unknown) => unknown)
61+
| undefined;
62+
const getFactory = registerTool.mock.calls[1]?.[0] as ((ctx: unknown) => unknown) | undefined;
63+
const ctx = { config: { plugins: {} }, sessionKey: "agent:main:slack:dm:u123" };
64+
65+
expect(searchFactory?.(ctx)).toBe(searchTool);
66+
expect(getFactory?.(ctx)).toBeNull();
67+
});
3268
});

extensions/telegram/src/bot-message-dispatch.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const telegramDepsForTest: TelegramBotDeps = {
101101
enqueueSystemEvent: enqueueSystemEvent as TelegramBotDeps["enqueueSystemEvent"],
102102
dispatchReplyWithBufferedBlockDispatcher:
103103
dispatchReplyWithBufferedBlockDispatcher as TelegramBotDeps["dispatchReplyWithBufferedBlockDispatcher"],
104+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
104105
buildModelsProviderData: buildModelsProviderData as TelegramBotDeps["buildModelsProviderData"],
105106
listSkillCommandsForAgents:
106107
listSkillCommandsForAgents as TelegramBotDeps["listSkillCommandsForAgents"],

extensions/telegram/src/bot-native-commands.menu-test-support.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export function createNativeCommandTestParams(
109109
providers: [],
110110
resolvedDefault: { provider: "openai", model: "gpt-4.1" },
111111
})) as TelegramBotDeps["buildModelsProviderData"],
112+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
112113
listSkillCommandsForAgents,
113114
wasSentByBot: vi.fn(() => false) as TelegramBotDeps["wasSentByBot"],
114115
};

extensions/telegram/src/bot-native-commands.session-meta.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ function registerAndResolveCommandHandlerBase(params: {
208208
providers: [],
209209
resolvedDefault: { provider: "openai", model: "gpt-4.1" },
210210
})),
211+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
211212
listSkillCommandsForAgents: vi.fn(() => []),
212213
wasSentByBot: vi.fn(() => false),
213214
};

extensions/telegram/src/bot-native-commands.test-helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { TelegramAccountConfig } from "openclaw/plugin-sdk/config-runtime";
44
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
55
import type { MockFn } from "openclaw/plugin-sdk/testing";
66
import { vi } from "vitest";
7+
import type { TelegramBotDeps } from "./bot-deps.js";
78
import {
89
createNativeCommandTestParams,
910
type NativeCommandTestParams,
@@ -121,6 +122,7 @@ export function createNativeCommandsHarness(params?: {
121122
enqueueSystemEvent: vi.fn(),
122123
dispatchReplyWithBufferedBlockDispatcher:
123124
replyPipelineMocks.dispatchReplyWithBufferedBlockDispatcher,
125+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
124126
buildModelsProviderData: vi.fn(async () => ({
125127
byProvider: new Map<string, Set<string>>(),
126128
providers: [],

extensions/telegram/src/bot-native-commands.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function createNativeCommandTestParams(
6868
providers: [],
6969
resolvedDefault: { provider: "openai", model: "gpt-4.1" },
7070
})) as TelegramBotDeps["buildModelsProviderData"],
71+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
7172
listSkillCommandsForAgents: skillCommandMocks.listSkillCommandsForAgents,
7273
wasSentByBot: vi.fn(() => false) as TelegramBotDeps["wasSentByBot"],
7374
};

extensions/telegram/src/bot.media.e2e-harness.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const telegramBotDepsForTest: TelegramBotDeps = {
161161
providers: [],
162162
resolvedDefault: { provider: "openai", model: "gpt-4.1" },
163163
})) as TelegramBotDeps["buildModelsProviderData"],
164+
loadWebMedia: vi.fn() as TelegramBotDeps["loadWebMedia"],
164165
listSkillCommandsForAgents: vi.fn(() => []) as TelegramBotDeps["listSkillCommandsForAgents"],
165166
wasSentByBot: vi.fn(() => false) as TelegramBotDeps["wasSentByBot"],
166167
};

0 commit comments

Comments
 (0)