Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(plugins): filter hook capture before truncation (#5375)
z1gon4edc30b06893
diff --git a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.jsonindex 5caf00999..5179ed3cd 100644--- a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json+++ b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json@@ -1,7 +1,7 @@{"schemaVersion": 1,"id": "openviking-memory",- "version": "0.5.2",+ "version": "0.5.3","clients": ["cursor"],diff --git a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.jsonindex 5c7daf397..1a93eb6da 100644--- a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json+++ b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json@@ -1,7 +1,7 @@{"schemaVersion": 1,"id": "openviking-memory",- "version": "0.5.2",+ "version": "0.5.3","clients": ["kimicode"],diff --git a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json b/examples/agent-hook-plugin/hosts/trae/openviking.integration.jsonindex 186c7e954..4b1e6171e 100644--- a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json+++ b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json@@ -1,7 +1,7 @@{"schemaVersion": 1,"id": "openviking-memory",- "version": "0.5.2",+ "version": "0.5.3","clients": ["trae","trae-cn"diff --git a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.jsonindex 79e96a2ed..38e72fa4a 100644--- a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json+++ b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json@@ -1,7 +1,7 @@{"schemaVersion": 1,"id": "openviking-memory",- "version": "0.5.2",+ "version": "0.5.3","clients": ["zcode"],diff --git a/examples/agent-hook-plugin/plugin.json b/examples/agent-hook-plugin/plugin.jsonindex da1c6d776..ae32fefe1 100644--- a/examples/agent-hook-plugin/plugin.json+++ b/examples/agent-hook-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "agent-hook-plugin",- "version": "0.5.2",+ "version": "0.5.3","description": "Long-term semantic memory for Cursor, TRAE, TRAE CN, ZCode and Kimi Code — powered by OpenViking. Auto-recall relevant memories and capture the conversation as it happens.","author": {"name": "OpenViking",diff --git a/examples/agent-hook-plugin/tests/zcode-capture.test.mjs b/examples/agent-hook-plugin/tests/zcode-capture.test.mjsindex 97a44c4e2..35c476976 100644--- a/examples/agent-hook-plugin/tests/zcode-capture.test.mjs+++ b/examples/agent-hook-plugin/tests/zcode-capture.test.mjs@@ -73,6 +73,15 @@ test("oversized turns are truncated to captureMaxLength before they are sent", (assert.equal(wider.payloads[0].content, long.trim());});+test("Zcode filters the full turn before capping the payload", () => {+ const turn = { role: "user", content: `Remember ${"x".repeat(100)} SECRET123`, turnId: "turn-001" };+ const plan = buildZcodeCapturePlan([turn], {}, {+ captureMaxLength: 64,+ captureFilters: ["d/SECRET123/"],+ });+ assert.deepEqual(plan.payloads, []);+});+test("non-retryable failure keeps cursor, dedup, and pending prompt unchanged", () => {const state = {lastTurnId: "turn-000",diff --git a/examples/claude-code-memory-plugin/.claude-plugin/plugin.json b/examples/claude-code-memory-plugin/.claude-plugin/plugin.jsonindex cb0c4f12e..c4a74c4e1 100644--- a/examples/claude-code-memory-plugin/.claude-plugin/plugin.json+++ b/examples/claude-code-memory-plugin/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "openviking-memory",- "version": "0.6.3",+ "version": "0.6.4","description": "Long-term semantic memory for Claude Code, powered by OpenViking. Auto-recall relevant memories at session start and capture important information during conversations.","author": {"name": "OpenViking",diff --git a/examples/claude-code-memory-plugin/package.json b/examples/claude-code-memory-plugin/package.jsonindex e05f59619..268a557fb 100644--- a/examples/claude-code-memory-plugin/package.json+++ b/examples/claude-code-memory-plugin/package.json@@ -1,6 +1,6 @@{"name": "claude-code-openviking-memory",- "version": "0.6.3",+ "version": "0.6.4","description": "OpenViking memory plugin for Claude Code — semantic long-term memory","type": "module","scripts": {diff --git a/examples/claude-code-memory-plugin/scripts/shared/capture-utils.mjs b/examples/claude-code-memory-plugin/scripts/shared/capture-utils.mjsindex a606ff44b..70f0bad1b 100644--- a/examples/claude-code-memory-plugin/scripts/shared/capture-utils.mjs+++ b/examples/claude-code-memory-plugin/scripts/shared/capture-utils.mjs@@ -642,16 +642,18 @@ export function shouldCaptureText(text, role, cfg = {}, { filters = true } = {})const sanitized = sanitizeCapturedText(text);if (!sanitized) return { shouldCapture: false, reason: "empty", text: "" };- let capped = truncateCaptureText(sanitized, maxLength);+ // Rules judge the full sanitized turn; the wire cap applies afterward.+ let filtered = sanitized;if (filters) {const compiled = compileInputFilters(cfg?.captureFilters);if (compiled.rules.length) {- const verdict = applyInputFilters(capped, compiled.rules, { role });+ const verdict = applyInputFilters(filtered, compiled.rules, { role });if (verdict.dropped) return { shouldCapture: false, reason: "filtered", text: "" };- capped = verdict.text;- if (!capped) return { shouldCapture: false, reason: "empty", text: "" };+ filtered = verdict.text;+ if (!filtered) return { shouldCapture: false, reason: "empty", text: "" };}}+ const capped = truncateCaptureText(filtered, maxLength);const compact = oneLine(capped);const isToolSummary = /^\[tool-(?:call|result)\b/i.test(compact);diff --git a/examples/codex-memory-plugin/.codex-plugin/plugin.json b/examples/codex-memory-plugin/.codex-plugin/plugin.jsonindex 7a5c04551..122744a78 100644--- a/examples/codex-memory-plugin/.codex-plugin/plugin.json+++ b/examples/codex-memory-plugin/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "openviking-memory",- "version": "0.10.3",+ "version": "0.10.4","description": "Long-term semantic memory for Codex, powered by OpenViking. Recall on UserPromptSubmit, incremental add_message on Stop (per turn), commit on SessionEnd (Codex >= 0.145) and on PreCompact, with an idle/ended sweep on SessionStart as the fallback for signals, crashes and older Codex builds. Includes a local stdio MCP proxy that reads OpenViking credentials from env/ovcli.conf.","author": {"name": "OpenViking",diff --git a/examples/codex-memory-plugin/scripts/shared/capture-utils.mjs b/examples/codex-memory-plugin/scripts/shared/capture-utils.mjsindex a606ff44b..70f0bad1b 100644--- a/examples/codex-memory-plugin/scripts/shared/capture-utils.mjs+++ b/examples/codex-memory-plugin/scripts/shared/capture-utils.mjs@@ -642,16 +642,18 @@ export function shouldCaptureText(text, role, cfg = {}, { filters = true } = {})const sanitized = sanitizeCapturedText(text);if (!sanitized) return { shouldCapture: false, reason: "empty", text: "" };- let capped = truncateCaptureText(sanitized, maxLength);+ // Rules judge the full sanitized turn; the wire cap applies afterward.+ let filtered = sanitized;if (filters) {const compiled = compileInputFilters(cfg?.captureFilters);if (compiled.rules.length) {- const verdict = applyInputFilters(capped, compiled.rules, { role });+ const verdict = applyInputFilters(filtered, compiled.rules, { role });if (verdict.dropped) return { shouldCapture: false, reason: "filtered", text: "" };- capped = verdict.text;- if (!capped) return { shouldCapture: false, reason: "empty", text: "" };+ filtered = verdict.text;+ if (!filtered) return { shouldCapture: false, reason: "empty", text: "" };}}+ const capped = truncateCaptureText(filtered, maxLength);const compact = oneLine(capped);const isToolSummary = /^\[tool-(?:call|result)\b/i.test(compact);diff --git a/examples/dsh-memory-plugin/config.mjs b/examples/dsh-memory-plugin/config.mjsindex 43664c6c1..1cc397995 100644--- a/examples/dsh-memory-plugin/config.mjs+++ b/examples/dsh-memory-plugin/config.mjs@@ -1,7 +1,7 @@import { buildPluginConfig } from "./shared/plugin-config.mjs";import { loadCredentialFiles } from "./shared/credentials.mjs";-export const PLUGIN_VERSION = "0.5.4";+export const PLUGIN_VERSION = "0.5.5";/*** Namespace for the bridged OpenViking MCP tools. DSH publishes every MCP tooldiff --git a/examples/dsh-memory-plugin/package-lock.json b/examples/dsh-memory-plugin/package-lock.jsonindex 9d7494971..6d9e2cf30 100644--- a/examples/dsh-memory-plugin/package-lock.json+++ b/examples/dsh-memory-plugin/package-lock.json@@ -1,12 +1,12 @@{"name": "@openviking/dsh-memory-plugin",- "version": "0.5.4",+ "version": "0.5.5","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@openviking/dsh-memory-plugin",- "version": "0.5.4",+ "version": "0.5.5","license": "Apache-2.0","devDependencies": {"@deepseek-ai/dsh-llm": "0.1.0-rc.6",diff --git a/examples/dsh-memory-plugin/package.json b/examples/dsh-memory-plugin/package.jsonindex 03aa95dc1..09d7b9e99 100644--- a/examples/dsh-memory-plugin/package.json+++ b/examples/dsh-memory-plugin/package.json@@ -1,6 +1,6 @@{"name": "@openviking/dsh-memory-plugin",- "version": "0.5.4",+ "version": "0.5.5","description": "OpenViking memory and context bundle for DeepSeek Harness","type": "module","main": "index.mjs",diff --git a/examples/memory-plugin-shared/agent-hook-runtime.test.mjs b/examples/memory-plugin-shared/agent-hook-runtime.test.mjsindex c20be6e47..1a42d0301 100644--- a/examples/memory-plugin-shared/agent-hook-runtime.test.mjs+++ b/examples/memory-plugin-shared/agent-hook-runtime.test.mjs@@ -208,6 +208,22 @@ test("a turn past captureMaxLength is capped rather than dropped", () => {assert.ok(kept[0].content.startsWith("remember this detail."));});+test("hook capture rules judge sanitized text beyond the send cap", () => {+ const content = `Remember the audit result ${"x".repeat(100)} SECRET123`;+ const turn = { role: "user", content };+ const cfg = { captureMaxLength: 64, captureFilters: ["d/SECRET123/"] };+ assert.deepEqual(filterCaptureTurns([turn], cfg), {+ kept: [], dropped: [{ role: "user", reason: "filtered" }],+ });++ const kept = filterCaptureTurns([turn], {+ captureMaxLength: 64, captureFilters: ["k/SECRET123/"],+ }).kept;+ assert.equal(kept.length, 1);+ assert.ok(kept[0].content.length <= 64);+ assert.ok(kept[0].content.endsWith("[truncated]"));+});+test("filterCaptureTurns tolerates a missing or malformed turn list", () => {for (const input of [undefined, null, "text", 3, {}]) {assert.deepEqual(filterCaptureTurns(input), { kept: [], dropped: [] });@@ -235,6 +251,7 @@ test("the thin harnesses resolve the same layers as everyone else", () => {url: "http://127.0.0.1:1933",plugin: {recallLimit: 7,+ captureFilters: ["d/secret/"],cursor: { captureMode: "keyword" },"trae-cn": { scoreThreshold: 0.8 },zcode: { autoRecall: false },@@ -253,6 +270,9 @@ test("the thin harnesses resolve the same layers as everyone else", () => {// The hyphenated spelling of a harness finds the same override.assert.equal(loadAgentHookConfig("trae-cn", workspace).scoreThreshold, 0.8);assert.equal(loadAgentHookConfig("trae", workspace).scoreThreshold, 0.35);+ for (const clientId of ["cursor", "trae", "trae-cn", "zcode", "kimicode"]) {+ assert.deepEqual(loadAgentHookConfig(clientId, workspace).captureFilters, ["d/secret/"]);+ }// A workspace file outranks ovcli.conf, and the environment outranks both.writeFileSync(diff --git a/examples/memory-plugin-shared/lib/capture-utils.mjs b/examples/memory-plugin-shared/lib/capture-utils.mjsindex 2347d0562..67b0e9e37 100644--- a/examples/memory-plugin-shared/lib/capture-utils.mjs+++ b/examples/memory-plugin-shared/lib/capture-utils.mjs@@ -641,16 +641,18 @@ export function shouldCaptureText(text, role, cfg = {}, { filters = true } = {})const sanitized = sanitizeCapturedText(text);if (!sanitized) return { shouldCapture: false, reason: "empty", text: "" };- let capped = truncateCaptureText(sanitized, maxLength);+ // Rules judge the full sanitized turn; the wire cap applies afterward.+ let filtered = sanitized;if (filters) {const compiled = compileInputFilters(cfg?.captureFilters);if (compiled.rules.length) {- const verdict = applyInputFilters(capped, compiled.rules, { role });+ const verdict = applyInputFilters(filtered, compiled.rules, { role });if (verdict.dropped) return { shouldCapture: false, reason: "filtered", text: "" };- capped = verdict.text;- if (!capped) return { shouldCapture: false, reason: "empty", text: "" };+ filtered = verdict.text;+ if (!filtered) return { shouldCapture: false, reason: "empty", text: "" };}}+ const capped = truncateCaptureText(filtered, maxLength);const compact = oneLine(capped);const isToolSummary = /^\[tool-(?:call|result)\b/i.test(compact);diff --git a/examples/opencode-plugin/package.json b/examples/opencode-plugin/package.jsonindex 6d4dd1a1f..3769028f5 100644--- a/examples/opencode-plugin/package.json+++ b/examples/opencode-plugin/package.json@@ -1,6 +1,6 @@{"name": "@openviking/opencode-plugin",- "version": "0.5.1",+ "version": "0.5.2","author": "@openviking","description": "Unified OpenCode plugin for OpenViking repository retrieval and long-term memory","type": "module",diff --git a/examples/pi-coding-agent-extension/package-lock.json b/examples/pi-coding-agent-extension/package-lock.jsonindex 0c70f6b80..c902f963a 100644--- a/examples/pi-coding-agent-extension/package-lock.json+++ b/examples/pi-coding-agent-extension/package-lock.json@@ -1,12 +1,12 @@{"name": "openviking-pi-extension",- "version": "0.4.4",+ "version": "0.4.5","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openviking-pi-extension",- "version": "0.4.4",+ "version": "0.4.5","dependencies": {"@modelcontextprotocol/client": "2.0.0"},diff --git a/examples/pi-coding-agent-extension/package.json b/examples/pi-coding-agent-extension/package.jsonindex c650ae81c..11e514987 100644--- a/examples/pi-coding-agent-extension/package.json+++ b/examples/pi-coding-agent-extension/package.json@@ -1,6 +1,6 @@{"name": "openviking-pi-extension",- "version": "0.4.4",+ "version": "0.4.5","description": "OpenViking memory and context extension for the pi coding agent","private": true,"type": "module",