Skip to content

Commit 902ada3

Browse files
Banger455Max Eschbach
andauthored
fix: remove duplicate memory_compact registration + redundant schema required (OpenClaw 2026.4.5 compat) (#541)
* fix: remove duplicate memory_compact tool registration in index.ts memory_compact was registered twice when enableManagementTools is true: once via registerAllMemoryTools() → registerMemoryCompactTool() in src/tools.ts, and again in a standalone block in index.ts (lines 2116–2202). OpenClaw 2026.4.5 now throws on duplicate tool name registration, causing plugin initialization failure. The standalone block in index.ts is the stale duplicate — the canonical implementation lives in src/tools.ts and is already wired through registerAllMemoryTools(). * fix: remove redundant required: ["embedding"] from configSchema root OpenClaw 2026.4.5 changed how config values are passed to the AJV validator during framework-level validation. The root-level required: ["embedding"] constraint fails because the config object reaching the validator may not have the embedding key at the time of framework validation (timing/default-handling change). This constraint was always redundant: the plugin's own parsePluginConfig() already validates embedding.apiKey presence at load time, and embedding.required: ["apiKey"] in the sub-schema still catches misconfiguration. --------- Co-authored-by: Max Eschbach <maxeschbach@macbookair.local>
1 parent aa0d229 commit 902ada3

2 files changed

Lines changed: 1 addition & 92 deletions

File tree

index.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,94 +2113,6 @@ const memoryLanceDBProPlugin = {
21132113
}
21142114
);
21152115

2116-
// ========================================================================
2117-
// Memory Compaction (Progressive Summarization)
2118-
// ========================================================================
2119-
2120-
if (config.enableManagementTools) {
2121-
api.registerTool({
2122-
name: "memory_compact",
2123-
description:
2124-
"Consolidate semantically similar old memories into refined single entries " +
2125-
"(progressive summarization). Reduces noise and improves retrieval quality over time. " +
2126-
"Use dry_run:true first to preview the compaction plan without making changes.",
2127-
inputSchema: {
2128-
type: "object" as const,
2129-
properties: {
2130-
dry_run: {
2131-
type: "boolean",
2132-
description: "Preview clusters without writing changes. Default: false.",
2133-
},
2134-
min_age_days: {
2135-
type: "number",
2136-
description: "Only compact memories at least this many days old. Default: 7.",
2137-
},
2138-
similarity_threshold: {
2139-
type: "number",
2140-
description: "Cosine similarity threshold for clustering [0-1]. Default: 0.88.",
2141-
},
2142-
scopes: {
2143-
type: "array",
2144-
items: { type: "string" },
2145-
description: "Scope filter. Omit to compact all scopes.",
2146-
},
2147-
},
2148-
required: [],
2149-
},
2150-
execute: async (args: Record<string, unknown>) => {
2151-
const compactionCfg: CompactionConfig = {
2152-
enabled: true,
2153-
minAgeDays:
2154-
typeof args.min_age_days === "number"
2155-
? args.min_age_days
2156-
: (config.memoryCompaction?.minAgeDays ?? 7),
2157-
similarityThreshold:
2158-
typeof args.similarity_threshold === "number"
2159-
? Math.max(0, Math.min(1, args.similarity_threshold))
2160-
: (config.memoryCompaction?.similarityThreshold ?? 0.88),
2161-
minClusterSize: config.memoryCompaction?.minClusterSize ?? 2,
2162-
maxMemoriesToScan: config.memoryCompaction?.maxMemoriesToScan ?? 200,
2163-
dryRun: args.dry_run === true,
2164-
cooldownHours: config.memoryCompaction?.cooldownHours ?? 24,
2165-
};
2166-
const scopes =
2167-
Array.isArray(args.scopes) && args.scopes.length > 0
2168-
? (args.scopes as string[])
2169-
: undefined;
2170-
2171-
const result = await runCompaction(
2172-
store,
2173-
embedder,
2174-
compactionCfg,
2175-
scopes,
2176-
api.logger,
2177-
);
2178-
2179-
return {
2180-
content: [
2181-
{
2182-
type: "text",
2183-
text: JSON.stringify(
2184-
{
2185-
scanned: result.scanned,
2186-
clustersFound: result.clustersFound,
2187-
memoriesDeleted: result.memoriesDeleted,
2188-
memoriesCreated: result.memoriesCreated,
2189-
dryRun: result.dryRun,
2190-
summary: result.dryRun
2191-
? `Dry run: found ${result.clustersFound} cluster(s) in ${result.scanned} memories — no changes made.`
2192-
: `Compacted ${result.memoriesDeleted} memories into ${result.memoriesCreated} consolidated entries.`,
2193-
},
2194-
null,
2195-
2,
2196-
),
2197-
},
2198-
],
2199-
};
2200-
},
2201-
});
2202-
}
2203-
22042116
// Auto-compaction at gateway_start (if enabled, respects cooldown)
22052117
if (config.memoryCompaction?.enabled) {
22062118
api.on("gateway_start", () => {

openclaw.plugin.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,7 @@
854854
}
855855
}
856856
}
857-
},
858-
"required": [
859-
"embedding"
860-
]
857+
}
861858
},
862859
"uiHints": {
863860
"embedding.apiKey": {

0 commit comments

Comments
 (0)