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 {
|
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) {
|
} catch (err) {
|
||||||
api.logger.warn(`openclaw-mem0: recall failed: ${String(err)}`);
|
api.logger.warn(`openclaw-mem0: recall failed: ${String(err)}`);
|
||||||
@@ -1318,8 +1318,6 @@ const memoryPlugin = {
|
|||||||
if (
|
if (
|
||||||
block &&
|
block &&
|
||||||
typeof block === "object" &&
|
typeof block === "object" &&
|
||||||
"type" in block &&
|
|
||||||
(block as Record<string, unknown>).type === "text" &&
|
|
||||||
"text" in block &&
|
"text" in block &&
|
||||||
typeof (block as Record<string, unknown>).text === "string"
|
typeof (block as Record<string, unknown>).text === "string"
|
||||||
) {
|
) {
|
||||||
@@ -1331,8 +1329,11 @@ const memoryPlugin = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!textContent) continue;
|
if (!textContent) continue;
|
||||||
// Skip injected memory context
|
// Strip injected memory context, keep the actual user text
|
||||||
if (textContent.includes("<relevant-memories>")) continue;
|
if (textContent.includes("<relevant-memories>")) {
|
||||||
|
textContent = textContent.replace(/<relevant-memories>[\s\S]*?<\/relevant-memories>\s*/g, "").trim();
|
||||||
|
if (!textContent) continue;
|
||||||
|
}
|
||||||
|
|
||||||
formattedMessages.push({
|
formattedMessages.push({
|
||||||
role: role as string,
|
role: role as string,
|
||||||
|
|||||||
Reference in New Issue
Block a user