mr-memory 3.5.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +18 -4
  2. package/index.ts +27 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # mr-memory
2
2
 
3
- Persistent AI memory plugin for [OpenClaw](https://github.com/openclaw/openclaw). Your AI remembers every conversation.
3
+ **mr-memory OpenClaw plugin** — persistent AI memory that survives compaction and session resets.
4
4
 
5
- Powered by [MemoryRouter](https://memoryrouter.ai).
5
+ OpenClaw agents forget conversations after compaction. mr-memory fixes that. Every conversation is stored and the most relevant context is automatically injected into every response — not just at session start, but continuously.
6
+
7
+ Powered by [MemoryRouter](https://memoryrouter.ai). 50M tokens free.
6
8
 
7
9
  ## Install
8
10
 
@@ -38,9 +40,21 @@ openclaw mr upload --brain <dir> # Custom state dir (sessions from another
38
40
 
39
41
  ## How It Works
40
42
 
41
- When enabled, all LLM calls route through MemoryRouter which injects relevant past context and captures new conversations. Your provider API keys pass through untouched (BYOK).
43
+ When enabled, the **mr-memory OpenClaw plugin** routes all LLM calls through MemoryRouter, which automatically:
44
+
45
+ 1. **Retrieves** relevant memories from past conversations before every response
46
+ 2. **Injects** that context into the prompt so the agent knows what's happened before
47
+ 3. **Stores** new conversations for future recall
48
+
49
+ Your provider API keys pass through untouched (BYOK). Only direct user-to-AI conversation is stored — tool use and subagent work are excluded automatically.
50
+
51
+ ## Why mr-memory
42
52
 
43
- Only direct user-to-AI conversation is stored. Tool use and subagent work are excluded automatically.
53
+ - **Survives compaction** memories persist even when OpenClaw summarizes/compacts conversation history
54
+ - **Survives restarts** — stored externally, not in the session
55
+ - **Full fidelity** — stores raw conversations, not lossy summaries
56
+ - **Continuous** — queries memory on every message, not just session start
57
+ - **Zero config** — one command install, one command setup
44
58
 
45
59
  ## Config
46
60
 
package/index.ts CHANGED
@@ -246,6 +246,15 @@ function isSystemNoise(text: string): boolean {
246
246
  return SYSTEM_NOISE_PATTERNS.some(pattern => pattern.test(trimmed));
247
247
  }
248
248
 
249
+ /** Strip cron/system prefixes from prompts, keeping the actual task content.
250
+ * Used for prepare context building — we want the mission text, not the tag. */
251
+ function stripSystemPrefixes(text: string): string {
252
+ return text
253
+ .replace(/^\[cron:[^\]]+\]\s*/i, "")
254
+ .replace(/^A background task "[^"]*" just completed[^\n]*\n*/i, "")
255
+ .trim();
256
+ }
257
+
249
258
  /**
250
259
  * Detect OpenClaw compaction summary blobs — large user messages containing
251
260
  * interleaved [USER] and [ASSISTANT] markers from conversation history dumps.
@@ -464,8 +473,12 @@ const memoryRouterPlugin = {
464
473
  }
465
474
  }
466
475
  const cleanedPrompt = sanitizeForIngest(prompt);
467
- if (cleanedPrompt && !isSystemNoise(cleanedPrompt)) {
468
- contextPayload.push({ role: "user", content: cleanedPrompt });
476
+ if (cleanedPrompt) {
477
+ // Strip cron/system prefixes but keep the task content for memory search
478
+ const taskPrompt = stripSystemPrefixes(cleanedPrompt);
479
+ if (taskPrompt && !isSystemNoise(taskPrompt)) {
480
+ contextPayload.push({ role: "user", content: taskPrompt });
481
+ }
469
482
  }
470
483
 
471
484
 
@@ -575,8 +588,12 @@ const memoryRouterPlugin = {
575
588
 
576
589
  // Add current user prompt (sanitized)
577
590
  const cleanedPrompt = sanitizeForIngest(prompt);
578
- if (cleanedPrompt && !isSystemNoise(cleanedPrompt)) {
579
- contextPayload.push({ role: "user", content: cleanedPrompt });
591
+ if (cleanedPrompt) {
592
+ // Strip cron/system prefixes but keep the task content for memory search
593
+ const taskPrompt = stripSystemPrefixes(cleanedPrompt);
594
+ if (taskPrompt && !isSystemNoise(taskPrompt)) {
595
+ contextPayload.push({ role: "user", content: taskPrompt });
596
+ }
580
597
  }
581
598
 
582
599
  // 4. Call /v1/memory/prepare (no session_id — always search core vault)
@@ -671,8 +688,12 @@ const memoryRouterPlugin = {
671
688
  if (userText) {
672
689
  // Sanitize: strip memory injections, envelope metadata, and system noise
673
690
  userText = sanitizeForIngest(stripMediaReferences(userText));
674
- if (userText && !isSystemNoise(userText)) {
675
- toStore.push({ role: "user", content: userText });
691
+ if (userText) {
692
+ // Strip cron/system prefixes but keep the task content for storage
693
+ const taskText = stripSystemPrefixes(userText);
694
+ if (taskText && !isSystemNoise(taskText)) {
695
+ toStore.push({ role: "user", content: taskText });
696
+ }
676
697
  }
677
698
  }
678
699
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [