Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(plugin): deduplicate repeated messages in capture batches (#6230)

vriebge81faeb6f282c
diff --git a/examples/agent-hook-plugin/hosts/codebuddy/plugin.json b/examples/agent-hook-plugin/hosts/codebuddy/plugin.json
index eabf22e55..9e6144a1f 100644
--- a/examples/agent-hook-plugin/hosts/codebuddy/plugin.json
+++ b/examples/agent-hook-plugin/hosts/codebuddy/plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.5.28",
+ "version": "0.5.29",
"description": "Long-term semantic memory for the CodeBuddy Code CLI, powered by OpenViking. Injects relevant context at session start and on each prompt, and captures the conversation back into OpenViking.",
"author": {
"name": "OpenViking",
diff --git a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
index 9af7c1e37..f55e6122f 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.28",
+ "version": "0.5.29",
"clients": [
"cursor"
],
diff --git a/examples/agent-hook-plugin/hosts/incremental-turn-capture.mjs b/examples/agent-hook-plugin/hosts/incremental-turn-capture.mjs
index c8ca00352..3d75091a5 100644
--- a/examples/agent-hook-plugin/hosts/incremental-turn-capture.mjs
+++ b/examples/agent-hook-plugin/hosts/incremental-turn-capture.mjs
@@ -17,7 +17,14 @@ export function buildIncrementalCapturePlan(turns, state = {}, cfg = {}) {
if (!decision.shouldCapture) continue;
candidates.push({ dedupKey: turnDedupKey(turn), turn, content: decision.text });
}
- const toSend = candidates.filter((item) => !acknowledged.has(item.dedupKey));
+ const seenInBatch = new Set();
+ const toSend = candidates.filter((item) => {
+ if (acknowledged.has(item.dedupKey)) return false;
+ const batchKey = stableHash(item.dedupKey, item.content);
+ if (seenInBatch.has(batchKey)) return false;
+ seenInBatch.add(batchKey);
+ return true;
+ });
const payloads = toSend.map(({ turn, content }) => ({
role: turn.role,
content,
diff --git a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
index 7f2715935..7f43baf59 100644
--- a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
+++ b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.5.28",
+ "version": "0.5.29",
"description": "Long-term semantic memory for Kimi Code CLI, powered by OpenViking.",
"author": {
"name": "OpenViking",
diff --git a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
index 7aafef4ed..85dd5ee5d 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.28",
+ "version": "0.5.29",
"clients": [
"kimicode"
],
diff --git a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
index 4535d4714..dd93fce1f 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.28",
+ "version": "0.5.29",
"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.json
index 476f1d97a..76f972b41 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.28",
+ "version": "0.5.29",
"clients": [
"zcode"
],
diff --git a/examples/agent-hook-plugin/plugin.json b/examples/agent-hook-plugin/plugin.json
index 48f8a70aa..ba769adf1 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.28",
+ "version": "0.5.29",
"description": "Long-term semantic memory for Cursor, TRAE, TRAE CN, ZCode, Kimi Code and CodeBuddy 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.mjs
index 35c476976..53723458a 100644
--- a/examples/agent-hook-plugin/tests/zcode-capture.test.mjs
+++ b/examples/agent-hook-plugin/tests/zcode-capture.test.mjs
@@ -143,6 +143,29 @@ test("successful capture records every dedup key and suppresses repeated Stop",
assert.equal(repeatedPlan.payloads.length, 0);
});
+test("capture plan deduplicates identical messages within one rollout batch", () => {
+ const duplicatePrompt = { role: "user", content: "same prompt", turnId: "turn-001" };
+ const turnsWithRetries = [
+ ...Array.from({ length: 10 }, () => duplicatePrompt),
+ ...Array.from({ length: 5 }, (_, index) => ({
+ role: "assistant",
+ content: `assistant fragment ${index}`,
+ turnId: "turn-001",
+ })),
+ ];
+
+ const plan = buildZcodeCapturePlan(turnsWithRetries, {});
+
+ assert.equal(plan.payloads.length, 6);
+ assert.deepEqual(plan.payloads.map(({ role, content }) => ({ role, content })), [
+ { role: "user", content: "same prompt" },
+ ...Array.from({ length: 5 }, (_, index) => ({
+ role: "assistant",
+ content: `assistant fragment ${index}`,
+ })),
+ ]);
+});
+
test("queued messages are acknowledged like sent messages", () => {
const plan = buildZcodeCapturePlan(turns, {});
const next = applyZcodeCaptureResult({}, plan, {