From d1f93894adfbe574aab76feb3f286564ae2a4e1f Mon Sep 17 00:00:00 2001 From: Johnny Date: Sat, 28 Mar 2026 00:53:07 +0800 Subject: [PATCH] feat(openclaw-plugin): add configurable capture skipSessionPatterns Allow users to configure session key substrings to skip memory capture via config option (default: [:cron:]). Previously, only cron sessions were hard-coded to skip. This change makes the filter configurable so users can exclude specific agents or session types from memory capture without code changes. Example config: capture: { skipSessionPatterns: [:cron:, agent:wechat] } Co-authored-by: duoyidavid --- apps/memos-local-openclaw/src/capture/index.ts | 9 +++++++++ apps/memos-local-openclaw/src/config.ts | 1 + apps/memos-local-openclaw/src/index.ts | 2 +- apps/memos-local-openclaw/src/types.ts | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/memos-local-openclaw/src/capture/index.ts b/apps/memos-local-openclaw/src/capture/index.ts index 10d5282c6..69945a528 100644 --- a/apps/memos-local-openclaw/src/capture/index.ts +++ b/apps/memos-local-openclaw/src/capture/index.ts @@ -62,11 +62,20 @@ export function captureMessages( log: Logger, owner?: string, userSearchTime?: number, + skipSessionPatterns?: string[], ): ConversationMessage[] { const now = Date.now(); const result: ConversationMessage[] = []; let lastTimestamp = 0; + // Skip capturing sessions matching configured patterns (e.g. [":cron:", "agent:wechat"]). + if (sessionKey && skipSessionPatterns && skipSessionPatterns.length > 0) { + if (skipSessionPatterns.some(p => sessionKey.includes(p))) { + log.debug(`Skipping filtered session capture: ${sessionKey}`); + return result; + } + } + for (const msg of messages) { const role = msg.role as Role; if (SKIP_ROLES.has(role)) continue; diff --git a/apps/memos-local-openclaw/src/config.ts b/apps/memos-local-openclaw/src/config.ts index 150b09cc4..61519be67 100644 --- a/apps/memos-local-openclaw/src/config.ts +++ b/apps/memos-local-openclaw/src/config.ts @@ -72,6 +72,7 @@ export function resolveConfig(raw: Partial | undefined, stateD }, capture: { evidenceWrapperTag: cfg.capture?.evidenceWrapperTag ?? DEFAULTS.evidenceWrapperTag, + skipSessionPatterns: cfg.capture?.skipSessionPatterns ?? [":cron:"], }, telemetry: { enabled: telemetryEnabled, diff --git a/apps/memos-local-openclaw/src/index.ts b/apps/memos-local-openclaw/src/index.ts index abf3e3590..977c800f1 100644 --- a/apps/memos-local-openclaw/src/index.ts +++ b/apps/memos-local-openclaw/src/index.ts @@ -92,7 +92,7 @@ export function initPlugin(opts: PluginInitOptions = {}): MemosLocalPlugin { const userSearchTime = sharedState.lastSearchTime || 0; sharedState.lastSearchTime = 0; - const captured = captureMessages(messages, session, turnId, tag, ctx.log, owner, userSearchTime); + const captured = captureMessages(messages, session, turnId, tag, ctx.log, owner, userSearchTime, ctx.config.capture?.skipSessionPatterns); if (captured.length > 0) { worker.enqueue(captured); } diff --git a/apps/memos-local-openclaw/src/types.ts b/apps/memos-local-openclaw/src/types.ts index 88a853f09..6586a82d4 100644 --- a/apps/memos-local-openclaw/src/types.ts +++ b/apps/memos-local-openclaw/src/types.ts @@ -318,6 +318,8 @@ export interface MemosLocalConfig { }; capture?: { evidenceWrapperTag?: string; + /** Session key substrings to skip capture entirely (e.g. [":cron:", "agent:wechat"]). Default: [":cron:"] */ + skipSessionPatterns?: string[]; }; skillEvolution?: SkillEvolutionConfig; telemetry?: TelemetryConfig;