From 4f112101ac3f94aad48f712f0fbd39167d5a6ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Fri, 13 Feb 2026 10:47:39 +0100 Subject: [PATCH] fix(openclaw): avoid memory retain recursion (#362) --- hindsight-docs/docs/sdks/integrations/openclaw.md | 2 ++ hindsight-integrations/openclaw/package-lock.json | 4 ++-- hindsight-integrations/openclaw/src/index.ts | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hindsight-docs/docs/sdks/integrations/openclaw.md b/hindsight-docs/docs/sdks/integrations/openclaw.md index ebb9458d..bcd1567e 100644 --- a/hindsight-docs/docs/sdks/integrations/openclaw.md +++ b/hindsight-docs/docs/sdks/integrations/openclaw.md @@ -59,6 +59,8 @@ The plugin will automatically: **Auto-Recall:** Before each agent response, relevant memories are automatically injected into the context (up to 1024 tokens). The agent uses past context without needing to call tools. +**Feedback Loop Prevention:** The plugin automatically strips injected memory tags (``) before storing conversations. This prevents recalled memories from being re-extracted as new facts, which would cause exponential memory growth and duplicate entries. + Traditional memory systems give agents a `search_memory` tool - but models don't use it consistently. Auto-recall solves this by injecting memories automatically before every turn. ## Configuration diff --git a/hindsight-integrations/openclaw/package-lock.json b/hindsight-integrations/openclaw/package-lock.json index bf27d69e..af9d6fcd 100644 --- a/hindsight-integrations/openclaw/package-lock.json +++ b/hindsight-integrations/openclaw/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vectorize-io/hindsight-openclaw", - "version": "0.4.7", + "version": "0.4.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@vectorize-io/hindsight-openclaw", - "version": "0.4.7", + "version": "0.4.10", "license": "MIT", "dependencies": { "node-fetch": "^3.3.2" diff --git a/hindsight-integrations/openclaw/src/index.ts b/hindsight-integrations/openclaw/src/index.ts index a72d19c8..6353316b 100644 --- a/hindsight-integrations/openclaw/src/index.ts +++ b/hindsight-integrations/openclaw/src/index.ts @@ -702,6 +702,12 @@ User message: ${prompt} .join('\n'); } + // Strip plugin-injected memory tags to prevent feedback loop + // Remove blocks injected during before_agent_start + content = content.replace(/[\s\S]*?<\/hindsight_memories>/g, ''); + // Remove any blocks (legacy/alternative format) + content = content.replace(/[\s\S]*?<\/relevant_memories>/g, ''); + return `[role: ${role}]\n${content}\n[${role}:end]`; }) .join('\n\n');