Skip to content

[memos-local-plugin] dsh 0.2.x session format V4 rejects plugin messages: "producer-owned source kind" — every turn fails #2538

Closed

Description

@slamdunk111

BODY:

Summary

@memtensor/memos-local-plugin@2.0.20 (DSH adapter) still writes messages with the legacy V3 source shape source.kind: "plugin". dsh 0.2.1-rc.2 session format V4 rejects any runtime-written message whose source.kind === "plugin":


SessionFormatError: format v4 message requires a producer-owned source kind

  (@deepseek-ai/dsh-session-format-v3-to-v4/lib/index.js:126)

Result: every conversation turn fails with UNKNOWN error as soon as the plugin injects its recall message — the harness is completely unusable with this plugin installed.

Offending code (v2.0.20, dist/adapters/deepseek-harness/)

  1. index.js (~line 301) — per-turn recall message:
createRecallMessage: (text) => createUserMessage({

    content: [{ type: "text", text }],

    source: {

        kind: "plugin",              // ← rejected by V4 validator

        plugin: DEEPSEEK_HARNESS_PLUGIN,

        form: "recall",

    },

}),
  1. host-llm.js (~line 220) — host LLM messages:
source: { kind: "plugin", plugin: HOST_LLM_MESSAGE_SOURCE },  // ← rejected

The V3→V4 migration rewrites historical sessions, but runtime writes are hard-rejected.

Expected fix

Use the producer-owned form that dsh itself maps unknown plugins to:

kind: "plugin:memos-local-memory"   // instead of kind: "plugin", plugin: "..."

We verified locally: replacing both sites with kind: "plugin:memos-local-memory" makes all turns pass again (syntax-checked, zero residual kind: "plugin" in dist, web profile back to normal).

Secondary issue: peer range pins plugin to dsh <0.2.0

The plugin's peer requirements (@deepseek-ai/dsh-agent etc. >=0.1.0-rc.5 <0.2.0) make dsh 0.2.1-rc.2 skip the bundle at startup ("incompatible ... Exact-version exemption: not active"). Users must hand-grant dsh plugin allow-version. Please widen the range (or republish) once the V4 kind fix is in, otherwise the plugin silently doesn't load on current dsh.

Environment

  • dsh 0.2.1-rc.2, plugin @memtensor/memos-local-plugin@2.0.20 (latest on npm as of 2026-10-23)

  • Reproduced on 3 machines (Linux x86_64, macOS arm64, Linux aarch64) — deterministic, 100% repro on any new turn

  • Session data on affected hosts was not corrupted (rejection happens before persistence)

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    types:bugSomething isn't working | 功能异常
    on Oct 23, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. Memtensor-AI commented on Oct 23, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 2e1b2262c967d90d
    Working branch: bugfix/autodev-2538-20261023114157826
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  4. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Oct 23, 2026
  5. Memtensor-AI commented on Oct 23, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 2e1b2262c967d90d completed.

    Summary: Fixes #2538. The DeepSeek Harness adapter in apps/memos-local-plugin still wrote the retired V3 message source wrapper source: { kind: "plugin", plugin: "..." }. DSH session format V4 validates runtime writes (not only migrations), so the per-turn recall message injected at agent/pre-step was rejected before persistence with SessionFormatError: format v4 message requires a producer-owned source kind, failing every conversation turn with UNKNOWN. Both runtime writers — the recall message in adapters/deepseek-harness/index.ts and the host-LLM user message in host-llm.ts — now emit kind: "plugin:memos-local-memory" through a new shared adapters/deepseek-harness/source-kind.ts. That constant is declared in DSH's MessageSourceMap extension point (the same pattern first-party plugins use) rather than cast, and it is exactly the value DSH's own V3→V4 migration derives for memos-local-memory, so live and migrated messages stay indistinguishable. The recall message keeps form: "recall"; host-LLM messages still omit form, since those are auxiliary MemOS calls rather than DSH conversation context.

    The secondary issue is also addressed: the optional DSH peer range stopped at <0.2.0, which made DSH 0.2.x silently skip the bundle at startup. Semver prerelease rules mean <0.2.0 does not admit 0.1.7-rc.x and <0.3.0 does not admit 0.2.1-rc.x, so the range now enumerates each V4 preview line that was actually compiled and tested. Dev dependencies move to DSH 0.2.1-rc.2 so CI exercises the V4 surface, and JsonValue (moved out of dsh-tools after 0.2) is declared locally so the adapter builds against both lines. Adapter README and CHANGELOG document the new source contract.

    Verification is real and reproduced the issue's exact error: calling the published assertV4RowAdmission from @deepseek-ai/dsh-session-format-v3-to-v4@0.2.1-rc.2 rejects the V3 shape and admits both new shapes, including the constants exported by the compiled dist. tsc --noEmit passes and all 68 DSH adapter tests pass on DSH 0.1.0-rc.6, 0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.2; the full plugin suite is 1601 passed / 2 skipped; npm run build succeeds. A new regression test fails if either writer or any adapter source reintroduces a code-level kind: "plugin".

    Changes are committed as 1263b229 on bugfix/autodev-2538-20261023114157826 and pushed to the remote. The opsp task file and openspec change (proposal.md, spec.md, design.md, verification-report.md) were produced and archived to the specs repository. No PR was opened from here, per the scheduler contract.

    Base branch: main
    Branch: bugfix/autodev-2538-20261023114157826
    Commit: 1263b22
    PR: #2541
    Assigned to: @XiaohuiSu
    Reviewers: @whipser030, @hijzy

  6. Poqianhu7895 commented on Oct 24, 2026

    @Poqianhu7895

    Independent verification from a 2.0.20 + DSH 0.2.1-rc.3 deployment (Linux, node v22.23.1):

    • Confirmed the bug exactly as described: every turn that triggers a recall injection fails with 0-token output and SessionFormatError: format v4 message requires a producer-owned source kind; the on-disk v4 session file stays clean (rejection happens at runtime adoption), and ~/.dsh/storages/session_projcache snapshots are also clean.
    • Patched the installed 2.0.20 dist locally at both sites (adapters/deepseek-harness/index.ts recall message, adapters/deepseek-harness/host-llm.ts toDshMessage), changing kind: "plugin" → kind: "memos-local-memory". After systemctl --user restart the same prompt that previously died instantly ran a full multi-tool turn (including a memos_get tool call) with zero SessionFormatError in the journal.
    • Note for the PR: the adapter's own consumer isUserMessage (bridge) only requires source.kind to be a string, so any producer-owned kind works; your plugin:memos-local-memory choice is fine. One caveat: if the published fix lands in a new release, users on 2.0.20 who hand-patched dist/ (like us) will need to re-apply or reinstall, since a profile pnpm install will overwrite the patch — worth a line in the release notes.
    • Also observed on this deployment (possibly related, possibly separate): intermittent MEMOS_DSH_HOST_LLM_TIMEOUT after 2000ms / fetch failed from the host-LLM bridge during retrieval — memory recall still works but degraded. Happy to provide journal excerpts if useful.
  7. slamdunk111 commented on Oct 24, 2026

    @slamdunk111
    Author

    Thanks @Poqianhu7895 for the independent verification on 2.0.20 + DSH 0.2.1-rc.3 — the both-sites patch confirmation and the isUserMessage consumer check are exactly the cross-check this fix needed.

    Agreed on the release-notes point: users who hand-patched dist/ locally will need a re-apply/reinstall note once the fix ships, since pnpm install overwrites the patch.

    On the MEMOS_DSH_HOST_LLM_TIMEOUT after 2000ms observation — yes, journal excerpts would be useful; if you could post a few occurrences with timestamps we can check whether it correlates with recall load or is a separate host-LLM bridge issue.

  8. shirokoterror01 commented on Oct 27, 2026

    @shirokoterror01

    Additional confirmation from Windows, with a different failure mode (session-fatal, delayed onset)

    Same root cause, but the blast radius here was larger than "every turn fails", and the onset was
    delayed — which is why this can silently sit in a long-running session and then kill it.

    Environment

    • Windows 10.0.26100 x64, Node v24.19.0
    • DSH @deepseek-ai/dsh@0.2.1-rc.2 (session format v4)
    • @memtensor/memos-local-plugin@2.0.20 (npm latest), installed as a profile bundle,
      recallEnabled: true, hostLlmEnabled: true

    Here the session dies; it does not merely fail a turn

    The affected turn never wrote turn/end. The JSONL tail is:

    6341  agent/inbox/spliced  next-turn  inserted=[user message]
    6342  turn/start           turn=121
    6343  agent/inbox/spliced  next-step  removedCount=1  inserted=[]
    6344  agent/inbox/spliced  next-turn  removedCount=1  inserted=[]
          ← seq 6345 never written; SessionFormatError at admission
    

    The queued user message is rolled back by those two removals, no
    turn/end { kind: "interrupted" } is written, and the session is dead from the UI's point of view.
    The on-disk file stayed clean (dense seq 0..6344, zero unparsable rows, last line complete) — same
    "rejected before persistence" property already reported, but here the rejection also takes the
    session with it instead of just ending the turn.

    Onset is delayed, so repro looks intermittent

    bridge.js only injects when recall actually produced context:

    const context = renderRecallContext(packet.injectedContext, this.contextMaxChars);
    if (!context) return decision;
    return { kind: "enter", messages: [...decision.messages, this.createRecallMessage(context)] };
    

    A fresh install, or any session whose corpus yields no hits, behaves perfectly. The bug only fires on
    the first turn with a non-empty recall — here that was turn 121, long after this session had
    already been migrated to v4 and had run many turns. That "fine until it suddenly isn't, once,
    catastrophically" shape may also explain the non-100% ratio in #2437 (4 of 11 turns).

    Independently reproduced with the same admission function the PR uses

    BEFORE: {"kind":"plugin","plugin":"memos-local-memory","form":"recall"}
            → SessionFormatError: format v4 message requires a producer-owned source kind
    AFTER : {"kind":"plugin:memos-local-memory","form":"recall"}
            → accepted
    

    That AFTER value is byte-identical to the recall rows already present in this session's migrated
    history, which is why plugin:memos-local-memory (rather than a bare memos-local-memory) is the
    right choice: live and migrated messages stay indistinguishable.

    Two things worth closing alongside the code fix

    1. This machine's ~/.dsh/profiles/web/compatibility.json recorded
      @memtensor/memos-local-plugin@2.0.20 → 0.2.1-rc.2 as compatible. A runtime source-contract
      change is invisible to that gate — worth documenting that it does not cover session-format
      invariants, or tightening whatever produces the verdict.
    2. The plugin's peerDependencies still claim <0.2.0, yet it loads on 0.2.1-rc.2 after an
      exemption. Gating and actual behavior disagree, which is how a broken combination reaches a
      setup that looks stable.

    For the release notes: users who hand-patched dist/ to unblock (several of us did) will have
    that silently reverted by the next profile pnpm install, and the crash then returns at the next
    recall hit
    — which is later, and therefore will not be obviously connected to the upgrade.

    Happy to test the PR build on Windows if a preview pack is published.

  9. slamdunk111 commented on Oct 27, 2026

    @slamdunk111
    Author

    Thanks @shirokoterror01 — this is a valuable escalation of the blast-radius picture:

    • Session-fatal, not just turn-fatal: the missing turn/end after the two inbox rollbacks (seq 6345 never written) explains why the session appears dead from the UI rather than failing one turn. An admission-time SessionFormatError leaves no terminal event for the open turn, so the session has no way to recover.
    • Delayed onset matches the trigger condition: the adapter only injects when recall actually produced context, so a session can run clean for a long time and die on the first turn where recall fires — consistent with the seq-6341 spliced next-turn right before the fatal turn.

    Two takeaways for the fix now in progress upstream:

    1. The plugin-side fix (recall message carrying a producer-owned source kind instead of plugin), already verified on Linux (2.0.20 + DSH 0.2.1-rc.3), addresses the root cause at the source — your patched-dist confirmation on Windows mirrors that.
    2. Your report also suggests a dsh-side hardening worth tracking separately: when adoption rejects a spliced message, writing a terminal turn/end (kind interrupted) before surfacing the error would at least keep the session recoverable instead of killing it silently. If nobody has filed that yet, it may deserve its own issue against the harness repo.

    Will reference your Windows trace when the release lands so the Windows path gets explicit verification in the release notes.

  10. chichi233 commented on Oct 29, 2026

    @chichi233

    Additional data point: DSH Desktop (Electron, 0.2.1-rc.3) on Windows — turn-fatal, session survives

    Same root cause as reported, but a third blast radius: here the turn dies while the session stays usable (the next prompt works), so it reads like a transient model error rather than a plugin bug. The UI surfaces it as a turn-card error:

    本轮运行失败 format v4 message requires a producer-owned source kind
    

    Environment

    item value
    OS Windows 10.0.26100 x64
    DSH Desktop/Electron bundle, @deepseek-ai/dsh@0.2.1-rc.3, SESSION_FORMAT_VERSION = 4
    plugin @memtensor/memos-local-plugin@2.0.20 (npm latest), installed as a profile bundle
    flags recallEnabled: true

    Trace (on-disk v4 session, verbatim event tail)

    seq 9  agent/inbox/spliced  next-turn  inserted:[user message "…搜索一下[3d打印公差表]…"]
    seq 10 turn/start           turn 1
    seq 11 agent/inbox/spliced  next-step  start 0  removedCount 1  inserted []
    seq 12 agent/inbox/spliced  next-turn  start 0  removedCount 1  inserted []
    

    No step/start, no request/header, no turn/end follow. Two inbox rollbacks and then silence: the rejected insert is the pre-step recall message, and nothing about it reaches the log — which is why the session file stays clean.

    The file really stays clean. Swept all 60 session.v4.jsonl.zstd files under ~/.dsh/sessions/**: zero occurrences of "kind":"plugin". Nothing to repair afterwards — consistent with admission rejecting the write, not with a corrupted log.

    Why the same install can run clean for a long time. dist/adapters/deepseek-harness/bridge.js:112-118:

    const context = renderRecallContext(packet.injectedContext, this.contextMaxChars);
    if (!context) return decision;          // no context → no injection → no failure
    return { kind: "enter", messages: [...decision.messages, this.createRecallMessage(context)] };

    Failure needs a non-empty recall result, so it fires on the first turn where recall actually hits — the delayed-onset pattern already described in this thread.

    Sibling risk worth fixing in the same pass. The retired wrapper is not unique to this plugin, and the dangerous part is deciding the source shape from a module constant instead of the live session. In the same profile:

    • @nanmicoder/dsh-agent-teams/lib/harness-compat.js:90-130 — agentTeamsSource(modern, observed) returns { kind: "plugin", plugin: ... } whenever hostSessionFormatVersion(observed) < 3, where observed is subject?.session?.header?.version and the module fallback is dshSession.SESSION_FORMAT_VERSION. Its own comment documents that a profile resolving a different @deepseek-ai/dsh-session copy reports the wrong generation and "makes every durable AgentTeams message fail the host's own admission check (feat: add further questions for dialogue #236)". On this Desktop/asar deployment ~/.dsh/profiles/desktop/node_modules/@deepseek-ai/ contains dsh-session-persistence, dsh-session-projection, dsh-util-values but no dsh-session — exactly the layout where that resolution can land on the wrong copy.
    • dsh-vision-router/lib/session-message-source-compat.js:4-6 does it the robust way: Number(session?.header?.version) >= 4 ? PRODUCER_SOURCE : LEGACY_SOURCE, i.e. from the live session header.

    Suggestion for apps/memos-local-plugin: derive the kind from the live session at the write site (same as vision-router) rather than from a plugin constant, and add the CHANGELOG.md reinstall note — the hand-patch is currently the only workaround, since 2.0.20 is still npm latest (published 2026-09-21, PR #2541 opened 2026-10-23).

  11. endxxxx commented on Oct 29, 2026

    @endxxxx
    Collaborator

    Update: the V4 message-source failure is fixed by #2519 and released in @memtensor/memos-local-plugin 2.0.21. Both recall and auxiliary host-LLM messages now use plugin:memos-local-memory; Windows Desktop automatic recall and restart persistence were verified.

    However, the secondary peer-compatibility issue remains: 2.0.21 still declares the DSH peer range >=0.1.0-rc.5 <0.2.0. Upgrading the plugin therefore does not, by itself, resolve DSH 0.2.x bundle compatibility checks.

    Keeping this issue open for the remaining compatibility work tracked in #2520 / #2541. The intermittent host-LLM timeout reports should also remain a separate investigation.

  12. slamdunk111 commented on Oct 29, 2026

    @slamdunk111
    Author

    Confirmed on our side: @memtensor/memos-local-plugin 2.0.21 is now published on npm (dist-tags.latest = 2.0.21, checked today), and it carries the V4 producer-owned message-source fix from #2519 — which is exactly the root cause this issue reported (recall messages using the retired kind: "plugin" wrapper instead of a producer-owned source kind under SESSION_FORMAT_VERSION = 4).

    Two follow-ups from this thread we'll track on our side:

    1. The remaining DSH peer-range gap (>=0.1.0-rc.5 <0.2.0 in 2.0.21, so 0.2.x bundle compatibility checks still fail) — noted as tracked in feat: support DeepSeek Harness 0.2.x (peer deps currently pin <0.2.0) #2520 / Fix #2538: [memos-local-plugin] dsh 0.2.x session format V4 rejects plugin messages: "produ #2541; our 0.2.x installs keep the "snapshot"-style local pin until that lands.
    2. @chichi233's Windows Desktop trace (turn-fatal, session survives, clean session logs) is the clearest blast-radius documentation in this thread — worth folding into the release notes verification for the Windows path, as it also identifies the general anti-pattern (deciding source shape from a module constant instead of the live session) in sibling plugins.

    Thanks for the fix and for keeping the issue open for the compatibility work — no further action needed from us on the original V4 rejection itself.

  13. endxxxx commented on Nov 9, 2026

    @endxxxx
    Collaborator

    Thanks for the detailed reports and reproduction steps. #2519 fixed the V4 message-source error for both automatic recall and auxiliary host LLM calls. #2549 addressed the remaining issue that prevented the local plugin from loading on supported DSH 0.2 previews.

    Both fixes are available in @memtensor/memos-local-plugin 2.0.21-beta.1. If you're using a patched build or a local pin, you can switch to the published beta. For a DSH CLI profile, run:

    dsh plugin --profile web add @memtensor/memos-local-plugin@2.0.21-beta.1

    Replace web with your profile name and restart DSH. We verified recall injection, memos_get, and recall after restart on macOS with DSH Desktop 0.2.1-rc.5 and a live DeepSeek model.

    Closing as fixed. If you still see the V4 error with this beta, please share your DSH version, OS, and whether the failing turn had a memory hit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务ai:testingAI agent is running tests | AI 正在运行测试area:pluginOpenClaw & Hermesstatus:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions