New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

dsh-context-mode-compaction

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsh-context-mode-compaction

Lossless checkpoint strategy for DeepSeek Harness: keeps the full conversation transcript and archives tool output to the context-mode knowledge base

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
12
20%
Maintainers
1
Weekly downloads
 
Created
Source

dsh-context-mode-compaction

English | 中文

A lossless checkpoint strategy for DeepSeek Harness.

DSH's shipped compaction asks a model to retell the conversation in eight fixed sections. Tool output has no section of its own, so it survives only as whatever prose the summarizer happened to write — in practice most of what was actually said is gone. This package replaces that strategy with one that rebuilds the conversation from the events themselves.

It is a drop-in dsh-compaction-basic engine. It runs the shipped summarizer first and unmodified, then appends two sections below its output.

What a checkpoint keeps

SourceWhat survivesDetail
user/messagewhole messageA message over 1,000 chars keeps its first and last 500; the middle is archived and reachable.
assistant/messagehead + tailFirst and last 200 chars; the middle is archived. Messages under 400 chars are kept whole.
tool/resultan index line onlyNever copied. One line names the tool, its size, and where its output lives.

Every clipped or dropped region leaves a pointer naming the source to search and the seq it came from, so the checkpoint says which event lost detail rather than merely that an archive exists.

Harness-injected blocks (<active_memory>, <current_runtime_context>, <system-reminder>, skill catalogs, prior checkpoints) are discarded: they are not conversation and would otherwise crowd out the real turns.

What a checkpoint looks like

## Conversation Transcript

## [user 6925]
重启并压缩了

## [assistant 7319]
⏵ 固化回归测试 在你重启期间,我把这次的验证固化成永久回归测试…

## [tool read seq 7321, 2242 chars → search `session/<id>/finding`]

## Archive Index

The raw transcript of this span was archived to the context-mode knowledge
base before it was condensed, so detail the summary above omits is still
retrievable with `ctx_search`. Scope each query to one layer by `source`:

- `source: "session/<id>/constraint"` — user messages: requirements, decisions, limits
- `source: "session/<id>/finding"` — tool results and stated conclusions
- `source: "session/<id>/narrative"` — assistant reasoning and plans

Install

This package is the strategy. It works on its own, but the archive index it writes only resolves if you also run the archiver, which lives in the companion package:

npm install dsh-context-mode dsh-context-mode-compaction

Then point the preset's compaction row at this package:

npx dsh-context-mode-compaction

That rewrites exactly one field — the name of the compaction-basic row inside the preset's compaction group — leaving every other line, comment, and !!js expression byte-for-byte intact. It backs the file up first.

npx dsh-context-mode-compaction --check     # report what would change
npx dsh-context-mode-compaction --revert    # restore the previous row

Restart DSH after wiring.

Why a script instead of just editing the preset

A preset row whose name is a bare package specifier resolves from the harness base, not from the profile that installed the package. A user-installed package is therefore invisible to such a row, and DSH marks the whole preset broken. Rows whose name is relative resolve against the preset's own directory instead — a base your installed copy can actually reach. The script computes that relative path for you.

Requirements

  • Node ^22.19 || >=24
  • @deepseek-ai/dsh-compaction-basic ^0.1.5-rc.2 (peer)
  • @deepseek-ai/cordis ^4.0.2 (peer)

Verifying it is actually running

A checkpoint's own text can never verify itself: the summarizing model copies whatever it is shown, so a marker quoted back from an earlier transcript is indistinguishable from one the engine wrote. Check the durable session log instead.

node scripts/verify-checkpoint.mjs <session-id>

It reads the compaction/summary events and structurally inspects what the engine wrote — the transcript's own ## [user …] / ## [tool …] entry syntax, which only the renderer emits, and archive sources anchored as the summary's final heading. VERDICT: the lossless strategy is live and exit 0 mean it ran.

Development

npm run verify   # build + smoke + wrapping + manual-range regressions

verify covers the two failure modes this engine has actually hit:

  • Cordis callable wrapping. A service declaring static [Service.invoke] is replaced by a new function object, so a #private field cannot survive and a WeakMap keyed on this can lose its key. repro-range.mjs pins this.
  • The manual compactNow path. DSH routes automatic pressure and overflow through compactRegion(), but /compact calls compactSurfaceRegion() directly and never touches it. A range captured only in compactRegion is therefore absent for every manual compaction, which produced checkpoints with an index pointing at a transcript that was never written. repro-manual-range.mjs pins the recovery: the summarizer's input messages are projections of the shadowed events, cached per surface node, so matching them back by identity recovers the span exactly.

License

MIT

Keywords

dsh

FAQs

Package last updated on 13 Sep 2026

Related posts