dsh-context-continuum: Replacing Rolling Narrative Summaries with Append-Only Conversation Indexes

Introduction

DeepSeek Harness (DSH) triggers context compaction during long sessions: it compresses earlier messages into summaries to free up window space for new conversations. The official BasicCompactionEngine aligns the start of the replacement interval with the sequence (seq) of the previous summary. In practice, this causes the old summary to be rewritten in every generation, which tends to “flatten” (erode) early literal facts. If you care about whether “compressed content can still be retrieved exactly as it was” or if “summaries will grow indefinitely and leak structural artifacts,” you need to make a choice regarding your compaction strategy. The following introduces the community plugin dsh-context-continuum (Maintainer: zongyanbai, Category: Memory): without touching the official compaction skeleton, it only changes the output form of summarize(), transforming the “rolling rewritten narrative summary” into an “append-only session index,” accompanied by anchors and raw text retrieval tools.

What is this

dsh-context-continuum (npm package name @local/dsh-context-continuum, current version 0.1.0, MIT) is a subclass extension of the DSH compaction engine: it inherits from BasicCompactionEngine and only overrides summarize(). Cache reuse, model fallbacks, and session associations still follow the official paths.

Key mechanism points: The original text remains in the append-only session log; during compaction, the model only writes one new entry, and the assembler transports old entries verbatim, rather than rewriting the entire summary segment in every generation. In same-session A/B tests (see docs/AB-report.md in the repository), the maintainer compared the official rolling summary with this plugin’s session index regarding metrics such as the survival rate of early literal facts, summary length trajectory, and official narrative structure leakage—refer to that document for specific figures.

The repository README states: Assistance Wanted. Three desktop host defects have been documented with logs (see docs/DEFECTS.md); issues and PRs are welcome. Please read the source code and license yourself before use; the plugin runs with DSH process privileges. The community directory SkillHub Plugin Page and GitHub have no affiliation with DeepSeek or High-Flyer officials.

What Problems It Solves

When the official engine compacts, the start of the replacement interval is exactly the seq of the previous summary (README claims this happened 9/9 times in testing), meaning the same summary segment is repeatedly rewritten. This plugin targets the information morphology issues caused by the misalignment of the replacement interval start point, rather than simply blaming “the model writes bad summaries.”

Core Features

Compaction Strategy

  • Session Index: New compactions only append entries; old entries are inherited verbatim.
  • Official Flows: Still uses official processes like compactIfNeeded; does not issue ctx.llm.stream() on its own to avoid reimplementing prefix caching and fallback logic.

Agent Tools

Tool Purpose
context_anchors View compressed content: compactionId, compressed seq range, token count, summary model
context_read Retrieve the verbatim original text of the compressed interval via anchor (original text is not deleted, only obscured)
context_compact Manual in-place compaction

The serial number T<n> corresponds one-to-one with the nth successful compaction transaction; failures are not numbered and are presented as “no entry + failure reason.”

Main Source Modules (for code reading)

File Responsibility
src/engine.ts Compaction backend + registration of three tools
src/indexlog.ts Index templates, old entry inheritance, narrative body discarding, oversized overflow archiving
src/artifacts.ts Artifact ledger
src/anchors.ts Anchor ledger
src/trace.ts Retrieve original text via anchor
src/tools.ts External implementation of the three tools mentioned above

Installation and Enablement

Installation consists of three layers; if one layer is missing, it will not work:

Layer Location Function
① Bundle patch This repo’s cordis.patch.yml Grays out top-level compaction-basic, inserts this plugin
② Profile User Layer Target profile’s cordis.patch.yml Adds preset-continuum (deterministic transformation from standard)
③ Dependencies & Resolution Profile’s package.json + node_modules/@local/dsh-context-continuum Makes the package resolvable

The README provides a quick start example for Windows (please back up your profile first):

# 1. Backup profile
$p = "$env:USERPROFILE\.dsh\profiles\desktop"
Copy-Item "$p\package.json" "$p\package.json.bak" -Force
Copy-Item "$p\cordis.patch.yml" "$p\cordis.patch.yml.bak" -Force

# 2. Wiring (see table ①② above)
#    - package.json: add "@local/dsh-context-continuum" to bundles array
#    - cordis.patch.yml: append preset-continuum block

# 3. Dependencies (Windows uses directory junctions, not symbolic links —— dsh cannot resolve symbolic links)
cmd /c mklink /J "$p\node_modules\@local\dsh-context-continuum" "<path-to-this-repo>"

# 4. Restart DeepSeek Harness

# 5. Select the "continuum" agent preset in the session

Step 5 cannot be omitted: The plugin does not change the default preset; if continuum is not selected, it remains standard, and the tools will not be hooked up.

Rollback example:

Copy-Item "$p\package.json.bak" "$p\package.json" -Force
Copy-Item "$p\cordis.patch.yml.bak" "$p\cordis.patch.yml" -Force
cmd /c rmdir "$p\node_modules\@local\dsh-context-continuum"

To delete directory junctions, use cmd /c rmdir; do not use Remove-Item -Recurse (older versions of PowerShell might follow the junction and delete the source directory).

Dependencies: package.json requires Node >=22.19, peer dependencies @deepseek-ai/dsh-* etc. are >=0.2.0-rc.1 <0.2.1; local typecheck targets @deepseek-ai/dsh-*@0.2.0-rc.2.

Typical Usage

  1. Complete the installation as described above and select the continuum preset in the session.
  2. After a long conversation triggers auto-compaction, use context_anchors to see which seq segment was compressed each time and which summary model was used.
  3. When you need to verify the literal content that was compressed, use context_read to pull the original text via anchor.
  4. When you need to proactively free up window space, call context_compact for manual compaction.

Compaction-related parameters can be adjusted in the configuration (excerpt from README):

thresholdRatio: 0.5        # Trigger threshold (official default 0.8; suggest lowering for large window models)
headroomTokens: 65536      # Generation headroom
retainRatio: 0.16          # Retain the last 16% tail of original text
maxOverflowRetries: 1      # Force compaction and retry after provider reports CONTEXT_WINDOW_EXCEEDED
compactionRetries: 1
auto: true

Before changing parameters, pay attention to the hard constraints in the README, for example: headroomTokens: 0 causes entries not to activate; if retainRatio >= thresholdRatio, there is no interval available for compression; if the summary size is not smaller than the original text, the engine will refuse and handle it via the archiving mechanism (surface layer cap is 24 entries).

Suitable Scenarios and Notes

More Suitable For: DSH developers with long sessions who need to preserve early literal facts and hope to trace back to “compressed original text” via anchors; those willing to wire up profiles themselves and read docs/DEFECTS.md and the A/B report before deciding whether to adopt.

Must Be Aware:

  • Known defects (High/Medium priority) include: compaction misjudging task information as “insufficient information”, <think> potentially leaking into entries, compaction triggering too late and not controlling total context volume—details are subject to docs/DEFECTS.md.
  • No dsh plugin add one-click command; installation is manual patch + local package resolution. Linux/macOS users need to wire up the three layers themselves according to the README (junction methods and paths differ from the Windows example; refer to repository documentation).
  • The plugin runs with the same permissions as the host code; please review the GitHub Repository source code and MIT license before installation.

Maintainer’s local verification commands:

npm install
npm test            # 101 unit tests / 10 files
npm run typecheck
npm run build       # Outputs lib/; delete lib/ before building to avoid interference from old artifacts

Conclusion

dsh-context-continuum changes DSH context compaction from “rewriting summaries every generation” to an “append-only session index,” and exposes anchor and original text reading tools. It is suitable for minimal-invasive experimentation and comparison on top of the official compaction mechanism. It is currently still soliciting community fixes for known defects; for more information, see the SkillHub Directory Page and GitHub: zongyanbai/dsh-context-continuum.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye