OpenClaw plugin: fix auto-recall injection and auto-capture message drop (#4065)
This commit is contained in:
+6
-5
@@ -1274,7 +1274,7 @@ const memoryPlugin = {
|
||||
);
|
||||
|
||||
return {
|
||||
systemContext: `<relevant-memories>\nThe following memories may be relevant to this conversation:\n${memoryContext}\n</relevant-memories>`,
|
||||
prependContext: `<relevant-memories>\nThe following memories may be relevant to this conversation:\n${memoryContext}\n</relevant-memories>`,
|
||||
};
|
||||
} catch (err) {
|
||||
api.logger.warn(`openclaw-mem0: recall failed: ${String(err)}`);
|
||||
@@ -1318,8 +1318,6 @@ const memoryPlugin = {
|
||||
if (
|
||||
block &&
|
||||
typeof block === "object" &&
|
||||
"type" in block &&
|
||||
(block as Record<string, unknown>).type === "text" &&
|
||||
"text" in block &&
|
||||
typeof (block as Record<string, unknown>).text === "string"
|
||||
) {
|
||||
@@ -1331,8 +1329,11 @@ const memoryPlugin = {
|
||||
}
|
||||
|
||||
if (!textContent) continue;
|
||||
// Skip injected memory context
|
||||
if (textContent.includes("<relevant-memories>")) continue;
|
||||
// Strip injected memory context, keep the actual user text
|
||||
if (textContent.includes("<relevant-memories>")) {
|
||||
textContent = textContent.replace(/<relevant-memories>[\s\S]*?<\/relevant-memories>\s*/g, "").trim();
|
||||
if (!textContent) continue;
|
||||
}
|
||||
|
||||
formattedMessages.push({
|
||||
role: role as string,
|
||||
|
||||
Reference in New Issue
Block a user