Skip to content

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

fix(dsh): forward MCP diagnostic settings (#5236)

z1gonac5950ce248b
diff --git a/docs/en/agent-integrations/17-dsh.md b/docs/en/agent-integrations/17-dsh.md
index 0eab3e868..47a671a70 100644
--- a/docs/en/agent-integrations/17-dsh.md
+++ b/docs/en/agent-integrations/17-dsh.md
@@ -53,7 +53,7 @@ After using it for a while, start a new conversation and ask about something you
Start `dsh --profile web` and open a conversation. You should see an OpenViking context injection at the top of the session, and the model should have `mcp__openviking__*` tools available. Ask it about something from an earlier session to confirm recall.
-If nothing appears, set `OV_DEBUG_LOG=/tmp/ov-dsh.log` and check that file.
+For MCP proxy diagnostics, set `OPENVIKING_DEBUG=1` and `OPENVIKING_DEBUG_LOG=/tmp/ov-dsh.log` before starting DSH, then check that file. Automatic memory callbacks use DSH's own logger. The legacy `OV_DEBUG_LOG=/tmp/ov-dsh.log` alias is still supported and takes precedence over both canonical settings.
## How it works
@@ -78,7 +78,9 @@ Credentials resolve from `OPENVIKING_*` environment variables, then `~/.openviki
| `OPENVIKING_PEER_ID` | — | Explicit actor peer |
| `OPENVIKING_WORKSPACE_PEER` | `true` | Derive a peer from each session's workspace; `0` sends no peer |
| `OPENVIKING_RECALL_PEER_SCOPE` | `all` | `actor` isolates recall to the current workspace |
-| `OV_DEBUG_LOG` | — | Write debug logs to this path |
+| `OPENVIKING_DEBUG` | `false` | Enable MCP proxy debug logging; also requires a log path |
+| `OPENVIKING_DEBUG_LOG` | `""` | File path for MCP proxy debug logs |
+| `OV_DEBUG_LOG` | — | Legacy alias: enables MCP proxy logging and overrides the canonical debug flag and log path |
Behavior knobs live in the profile's Cordis patch entry:
diff --git a/docs/zh/agent-integrations/17-dsh.md b/docs/zh/agent-integrations/17-dsh.md
index d13c218db..d10bb3ca6 100644
--- a/docs/zh/agent-integrations/17-dsh.md
+++ b/docs/zh/agent-integrations/17-dsh.md
@@ -53,7 +53,7 @@ bash <(curl -fsSL https://ovrelease.tos-cn-beijing.volces.com/memory-plugin-shar
启动 `dsh --profile web` 打开一个会话,会话开头应该能看到一条 OpenViking 上下文注入,模型也应该具备 `mcp__openviking__*` 工具。问一句更早会话里聊过的事,确认召回生效。
-如果什么都没有,设置 `OV_DEBUG_LOG=/tmp/ov-dsh.log` 后查看该文件。
+排查 MCP 代理问题时,在启动 DSH 前设置 `OPENVIKING_DEBUG=1` 和 `OPENVIKING_DEBUG_LOG=/tmp/ov-dsh.log`,然后查看该文件。自动记忆回调使用 DSH 自身的日志系统。旧别名 `OV_DEBUG_LOG=/tmp/ov-dsh.log` 仍然支持,并且优先于这两个规范配置项。
## 工作方式
@@ -78,7 +78,9 @@ bash <(curl -fsSL https://ovrelease.tos-cn-beijing.volces.com/memory-plugin-shar
| `OPENVIKING_PEER_ID` | — | 显式指定 actor peer |
| `OPENVIKING_WORKSPACE_PEER` | `true` | 按每个会话的工作区推导 peer;设为 `0` 则不发送 peer |
| `OPENVIKING_RECALL_PEER_SCOPE` | `all` | 设为 `actor` 可将召回限制在当前工作区 |
-| `OV_DEBUG_LOG` | — | 把调试日志写到该路径 |
+| `OPENVIKING_DEBUG` | `false` | 启用 MCP 代理调试日志;还需配置日志路径 |
+| `OPENVIKING_DEBUG_LOG` | `""` | MCP 代理调试日志的文件路径 |
+| `OV_DEBUG_LOG` | — | 旧别名:启用 MCP 代理日志,并覆盖规范的调试开关和日志路径 |
行为参数写在 profile 的 Cordis patch 条目里:
diff --git a/examples/dsh-memory-plugin/config.mjs b/examples/dsh-memory-plugin/config.mjs
index c5b473d30..27b37d98f 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.8";
+export const PLUGIN_VERSION = "0.5.9";
/**
* Namespace for the bridged OpenViking MCP tools. DSH publishes every MCP tool
diff --git a/examples/dsh-memory-plugin/mcp-env.mjs b/examples/dsh-memory-plugin/mcp-env.mjs
index 378988f71..4def69e21 100644
--- a/examples/dsh-memory-plugin/mcp-env.mjs
+++ b/examples/dsh-memory-plugin/mcp-env.mjs
@@ -12,15 +12,20 @@ export const PROXY_PATH = fileURLToPath(new URL("./servers/mcp-proxy.mjs", impor
* DSH scrubs credential-shaped names out of the environment a subprocess
* inherits, and the Cordis patch is invisible to one, so the proxy cannot
* resolve the connection the way this process did. It gets the answer instead:
- * the resolved connection and this session's peer, forwarded with the forced
- * `env` source so the child reads no file and lands on exactly this url, key,
- * identity, auth mode and peer — the empty ones included.
+ * the resolved connection, diagnostics, and this session's peer, forwarded
+ * with the forced `env` source so the child reads no file and lands on exactly
+ * these values — the empty ones included.
*/
export function buildMcpConfig(config) {
// In DSH Desktop, process.execPath is Electron's executable rather than a
// standalone Node binary. This tells Electron to run the proxy script as
// Node instead of attempting to launch a second Desktop instance.
- const env = { ELECTRON_RUN_AS_NODE: "1", ...forwardConnectionEnv(config) };
+ const env = {
+ ELECTRON_RUN_AS_NODE: "1",
+ ...forwardConnectionEnv(config),
+ OPENVIKING_DEBUG: config.debug ? "1" : "0",
+ OPENVIKING_DEBUG_LOG: config.debugLogPath || "",
+ };
if (config.recallPeerScope) env.OPENVIKING_RECALL_PEER_SCOPE = config.recallPeerScope;
if (config.timeoutMs) env.OPENVIKING_TIMEOUT_MS = String(config.timeoutMs);
return {
diff --git a/examples/dsh-memory-plugin/mcp.test.mjs b/examples/dsh-memory-plugin/mcp.test.mjs
index 254af7163..9caa70cba 100644
--- a/examples/dsh-memory-plugin/mcp.test.mjs
+++ b/examples/dsh-memory-plugin/mcp.test.mjs
@@ -79,6 +79,8 @@ test("credentials resolved by the plugin reach the proxy through the child env",
OPENVIKING_PEER_ID: "workspace-peer",
OPENVIKING_AUTH_MODE: "trusted",
OPENVIKING_RECALL_PEER_SCOPE: "all",
+ OPENVIKING_DEBUG: "0",
+ OPENVIKING_DEBUG_LOG: "",
OPENVIKING_TIMEOUT_MS: "10000",
});
@@ -111,6 +113,77 @@ test("credentials resolved by the plugin reach the proxy through the child env",
});
});
+test("shared diagnostic settings reach the proxy through the child env", async () => {
+ const { readProxyConfig } = await import("./servers/mcp-proxy.mjs");
+ await withCredentialFiles({}, ({ env: files, dir }) => {
+ const logPath = join(dir, "dsh-proxy.log");
+ const config = resolveConfig({
+ endpoint: "http://ov.example.com",
+ workspacePeer: false,
+ debug: true,
+ debugLogPath: logPath,
+ }, files, dir);
+ assert.equal(config.debug, true);
+ assert.equal(config.debugLogPath, logPath);
+
+ const { env } = buildMcpConfig(config);
+ assert.equal(env.OPENVIKING_DEBUG, "1");
+ assert.equal(env.OPENVIKING_DEBUG_LOG, logPath);
+
+ const proxy = readProxyConfig(env, dir);
+ assert.equal(proxy.debug, true);
+ assert.equal(proxy.debugLogPath, logPath);
+ });
+});
+
+test("the proxy accepts canonical diagnostic environment variables", async () => {
+ const { readProxyConfig } = await import("./servers/mcp-proxy.mjs");
+ await withCredentialFiles({}, ({ env: files, dir }) => {
+ const logPath = join(dir, "canonical-proxy.log");
+ const proxy = readProxyConfig({
+ ...files,
+ OPENVIKING_URL: "http://ov.example.com",
+ OPENVIKING_DEBUG: "1",
+ OPENVIKING_DEBUG_LOG: logPath,
+ }, dir);
+
+ assert.equal(proxy.debug, true);
+ assert.equal(proxy.debugLogPath, logPath);
+ });
+});
+
+test("disabled diagnostics are explicit in the child environment", () => {
+ withCredentialFiles({}, ({ env: files, dir }) => {
+ const config = resolveConfig({
+ endpoint: "http://ov.example.com",
+ workspacePeer: false,
+ debug: false,
+ debugLogPath: "",
+ }, files, dir);
+ const { env } = buildMcpConfig(config);
+
+ assert.equal(env.OPENVIKING_DEBUG, "0");
+ assert.equal(env.OPENVIKING_DEBUG_LOG, "");
+ });
+});
+
+test("the proxy keeps the legacy OV_DEBUG_LOG alias", async () => {
+ const { readProxyConfig } = await import("./servers/mcp-proxy.mjs");
+ await withCredentialFiles({}, ({ env: files, dir }) => {
+ const logPath = join(dir, "legacy-proxy.log");
+ const proxy = readProxyConfig({
+ ...files,
+ OPENVIKING_URL: "http://ov.example.com",
+ OPENVIKING_DEBUG: "0",
+ OPENVIKING_DEBUG_LOG: join(dir, "canonical-proxy.log"),
+ OV_DEBUG_LOG: logPath,
+ }, dir);
+
+ assert.equal(proxy.debug, true);
+ assert.equal(proxy.debugLogPath, logPath);
+ });
+});
+
test("a key the plugin left empty stays empty in the proxy", async () => {
// ovcli.conf naming only a url pins the chain to that file, so the runtime
// sends no key. The proxy's env names a url, which would have unpinned the
@@ -194,6 +267,8 @@ test("an anonymous local server forwards no key or identity", () => {
OPENVIKING_PEER_ID: "",
OPENVIKING_AUTH_MODE: "api_key",
OPENVIKING_RECALL_PEER_SCOPE: "all",
+ OPENVIKING_DEBUG: "0",
+ OPENVIKING_DEBUG_LOG: "",
OPENVIKING_TIMEOUT_MS: "10000",
});
});
diff --git a/examples/dsh-memory-plugin/package-lock.json b/examples/dsh-memory-plugin/package-lock.json
index e699f283c..e080c5f68 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.8",
+ "version": "0.5.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@openviking/dsh-memory-plugin",
- "version": "0.5.8",
+ "version": "0.5.9",
"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.json
index befba8197..bb57cb38f 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.8",
+ "version": "0.5.9",
"description": "OpenViking memory and context bundle for DeepSeek Harness",
"icon": "./icon.svg",
"type": "module",
diff --git a/examples/dsh-memory-plugin/servers/mcp-proxy.mjs b/examples/dsh-memory-plugin/servers/mcp-proxy.mjs
index a41466fb4..4035c1e99 100644
--- a/examples/dsh-memory-plugin/servers/mcp-proxy.mjs
+++ b/examples/dsh-memory-plugin/servers/mcp-proxy.mjs
@@ -4,8 +4,8 @@
* stdio -> streamable-HTTP MCP proxy for the OpenViking DSH bundle.
*
* DSH's MCP bridge starts this process as a local stdio MCP server. The proxy
- * resolves its connection through the same `resolveConfig()` as the in-process
- * runtime, from the child environment the bundle builds in `mcp.mjs`: DSH
+ * resolves its connection and diagnostics through the same `resolveConfig()`
+ * as the in-process runtime, from the child environment built in `mcp-env.mjs`: DSH
* scrubs credential-shaped names out of what it inherits, and values that came
* from the Cordis patch are invisible to a subprocess otherwise.
*/
@@ -25,8 +25,8 @@ export function readProxyConfig(env = process.env, cwd = process.cwd()) {
// still decides whether the proxy may send it. In broad recall mode the
// actor header must stay unset; otherwise a process launched in workspace A
// narrows MCP searches for a session whose runtime is serving workspace B.
- debug: Boolean(env.OV_DEBUG_LOG),
- debugLogPath: env.OV_DEBUG_LOG || "",
+ debug: env.OV_DEBUG_LOG ? true : cfg.debug,
+ debugLogPath: env.OV_DEBUG_LOG || cfg.debugLogPath,
});
}