From eaf21415830c580fa63fcadd335e65e7d9f729cf Mon Sep 17 00:00:00 2001 From: JasonOA888 Date: Fri, 27 Mar 2026 22:12:19 +0800 Subject: [PATCH] fix(plugin): exclude cron/maintenance tasks from ingest-reply-assist The isTranscriptLikeIngest heuristic misclassified cron maintenance prompts (daily distillation, weekly synthesis) as transcript-ingestion input, causing unwanted ingest-reply-assist prompt injection. Example misclassified prompt: "Daily memory maintenance. Read skills/opencortex/references/distillation.md for full instructions. Workspace: /Users/user/.openclaw/workspace" This was matched because "Workspace: /path" triggered the SPEAKER_TAG_RE twice, satisfying the minSpeakerTurns(2) threshold. Fix: Add CRON_MAINTENANCE_RE pattern that detects: - daily/weekly/monthly maintenance/distillation/synthesis/cleanup keywords - Workspace:/workspace path patterns - cron/scheduled task markers - OpenClaw cron/workspace references These patterns are checked before speaker-turn counting, ensuring maintenance tasks are excluded early without affecting genuine transcript detection. Fixes #982 --- examples/openclaw-plugin/text-utils.ts | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/openclaw-plugin/text-utils.ts b/examples/openclaw-plugin/text-utils.ts index 40f224a45..da3197b04 100644 --- a/examples/openclaw-plugin/text-utils.ts +++ b/examples/openclaw-plugin/text-utils.ts @@ -28,6 +28,22 @@ const QUESTION_CUE_RE = /[??]|\b(?:what|when|where|who|why|how|which|can|could|would|did|does|is|are)\b|^(?:请问|能否|可否|怎么|如何|什么时候|谁|什么|哪|是否)/i; const SPEAKER_TAG_RE = /(?:^|\s)([A-Za-z\u4e00-\u9fa5][A-Za-z0-9_\u4e00-\u9fa5-]{1,30}):\s/g; +/** Patterns that indicate cron/maintenance/scheduled tasks — these should never + * receive ingest-reply-assist because they are control/maintenance prompts, + * not memory-ingestion transcripts. See issue #982. */ +const CRON_MAINTENANCE_RE = new RegExp( + [ + /\b(?:daily|weekly|monthly)\s+(?:memory\s+)?(?:maintenance|distillation|synthesis|cleanup|review)/i, + /\b(?:distillation|synthesis)\.md\b/i, + /\bread\s+skills\//i, + /\b(?:cron|scheduled)\s+(?:task|job|run|prompt)/i, + /\bworkspace:\s*\/[\w/.]/, + /\bopenclaw\s+(?:cron|workspace)/i, + ] + .map((r) => r.source) + .join("|"), +); + export const CAPTURE_LIMIT = 3; function resolveCaptureMinLength(text: string): number { @@ -146,6 +162,19 @@ export function isTranscriptLikeIngest( }; } + // Exclude cron / maintenance / scheduled task prompts from ingest-reply-assist. + // These are control/maintenance instructions, not memory-ingestion transcripts. + // See https://github.com/volcengine/OpenViking/issues/982 + if (CRON_MAINTENANCE_RE.test(normalizedText)) { + return { + shouldAssist: false, + reason: "cron_maintenance_task", + normalizedText, + speakerTurns: 0, + chars: normalizedText.length, + }; + } + const chars = normalizedText.length; if (chars < options.minChars) { return {