mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 23:51:48 +00:00
The memory-core plugin registered both memory_search and memory_get in a single factory that returned null if either tool creation failed. This caused both tools to silently disappear from new sessions when only one tool's prerequisites were unavailable. Split into two independent registerTool calls so each tool's availability is evaluated separately. Also add debug logging when a plugin tool factory returns null to aid future diagnosis. Fixes #50173 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import type { MemoryPromptSectionBuilder } from "openclaw/plugin-sdk/memory-core";
|
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
|
|
export const buildPromptSection: MemoryPromptSectionBuilder = ({
|
|
availableTools,
|
|
citationsMode,
|
|
}) => {
|
|
if (!availableTools.has("memory_search") && !availableTools.has("memory_get")) {
|
|
return [];
|
|
}
|
|
const lines = [
|
|
"## Memory Recall",
|
|
"Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md; then use memory_get to pull only the needed lines. If low confidence after search, say you checked.",
|
|
];
|
|
if (citationsMode === "off") {
|
|
lines.push(
|
|
"Citations are disabled: do not mention file paths or line numbers in replies unless the user explicitly asks.",
|
|
);
|
|
} else {
|
|
lines.push(
|
|
"Citations: include Source: <path#line> when it helps the user verify memory snippets.",
|
|
);
|
|
}
|
|
lines.push("");
|
|
return lines;
|
|
};
|
|
|
|
export default definePluginEntry({
|
|
id: "memory-core",
|
|
name: "Memory (Core)",
|
|
description: "File-backed memory search tools and CLI",
|
|
kind: "memory",
|
|
register(api) {
|
|
api.registerMemoryPromptSection(buildPromptSection);
|
|
|
|
api.registerTool(
|
|
(ctx) =>
|
|
api.runtime.tools.createMemorySearchTool({
|
|
config: ctx.config,
|
|
agentSessionKey: ctx.sessionKey,
|
|
}),
|
|
{ names: ["memory_search"] },
|
|
);
|
|
|
|
api.registerTool(
|
|
(ctx) =>
|
|
api.runtime.tools.createMemoryGetTool({
|
|
config: ctx.config,
|
|
agentSessionKey: ctx.sessionKey,
|
|
}),
|
|
{ names: ["memory_get"] },
|
|
);
|
|
|
|
api.registerCli(
|
|
({ program }) => {
|
|
api.runtime.tools.registerMemoryCli(program);
|
|
},
|
|
{ commands: ["memory"] },
|
|
);
|
|
},
|
|
});
|