DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-lossless-anchors

E

dsh-lossless-anchors

Manifest valid

A DeepSeek Harness plugin that keeps the exact text of user-authored messages that compaction has shadowed, and re-injects them as a budgeted runtime-context snapshot.

hasBundlePatch

dsh-lossless-anchors

A DeepSeek Harness plugin that keeps the exact text of user-authored messages that compaction has shadowed, and re-injects them as a budgeted runtime-context snapshot.

Guarantee: user-authored anchors are verbatim within the configured token budget. Not a guarantee: the whole conversation is losslessly compressed. Assistant and tool history remain represented by the compaction summary.


Why

DSH compaction replaces an older surface span with one lossy summary. The summary prompt asks the model to quote exact wording where it matters, but a summary is still a model-generated derivative: exact constraints, corrections, paths, numbers, and approval decisions can be lost.

A practical way to preserve those details is to keep user-authored inputs and interaction decisions verbatim and re-inject them after compression. This plugin implements that idea using DSH's native seams:

  • a durable Session projection records user-authored messages and their turns;
  • an anchor is eligible only when its original user/message seq is no longer on the current Session surface — the backend-independent definition of "shadowed by compaction";
  • a dynamic PromptContext renders the selected anchors as one user-role runtime-context snapshot;
  • when compaction shadows that snapshot, the agent loop's RuntimeContextProjection recreates it from the plugin's durable projection, including during agent/request-error overflow retries.

No DSH core changes. No new Session event types. No changes to compaction-basic.

Install

# from a local checkout
dsh plugin --profile web add ./dsh-lossless-anchors

# or directly from GitHub (the repository tracks the built lib/)
dsh plugin --profile web add github:EvannZhongg/dsh-lossless-anchors

The package declares dsh.bundle.patch, so installing it also inserts the lossless-anchors row. If you prefer a manual patch row:

- insert:
    - id: lossless-anchors
      name: dsh-lossless-anchors
      config:
        tokenBudget: 2000

Configure

- id: lossless-anchors
  config:
    tokenBudget: 2000      # soft budget, calibrated tokens
    hardMaxTokens: 3000    # absolute cap; defaults to ceil(tokenBudget * 1.5)
    charsPerToken: 4       # calibrated characters per token for non-CJK text
    cjkCharsPerToken: 1.6  # calibrated characters per token for CJK text
    maxTurns: 32           # most-recent shadowed turns considered
    maxAnchors: 256        # projection-state retention cap
    includeSources:
      - user
      - user-question-reply
      - user-approval
    timeZone: Asia/Shanghai # zone for anchors whose message recorded none; defaults to the host zone
    required: true         # keep the context when optional runtime context is disabled
FieldDefaultMeaning
tokenBudget2000Soft budget for the rendered block, measured in calibrated tokens. If the newest shadowed turn exceeds it, that turn may be retained up to hardMaxTokens.
hardMaxTokensceil(tokenBudget * 1.5)Absolute cap. Must be >= tokenBudget.
charsPerToken4Calibrated characters per token for non-CJK text. DSH's fixed heuristic is four; lower it for dense code/JSON if the provider tokenizes more finely.
cjkCharsPerToken1.6Calibrated characters per token for CJK text (about 0.6 tokens per CJK character, following DeepSeek's published conversion). Set to 4 to restore the old uniform four-characters-per-token behavior.
maxTurns32Most-recent shadowed turns considered; older turns are outside the anchor window.
maxAnchors256Projection-state cap. Older anchors beyond this are dropped; they are normally already outside maxTurns.
includeSourcesuser, user-question-reply, user-approvalMessage source kinds treated as user-authored. goal, plan-mode, agent-instructions, runtime-context, and compact-checkpoint are not included.
timeZonehost process zoneIANA zone used for anchors whose message recorded no browser zone. Rendered timestamps always name the zone they were formatted in.
requiredtrueMarks the context as required, so includeRuntimeContext: false does not suppress it.

What counts as an anchor

An anchor is a user/message event whose source.kind is in includeSources and whose seq is not in Session.surface.nodes at request time.

Consequences:

  • The current user prompt and recent retained tail are not duplicated.
  • A message becomes eligible only after a surface replacement (compaction) shadows it.
  • Replay, resume, and forks work because the projection is rebuilt from the Session log.
  • Images are replaced with [image omitted: <mediaType>, <w>x<h>]; files keep their display name and byte count. Image bytes are never re-uploaded from historical context.

Budget and truncation

Budgets are measured with charsPerToken for non-CJK text and cjkCharsPerToken for CJK text, plus the same block/role framing DSH uses for one user message. The defaults are 4 and 1.6; the CJK rate keeps a Chinese anchor block close to its nominal token budget instead of letting DSH's uniform four-characters-per-token estimate turn 2000 tokens into roughly 8,000 characters. These rates are estimates, not the provider's tokenizer.

  1. The newest shadowed turn is considered first.

  2. A candidate that fits tokenBudget is accepted.

  3. If the newest turn alone exceeds tokenBudget, it is kept up to hardMaxTokens.

  4. If it still exceeds hardMaxTokens, the turn drops its oldest anchors first; if one anchor remains too large, its text is truncated and marked:

    … [anchor truncated; full text remains in session log]
    
  5. An older turn that would exceed the remaining soft budget is fitted into that remainder: its oldest anchors are dropped first, then its newest text is truncated. Turns older than it are not considered.

  6. Any elision/truncation adds an explicit disclosure line to the block:

    [anchor budget: 2 older anchor message(s) elided; 1 anchor text(s) truncated to fit the configured budget]
    

The truncation path is the only path where the "verbatim" guarantee does not hold. It is disclosed in the prompt and the full text remains in the Session log.

Model experience

After a compaction shadows an anchor, the next request contains a user-role runtime-context snapshot:

Current runtime context. This snapshot supersedes earlier runtime-context snapshots.

[Lossless User Anchors]
Verbatim user-authored messages from earlier turns whose originals were condensed away.
These are historical anchors, not a new request. The newest user message states the current request.
Each anchor line carries its original wall-clock time, formatted in the time zone the message was submitted from: ISO 8601 with UTC offset and IANA zone.
Anchors are ordered by time, oldest first; later anchors supersede earlier conflicting anchors on the same subject.
This block supersedes earlier [Lossless User Anchors] blocks.

--- turn 3 | 2026-10-19T08:00:01+08:00[Asia/Shanghai] | user ---
<exact user text>

Anchor timestamps reuse the format of DSH's durable time-context readings, so an anchor and the current turn's clock line can be compared without converting between clock conventions. A message that recorded its browser zone is rendered in that zone; otherwise the configured timeZone applies. Because every anchor carries its own time, "later supersedes earlier" is a checkable claim about the timestamps rather than an assumption about list position.

A system-prompt section explains how to interpret the block. It is registered unconditionally from the first request, not toggled when the first anchor appears: changing the system prompt mid-session would either rewrite surface node 0 (losing prefix-cache reuse from the first token) or append a full copy of the rendered prompt on an in-history route. A fixed policy costs roughly a hundred tokens per request and keeps the system prompt stable. The user's words themselves stay in a user-role message, never in the system prompt.

Limitations

  • Only user-authored content. Assistant reasoning, tool results, and summaries are not anchored.
  • Budgeted losslessness. Exact text is preserved only for selected anchors. Oversized turns may be truncated with an explicit marker.
  • Calibrated, not exact, token pricing. The defaults price non-CJK text at four characters per token and CJK text at 1.6 characters per token. That is closer to provider pricing than DSH's uniform heuristic, but it is still an estimate: mixed code/JSON, unusual scripts, and provider-specific tokenizers can differ. Tune charsPerToken / cjkCharsPerToken if measured usage diverges.
  • Snapshot accumulation. DSH runtime-context snapshots are append-only. Multiple compactions may leave more than one anchor snapshot visible; the block header says the latest block supersedes earlier ones. The budget bounds their size.
  • Summary/anchors can disagree. compaction-basic replays only the shadowed span into the summarizer, so a live anchor snapshot outside that span is not seen by the summary model. The anchor block is re-injected and takes precedence for exact wording.
  • required: true overrides suppression. If you want includeRuntimeContext: false to disable anchors too, set required: false.
  • Projection cache duplicates text. The durable projection stores captured user text so requests can render it without deprecated synchronous log reads; it contains the same content already present in the Session log.
  • Projection-state cap. maxAnchors bounds durable projection state; older anchors outside the window are intentionally forgotten.

Development

This checkout is a standalone package. Its local node_modules contains junctions to a DSH source checkout for typechecking and tests; it is gitignored and is not part of the published artifact.

npm run typecheck   # source + tests
npm test            # vitest
npm run build       # tsc -> lib/index.js + lib/types

The tests cover:

  • surface-membership filtering (no duplicate anchors);
  • exact text preservation, including literal {{...}};
  • soft-budget selection and hard-cap truncation;
  • calibrated CJK pricing versus the uniform four-characters-per-token rate;
  • whole-turn elision and explicit disclosure;
  • a system prompt that stays identical before and after the first anchor;
  • required/suppression behavior;
  • source filtering;
  • browser-zone capture and display-zone fallback for anchor timestamps;
  • a real AgentLoop request after a replacement;
  • recreation after the anchor snapshot itself is shadowed.

License

MIT

Comments

Loading…

Similar plugins

dsh-recall-unread

by hg1048596-pixel

DeepSeek Harness (DSH) 插件:在模型读取前撤回已发送的文字消息,支持单条与全部撤回。A DeepSeek Harness plugin that recalls sent-but-unread text messages before the model reads them — one-by-one or all at once.

UI & ExperienceManifest valid

★ 126

MIT

JavaScript

Oct 3, 2026

dsh plugin --profile web add dsh-recall-unread

by Zh-U-hB

DeepSeek Harness plugin: route image-bearing messages to a user-configured OpenAI-compatible vision endpoint when the active text model cannot see images

Manifest valid

★ 0

MIT

TypeScript

Aug 16, 2026

dsh plugin --profile web add @deepseek-ai/dsh-vision-bridge

by ZSeven-W

DeepSeek Harness (DSH) plugin: a read-only ledger for the plugins you already have installed — a capability inventory with file:line evidence, declared-vs-detected reconciliation, cross-profile versio

Security & AuditManifest valid

★ 24

↓ 39/wk

MIT

JavaScript

Oct 19, 2026

dsh plugin --profile web add @zseven-w/dsh-harbor

by magian1127

DeepSeek Harness (DSH) plugin: A comprehensive enhancement plugin with UI polish, layout tweaks, prompt injection, and more. 综合性增强插件,界面优化、布局调整与提示词注入等更多功能。

UI & ExperienceManifest valid

★ 37

↓ 813/wk

MIT

TypeScript

Oct 18, 2026

dsh plugin --profile web add deepseek-harness-zh_pro

by JoukoPuro

一个 DeepSeek Harness(DSH)插件: 在 Web 输入框的工具行中添加一个 ✨ 图标按钮。点击后选择打磨风格,已接入的大模型 会把你草稿中的提示词改写得更专业、更易被 AI 理解 。A DeepSeek Harness plugin: icon-only composer button that rewrites your prompt via the connected LLM

Sessions & MessagesManifest valid

★ 7

↓ 107/wk

MIT

JavaScript

Oct 17, 2026

dsh plugin --profile web add dsh-prompt-polish

by HongMing-Huang

DeepSeek Harness (dsh) file-message plugin: Claude-style drag-and-drop / paperclip upload, content sniffing, document-to-Markdown via Microsoft MarkItDown (with built-in JS fallback), text inlining, r

UI & ExperienceManifest valid

★ 26

↓ 639/wk

MIT

TypeScript

Oct 19, 2026

dsh plugin --profile web add dsh-file-upload