docs: update memory tool list, CLI usage, and config file reading logic (#4861)

Co-authored-by: Livia Ellen <liviaellen@msn.com>
This commit is contained in:
Kartik
2026-04-20 20:09:45 +05:30
committed by GitHub
co-authored by Livia Ellen
parent 5520226b5b
commit 4e611e8dba
31 changed files with 1530 additions and 364 deletions
+75 -2
View File
@@ -14,9 +14,41 @@ const NOISE_MESSAGE_PATTERNS: RegExp[] = [
/^(HEARTBEAT_OK|NO_REPLY)$/i,
/^Current time:.*\d{4}/,
/^Pre-compaction memory flush/i,
/^(ok|yes|no|sir|sure|thanks|done|good|nice|cool|got it|it's on|continue)$/i,
/^(ok|yes|no|sir|sure|thanks|done|good|nice|cool|got it|it's on|continue|alright|okay|yep|nope|uh-huh|mm-hmm|hmm)$/i,
/^System: \[.*\] (Slack message edited|Gateway restart|Exec (failed|completed))/,
/^System: \[.*\] ⚠️ Post-Compaction Audit:/,
// JSON-only messages (tool results, metadata)
/^[\s]*\{[\s\S]*\}[\s]*$/,
/^[\s]*\[[\s\S]*\][\s]*$/,
// Empty or whitespace-only after trimming
/^[\s\n\r]*$/,
// Technical noise patterns
/^(Error|Warning|Info|Debug):/i,
/^(Loading|Loaded|Fetching|Fetched|Processing|Processed)\b/i,
/^\[[\d:T\-\.Z]+\]/, // Timestamps like [2024-01-01T12:00:00.000Z]
/^(SUCCESS|FAILURE|PENDING|COMPLETED|FAILED)$/i,
// Tool/function call noise
/^(Calling|Called|Invoking|Invoked|Executing|Executed)\s+(function|tool|method)/i,
/^Tool (call|result|output):/i,
// Single emoji or very short messages
/^[\p{Emoji}\s]{1,5}$/u,
];
/** Patterns for session-specific technical content that should not be stored as memories. */
const SESSION_SPECIFIC_PATTERNS: RegExp[] = [
// Tool availability discussions
/tools?\s+(are|is)\s+(not\s+)?(exposed|available|accessible)/i,
/plugin\s+(does not|doesn't)\s+expose/i,
/I\s+(do not|don't)\s+(currently\s+)?see\s+.*tools?\s+exposed/i,
/memory_(search|get|add|update|delete|list)\s+(tool|is|are)/i,
// Session-specific capability statements
/in\s+this\s+session/i,
/my\s+(live\s+)?callable\s+tool\s+registry/i,
/tools?\s+I\s+(have|currently have)\s+access\s+to/i,
// Plugin/capability status statements
/openclaw-mem0\s+plugin/i,
/memory\s+wiki.*capability/i,
/workspace\s+memory\s+files/i,
];
/** Content fragments that should be stripped from otherwise-valid messages. */
@@ -50,6 +82,31 @@ const NOISE_CONTENT_PATTERNS: Array<{ pattern: RegExp; replacement: string }> =
/Replied message \(untrusted, for context\):\s*```json[\s\S]*?```/g,
replacement: "",
},
// Strip embedded JSON blocks that might contain metadata
{
pattern: /```json\s*\{[\s\S]*?\}\s*```/g,
replacement: "",
},
// Strip code blocks that are just tool outputs
{
pattern: /```(?:text|output|result|log)\s*[\s\S]*?```/gi,
replacement: "",
},
// Strip inline tool call IDs
{
pattern: /\[tool_call_id:[^\]]+\]/g,
replacement: "",
},
// Strip memory IDs from responses
{
pattern: /\(id:\s*[a-f0-9-]+\)/gi,
replacement: "",
},
// Strip session/run IDs
{
pattern: /(?:session|run|agent)[_-]?(?:id|key)?:\s*[a-zA-Z0-9_:-]+/gi,
replacement: "",
},
];
const MAX_MESSAGE_LENGTH = 2000;
@@ -81,6 +138,20 @@ export function isNoiseMessage(content: string): boolean {
return NOISE_MESSAGE_PATTERNS.some((p) => p.test(trimmed));
}
/**
* Check whether a message contains session-specific technical content
* that should not be stored (tool availability discussions, plugin
* capability statements, etc.). These are facts about the current session
* that have no value in future sessions.
*/
export function isSessionSpecificContent(content: string): boolean {
const trimmed = content.trim();
if (!trimmed) return false;
// Check if multiple session-specific patterns match (more confident filtering)
const matches = SESSION_SPECIFIC_PATTERNS.filter((p) => p.test(trimmed));
return matches.length >= 2;
}
/**
* Check whether an assistant message is a generic acknowledgment with no
* extractable facts (e.g. "I see you've shared an update. How can I help?").
@@ -120,7 +191,7 @@ function truncateMessage(content: string): string {
/**
* Full pre-extraction pipeline: drop noise messages, strip noise fragments,
* and truncate remaining messages to a reasonable length.
* filter session-specific content, and truncate remaining messages.
*/
export function filterMessagesForExtraction(
messages: Array<{ role: string; content: string }>,
@@ -131,6 +202,8 @@ export function filterMessagesForExtraction(
// Drop generic assistant acknowledgments that contain no facts
if (msg.role === "assistant" && isGenericAssistantMessage(msg.content))
continue;
// Drop session-specific technical content (tool availability, plugin capabilities)
if (isSessionSpecificContent(msg.content)) continue;
const cleaned = stripNoiseFromContent(msg.content);
if (!cleaned) continue;
filtered.push({ role: msg.role, content: truncateMessage(cleaned) });