[Bug]: dsh-memory-plugin — excludeUris is never passed, recallLimit widens the search, and two documented budget knobs only affect the fallback path
Issue Origin: Observed or reproduced in a real environment
Bug Description
Three defects on the recall path of the DSH integration. All three are re-verified against main (plugin 0.4.3); the file:line references are from main.
1. excludeUris is implemented but never passed by the DSH plugin
examples/memory-plugin-shared/lib/recall-core.mjs:146-147 reads it from the call options:
const excludeUris = Array.isArray(options.excludeUris) ? options.excludeUris.slice(0, 200) : [];
if (excludeUris.length) body.exclude_uris = excludeUris;
examples/dsh-memory-plugin/runtime.mjs:133-142 builds those options and passes only actorPeerId, legacyPeerId, sessionId and log. The string excludeUris appears 0 times in the whole file.
Consequence: no configuration can stop a subtree from being recalled. The generated per-directory context files (viking://user/default/skills, viking://user/default/resources, viking://agent/skills) are returned as ordinary hits and are pure boilerplate ("Use this directory for resources scoped to the current User."). On a vague prompt, 3 of 7 returned entries were these directory files. The only current remedy is deleting the data.
2. recallLimit below the category count widens the search instead of narrowing it
recall-core.mjs:59-65:
function scaleQuotas(limit, weights) {
const slots = Math.max(1, Math.floor(Number(limit) || DEFAULT_CONTEXT_LIMIT));
const order = Object.keys(weights);
...
if (slots < order.length) {
for (const key of order) quotas[key] = 1;
return quotas;
}
The coding preset has six categories (CODING_QUOTA_WEIGHTS, lines 22-29: events, entities, preferences, experiences, resources, skills). So recallLimit: 4 sends a quotas object covering all six categories with one slot each - including resources (weight 3) and skills (weight 2) that the weighted preset would otherwise prioritise. Lowering the limit therefore increases the number of searched categories, which is the opposite of what a user tuning for less noise expects.
3. recallTokenBudget / recallMaxContentChars are documented as injection-size knobs but only affect the fallback path
The DSH README's own configuration example sets recallTokenBudget: 2000 (examples/dsh-memory-plugin/README.md:189), and config-schema.mjs:82-83 declares both keys with capability: "recall". But on the primary path (POST /api/v1/search/search, the context face) neither is sent - that path is driven by recallMaxTokens (recall-core.mjs:118, 127-129, sendOnlyWhenConfigured). recallTokenBudget and recallMaxContentChars are read only inside buildFallbackInjectionBlock (recall-core.mjs:356, 361) and the legacy endpoint body.
Consequence: on a server that has the context face, these two documented keys are silently inert. A user who sets them observes no change and has no way to find out why.
Steps to Reproduce
- A DSH profile with the plugin installed, against an OpenViking server with the context face (0.4.20 here).
- In the profile's Cordis patch, set
recallTokenBudget: 800,recallMaxContentChars: 400,recallLimit: 4. - Run a session and inspect the outgoing search request (or the server's
stats.searched):body.max_tokensis absent,body.max_charsis absent;body.quotasis{events:1, entities:1, preferences:1, experiences:1, resources:1, skills:1};body.exclude_urisis absent - and no configuration key exists that would populate it.
Minimal repro for (2), no server required:
import { buildContextSearchBody } from "./shared/recall-core.mjs";
console.log(buildContextSearchBody(
{ recallLimit: 4, recallLimitConfigured: true, scoreThreshold: 0.5 },
{ sessionId: "x" },
).quotas);
// => { events: 1, entities: 1, preferences: 1, experiences: 1, resources: 1, skills: 1 }
Expected Behavior
- A documented recall knob either affects the primary path or is documented as fallback-only.
recallLimit: 4should not cause more categories to be searched thanrecallLimit: 10.- Excluding a subtree from recall should be reachable from configuration, since
exclude_urisis already supported by the server and byrecall-core.mjs.
Actual Behavior
As above: two documented knobs have no effect on the primary path, recallLimit behaves inversely at low values, and the exclusion plumbing is unreachable from any configuration.
Error Logs
None - which is part of the problem. All three are silent: no warning, no error, recall simply returns what it returns. OV_DEBUG_LOG is off by default, so a user cannot tell that a knob they set never took effect.
Additional Context
- Related: #4205 (injection noise across workspaces), #4515 and #5148 (per-step delay caused by the recall call).
- One thing I initially suspected does not reproduce on
main: the*Configuredflags forsendOnlyWhenConfiguredknobs are now set bybuildPluginConfig(examples/memory-plugin-shared/lib/plugin-config.mjs:268). The npm-published0.3.2does not have that, so users installing from npm see additional silent no-ops. - Rough fix sizes: (1) is a one-line addition in
runtime.mjsplus a config key; (2) is a few lines inscaleQuotas; (3) is either mappingrecallTokenBudgetonto the context face'smax_tokens, or documenting the two keys as fallback-only. - Happy to open a PR for (1) and (2) if that would help.
OpenViking Version: server 0.4.20; plugin installed from npm as 0.3.2, defects re-verified on main (plugin 0.4.3)
Python Version: 3.11
Operating System: Linux
Model Backend: Other (OpenAI-compatible gateway)
Additional findings after installing 0.4.3 from main
I installed the plugin from main (built 0.4.3 with npm pack, which runs prepack → memory-plugin-shared/sync.mjs) and re-verified the three defects above — all reproduce. Four more, all silent, all in the same integration. Every number below is measured on a live server (openviking 0.4.20, plugin 0.4.3, main).
Two of them are not DSH-specific: profile-inject.mjs lives in examples/memory-plugin-shared/lib/ and is imported by both agent-hook-runtime.mjs (the hook-based harnesses) and dsh-memory-plugin/runtime.mjs, so (4) and (5) apply to every harness that renders a session-start block.
4. The session-start memory index cannot carry abstracts — fs/ls never fills the field for memory files
profile-inject.mjs documents its inputs as:
* viking://user/<space>/memories/preferences/ (ls with abstracts)
* viking://user/<space>/memories/entities/ (ls with abstracts)
and lsDir() reads e.abstract to build each listing line. The server does not populate it for memory files. Measured on the same tree:
| request | leaves returned | leaves with a non-empty abstract |
|---|---|---|
GET /api/v1/fs/ls?uri=…/memories/preferences&output=agent&recursive=true |
9 | 0 |
GET /api/v1/fs/ls?uri=…/memories/entities&output=agent&recursive=true |
4 | 0 |
output=original has no abstract field at all; output=full, raw, detail → HTTP 400. abs_limit=0 and include_abstract=true change nothing. So the <available-memories> block is always a bare filename list.
The same cards do have abstracts — one endpoint away, POST /api/v1/search/find returns abstract for 8 of the 13 cards, sized 774–31,568 characters. The data exists; fs/ls does not surface it (it appears to be filled only for directory .overview.md entries).
Measured consequence. In one real 8.8-hour session (41 plugin user/message injections, 88 <memory> entries), the index was rendered twice, both times as 170 characters listing 1 of 13 cards and 0 preferences:
<available-memories>
viking://user/default/memories/entities/
- 项目/<project>.md
</available-memories>
A direct re-run of buildProfileBlock() against the same server a few minutes later returns the full profile (2,269/2,312 chars, 2,137 tokens) plus 9 preferences and 4 entities (2,837 chars). The information is reachable; the session never got it.
5. lsDir() and readProfile() discard every failure, so the block degrades silently
// profile-inject.mjs:124
if (!res.ok || !Array.isArray(res.result)) return [];
// profile-inject.mjs:103
if (!res.ok || typeof res.result !== "string") return null;
No retry, no log, no marker. A single transient failure at session start renders a block that looks normal and is nearly empty, and neither the caller nor the model can tell. This is what produced the 170-character block above — the endpoints are healthy now (12/12 calls, 4–9 ms), so the failure was transient and was swallowed. Since the block is only built at session start and on compaction, one bad request costs the entire session.
6. 0.4.3 dropped the recallExcludeUris declaration, so resolveConfig() strips it (compounds 1)
Even with the call-site fix from (1), state.config.recallExcludeUris is undefined on 0.4.3: KNOBS in shared/config-schema.mjs no longer declares it, and resolveConfig() drops undeclared keys.
resolveConfig({ recallExcludeUris: ["viking://user/default/skills"] })
// 0.3.2 → ["viking://user/default/skills"]
// 0.4.3 → undefined
So upgrading from 0.3.2 to 0.4.3 silently turns the one workaround users have for (1) into a no-op. syncTurns avoided this because it is declared as an alias of autoCapture; recallExcludeUris has no such declaration. Adding the declaration back restores it, which is how I confirmed the mechanism.
7. The context-face knobs are not monotonic (extends 2)
Same query, same server, only the knob changed:
recallLimit |
4 | 6 | 12 | 24 |
|---|---|---|---|---|
| entries | 2 | 1 | 1 | 2 |
| content chars | 1,122 | 774 | 306 | 879 |
max_tokens: 6000 returned fewer chars than the default (774 vs 1,122). Sending an explicit quotas ({preferences: 6, entities: 2}) returned 0 entries. Compared with POST /api/v1/search/find on the same query (6 entries, 35,456 chars), the context face is not a "retrieve more" surface at all — which is fine as a design, but the existing docs and the recallLimit name read as if it were.
Also, 8 of the 88 injected entries had detail="uri" with a body under 15 characters — an entry that costs tokens and carries nothing.
Measured injection coverage
Ratio of injected body to the card's size on disk, over one session:
| card | on disk | injected (avg) | coverage |
|---|---|---|---|
| main project card | 100,855 B | 350 B | 0% |
openviking.md |
10,886 B | 327 B | 3% |
openviking dsh 插件.md |
11,032 B | 396 B | 4% |
| working-discipline card | 6,915 B | 384 B | 6% |
| principles card | 1,930 B | 774 B | 40% |
| optimisation-direction card | 927 B | 306 B | 33% |
Small cards survive overview tiering; large ones are effectively absent from the automatic path. If the intent is that the auto path is a pointer and detail comes from mcp__openviking__read, that is a reasonable design — but then the index in (4) is the only thing telling the model what to read, and it currently carries neither abstracts nor (reliably) the full list.
Why the tests did not catch this
examples/memory-plugin-shared/ ships 31 *.test.mjs; these six lib/ modules have none: async-writer, config-schema, debug-log, profile-inject, retryable, session-model. recall-core.test.mjs covers buildContextSearchBody() in isolation (it is correct) but not whether a runtime passes the options through — which is exactly where (1) lives. Nothing asserts the assembled block's content, so an empty listing and a full one both pass.
Suggested fix
- Build the index from
search/find(context_type,uri,abstract,score) and keepfs/lsonly for completeness. A broad-queryfind(limit=20)covered 10 of 13 cards with abstracts in my test — a far better listing than names alone, and cheaper than Ncontent/readcalls. - Make (5) fail loudly: at minimum log the failing stage and emit the block with an explicit marker, so a degraded start is visible.
- Restore the
recallExcludeUrisdeclaration inKNOBS(or document that exclusion is not configurable). - Add one test for
profile-injectthat feeds a stubbedfs/lsresponse with and without abstracts and asserts the rendered block — that alone would have caught (4).
Happy to open a PR for (3) and (4); (1) and (2) I would rather agree on shape first.