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(dsh-plugin): recall only on real user input (#5647)
Zayn Jarvisd9352f2a8bac
diff --git a/docs/en/agent-integrations/17-dsh.md b/docs/en/agent-integrations/17-dsh.mdindex 419369dce..e356a38b1 100644--- a/docs/en/agent-integrations/17-dsh.md+++ b/docs/en/agent-integrations/17-dsh.md@@ -52,7 +52,7 @@ For MCP proxy diagnostics, set `OPENVIKING_DEBUG=1` and `OPENVIKING_DEBUG_LOG=/t## How it works-The bundle runs inside DSH as a Cordis plugin rather than as external hooks, so it follows the session in-process. At session start it injects your OpenViking profile block, an index of available memories, and an `<available-skills>` catalog of your OpenViking skills. Before every model step it searches OpenViking with the current input and appends what it finds to that step as a durable message, so the injection replays with the session and is visible to compaction. It captures user, assistant, and (optionally) tool-result messages straight from DSH's event stream, and commits to OpenViking once pending tokens cross the threshold, keeping the ten most recent messages live. Writes that fail land in a pending queue and replay at the next session start.+The bundle runs inside DSH as a Cordis plugin rather than as external hooks, so it follows the session in-process. At session start it injects your OpenViking profile block, an index of available memories, and an `<available-skills>` catalog of your OpenViking skills. When a model step takes new user input, it searches OpenViking with the text the user typed and appends what it finds to that step as a durable message, so the injection replays with the session and is visible to compaction. Context that DSH or other plugins inject (for example `time-context` or job notices) and tool results neither trigger recall nor enter the query. It captures user, assistant, and (optionally) tool-result messages straight from DSH's event stream, skipping injected context, and commits to OpenViking once pending tokens cross the threshold, keeping the ten most recent messages live. Writes that fail land in a pending queue and replay at the next session start.Each DSH session maps to `dsh-<session-id>` in OpenViking, and every subagent gets its own session.diff --git a/docs/zh/agent-integrations/17-dsh.md b/docs/zh/agent-integrations/17-dsh.mdindex b286a2d6c..735829563 100644--- a/docs/zh/agent-integrations/17-dsh.md+++ b/docs/zh/agent-integrations/17-dsh.md@@ -52,7 +52,7 @@ curl -fsSL https://openviking.ai/install | bash## 工作方式-插件以 Cordis 插件的形式跑在 DSH 进程内,而不是外挂 hook,因此能贴着会话走。会话开始时注入 OpenViking 画像块、可用记忆索引和 OpenViking 技能清单 `<available-skills>`;每个模型步骤前用当前输入做语义检索,把结果作为持久消息追加到同一步骤——因此注入会随会话重放,也对压缩可见。它直接从 DSH 的事件流捕获 user、assistant 以及(可选的)工具结果消息,待同步 token 超过阈值即 commit,并保留最近十条消息在本地上下文中。写入失败会进入待写队列,在下次会话开始时重放。+插件以 Cordis 插件的形式跑在 DSH 进程内,而不是外挂 hook,因此能贴着会话走。会话开始时注入 OpenViking 画像块、可用记忆索引和 OpenViking 技能清单 `<available-skills>`;模型步骤带有新的用户输入时,用用户输入的文本做语义检索,把结果作为持久消息追加到同一步骤,因此注入会随会话重放,也对压缩可见。DSH 或其他插件注入的上下文(例如 `time-context`、job 通知)和工具结果既不触发召回,也不拼进检索文本。它直接从 DSH 的事件流捕获 user、assistant 以及(可选的)工具结果消息,并跳过注入的上下文,待同步 token 超过阈值即 commit,并保留最近十条消息在本地上下文中。写入失败会进入待写队列,在下次会话开始时重放。每个 DSH 会话映射为 OpenViking 中的 `dsh-<session-id>`,子 agent 各自拥有独立会话。diff --git a/examples/dsh-memory-plugin/README.md b/examples/dsh-memory-plugin/README.mdindex c3224dee7..3478aab77 100644--- a/examples/dsh-memory-plugin/README.md+++ b/examples/dsh-memory-plugin/README.md@@ -117,6 +117,15 @@ context under such presets with no error. Pre-step injection also makes eachinjection a session event that replays, is visible to compaction, and neverreaches `request/header`.+### What triggers recall++Recall runs on a pre-step whose entering batch contains user-authored input.+The query is built only from those messages: user-role messages with+`source.kind` absent or `user`. Messages that DSH or other plugins inject+(`time-context`, `plugin:*` notices, this plugin's own blocks) and tool results+are excluded, using the same rule capture uses. A batch made only of injected+context sends no search request.+### How the tool surface is mounted`mcp.mjs` mounts `@deepseek-ai/dsh-mcp-client` on `servers/mcp-proxy.mjs`, thediff --git a/examples/dsh-memory-plugin/capture.mjs b/examples/dsh-memory-plugin/capture.mjsindex 09b24e71d..b7ff319ef 100644--- a/examples/dsh-memory-plugin/capture.mjs+++ b/examples/dsh-memory-plugin/capture.mjs@@ -96,9 +96,18 @@ function captureMessage(event, message, config, toolNames) {return payload;}+// Recall queries use only what the user typed. Injected context (time-context,+// job notices, other plugins' blocks, our own recall) and tool results would+// otherwise trigger recall on their own and pollute the query text.+function isUserInput(message) {+ if (!message || message.role !== "user") return false;+ if (message.source?.kind === "tool") return false;+ return !isSyntheticUserMessage(message);+}+export function promptText(messages) {return (messages || [])- .filter(message => !isOpenVikingPluginMessage(message))+ .filter(isUserInput).map(message => extractTextFromPayload(message)).filter(Boolean).join("\n\n")diff --git a/examples/dsh-memory-plugin/capture.test.mjs b/examples/dsh-memory-plugin/capture.test.mjsindex 42c5a3ef1..6630c9eb3 100644--- a/examples/dsh-memory-plugin/capture.test.mjs+++ b/examples/dsh-memory-plugin/capture.test.mjs@@ -201,7 +201,7 @@ test("preserves DSH event time so identical offline messages do not deduplicate"assert.equal(captured.created_at, "2026-08-14T04:20:34.567Z");});-test("builds recall queries from current input while excluding its own context", () => {+test("builds recall queries from user input only, excluding injected context", () => {assert.equal(promptText([{role: "user",@@ -218,7 +218,30 @@ test("builds recall queries from current input while excluding its own context",content: [{ type: "text", text: "background job completed" }],source: { kind: "plugin:job-controller", form: "notice", summary: "done" },},- ]), "Current question\n\nbackground job completed");+ {+ role: "user",+ content: [{ type: "text", text: "Current time: 2026-10-05 21:20" }],+ source: { kind: "time-context" },+ },+ ]), "Current question");++ // A batch made only of injected context has no user query, so recall is skipped.+ assert.equal(promptText([+ {+ role: "user",+ content: [{ type: "text", text: "Current time: 2026-10-05 21:20" }],+ source: { kind: "time-context" },+ },+ {+ role: "user",+ content: [{ type: "text", text: "background job completed" }],+ source: { kind: "plugin:job-controller", form: "notice", summary: "done" },+ },+ ]), "");++ assert.equal(promptText([+ { role: "user", content: [{ type: "text", text: "legacy untagged input" }] },+ ]), "legacy untagged input");assert.equal(promptText([{diff --git a/examples/dsh-memory-plugin/config.mjs b/examples/dsh-memory-plugin/config.mjsindex 994283c72..c86ece609 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.14";+export const PLUGIN_VERSION = "0.5.15";/*** 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 bbb670bc0..7841df886 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.14",+ "version": "0.5.15","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@openviking/dsh-memory-plugin",- "version": "0.5.14",+ "version": "0.5.15","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 a28efb531..c98cd034e 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.14",+ "version": "0.5.15","description": "OpenViking memory and context bundle for DeepSeek Harness","icon": "./icon.svg","type": "module",diff --git a/examples/dsh-memory-plugin/runtime.mjs b/examples/dsh-memory-plugin/runtime.mjsindex b09120bd8..d64314574 100644--- a/examples/dsh-memory-plugin/runtime.mjs+++ b/examples/dsh-memory-plugin/runtime.mjs@@ -131,7 +131,7 @@ export class OpenVikingRuntime {const state = await this.initialize(agent);if (!state.ready || !isRecallEnabled(state.config)) return null;const query = promptText(messages);- if (query.length < state.config.minQueryLength) return null;+ if (!query || query.length < state.config.minQueryLength) return null;const block = await buildRecallBlock((path, init, options) => this.client.fetchJSON(path, init, options),state.config,diff --git a/examples/dsh-memory-plugin/runtime.test.mjs b/examples/dsh-memory-plugin/runtime.test.mjsindex e3f7c28a3..6b74101ff 100644--- a/examples/dsh-memory-plugin/runtime.test.mjs+++ b/examples/dsh-memory-plugin/runtime.test.mjs@@ -381,6 +381,23 @@ test("autoRecall false stops the recall request", async () => {assert.equal(await runtime.recallMessage({}, [{ role: "user", content: "what did we decide" }]), null);});+// A batch of injected context alone (time-context, job notices) carries no+// user query, so it must not trigger a recall request.+test("injected context alone does not trigger recall", async () => {+ const runtime = new OpenVikingRuntime({+ async fetchJSON() {+ throw new Error("recall must not run without user input");+ },+ }, { ...config(), minQueryLength: 0 }, { debug() {} });+ runtime.initialize = async () => ({ ready: true, config: { ...config(), minQueryLength: 0 } });++ assert.equal(await runtime.recallMessage({}, [{+ role: "user",+ content: [{ type: "text", text: "Current time: 2026-10-05 21:20" }],+ source: { kind: "time-context" },+ }]), null);+});+// recall-core reads options.excludeUris, but the DSH runtime built its options// without it, so nothing a user configured could stop a subtree from being// recalled: generated directory files came back as ordinary hits.