Skip to content

Commit 4f11210

Browse files
authored
fix(openclaw): avoid memory retain recursion (#362)
1 parent e408b7e commit 4f11210

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

hindsight-docs/docs/sdks/integrations/openclaw.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ The plugin will automatically:
5959

6060
**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.
6161

62+
**Feedback Loop Prevention:** The plugin automatically strips injected memory tags (`<hindsight_memories>`) before storing conversations. This prevents recalled memories from being re-extracted as new facts, which would cause exponential memory growth and duplicate entries.
63+
6264
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.
6365

6466
## Configuration

hindsight-integrations/openclaw/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hindsight-integrations/openclaw/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ User message: ${prompt}
702702
.join('\n');
703703
}
704704

705+
// Strip plugin-injected memory tags to prevent feedback loop
706+
// Remove <hindsight_memories> blocks injected during before_agent_start
707+
content = content.replace(/<hindsight_memories>[\s\S]*?<\/hindsight_memories>/g, '');
708+
// Remove any <relevant_memories> blocks (legacy/alternative format)
709+
content = content.replace(/<relevant_memories>[\s\S]*?<\/relevant_memories>/g, '');
710+
705711
return `[role: ${role}]\n${content}\n[${role}:end]`;
706712
})
707713
.join('\n\n');

0 commit comments

Comments
 (0)