KitDoesIt/dsh-compaction-instant5

dsh-compaction-instant

VCC-style instant, near-lossless deterministic compaction engine for the DeepSeek Harness — a drop-in replacement for @deepseek-ai/dsh-compaction-basic

AI Analysis

核心用途是作为内置压缩引擎的替代品,提供更高效、近无损的上下文即时压缩。适合处理超长对话、需要优化上下文窗口占用并保留关键近期记忆的高频用户。

Package
dsh-compaction-instant
Version
0.1.4
License
MIT
Last updated
Aug 14, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:KitDoesIt/dsh-compaction-instant

Configuration

All fields optional; defaults shown.

KeyDefaultMeaning
thresholdRatio0.5Fraction of the routed model's context window that triggers automatic compaction
retainRatio0.05Fraction of the context window kept verbatim at the surface tail
retainTokensExact tail budget; mutually exclusive with retainRatio
manualRetainRatio0.05Fraction of the measured surface kept verbatim by a manual /compact (so the recent conversation is never compiled away)
manualRetainTokensExact manual tail budget; mutually exclusive with manualRetainRatio
autotrueRegister agent/pre-step pressure and agent/request-error overflow recovery
maxTokens8192Floor of the total cap for one compiled checkpoint (density-aware tokens)
checkpointScale0.1The effective cap is max(maxTokens, shadowed × checkpointScale), ceilinged at checkpointCap — a large span never crushes every entry into a sliver
checkpointCap65536Absolute ceiling of the scaled checkpoint cap
textTokens512Budget per assistant text block
userTextTokens1024Budget per user text block
toolCallTokens128Budget per tool-call one-liner (never rescaled — see the elision rules)
toolResultExcerptTokens256Accepted for compatibility; inert — tool results no longer occupy entries
includeReasoningfalseKeep reasoning blocks in the checkpoint
stripNoiseXmltrueStrip configured noise wrappers from user text
noisePatternssee compilerNoise XML regex sources, applied with the s flag
toolKeyFieldsbuilt-insExtra tool-name → argument-field map for one-liners
toolArgToolssee compilerWhitelist whose key argument renders in the one-liner (read/write/edit/glob/grep/bash/shell/web_search/skill/subagent/…); every other tool is name-only
hideToolsBookkeeping tools dropped from the checkpoint entirely
modelPoliciesPer provider/model overrides of thresholdRatio/retain* (basic-compatible shape)
compactionRetries / maxOverflowRetries1 / 1Retry budgets, same semantics as basic
summarizationProvider / summarizationModelAccepted for config drop-in compatibility; inert — this backend never routes a model

The tool and command plugins each take their own { maxRecallTokens?: 16000, maxSearchHits?: 50 } config.

Cordis config gotcha: the plugin row's config passes through the schemastery schema, whose ~standard adapter injects [] for every absent array key (toolArgTools, hideTools, noisePatterns, toolKeyFields, modelPolicies). The resolver treats an empty list as unset and falls back to the defaults — so a missing toolArgTools keeps the built-in whitelist (never disable it by writing toolArgTools: []; empty means default). debug: true writes per-compile diagnostics to the configured debugLogPath (default $DSH_HOME/compaction-debug.log).

Budgets are enforced twice — by token count and by a budget × 4 character ceiling — so pathological unbroken runs (base64 blobs, minified files) cannot bypass them. Tool calls are always one line: they are never rescaled, and the cap loop shrinks only the conversation-text budgets (floor 32 tokens each). If the compiled region still exceeds the (scaled) cap, the oldest tool rows are removed first ([N tool/result entries elided: seqs a-b]), and only then the oldest remaining entries ([N earlier entries elided: seqs a-b]) — tool calls can never squeeze the dialogue out. The newest content always survives.

Browser settings card (Settings → Plugins)

Since 0.1.4 the engine exposes a user-owned settings namespace (compaction-instant) on every deployment that composes the settings domain (the standard web/desktop profiles do). The editable subset, persisted to settings.yaml and layered over the plugin row's cordis config:

FieldMeaning
checkpointScaleCheckpoint budget = shadowed tokens × this ratio
checkpointCapAbsolute ceiling of the scaled budget
maxTokensTotal compiler-token cap for one checkpoint
autoRegister automatic between-step compaction
debugWrite engine debug lines to the log file
debugLogPathDebug log path (empty = $DSH_HOME/compaction-debug.log)

Everything else (modelPolicies, toolArgTools, …) stays cordis-config-only. The settings layer never breaks the engine: every settings write is re-validated by the full config resolver before it is persisted, and non-exposed entry fields keep their composed values. Without a settings service the engine behaves exactly as before (composition entry only). The card is registered on the client bundle, so it appears without touching any deployment config beyond installing the package — restart dsh web once so the boot graph picks up the dsh.client bundle.

Tokenizer and multilingual behavior

The tokenizer is a character-class heuristic: ASCII letter runs and digit runs count as one token each, punctuation is per-character, whitespace is free, and every other code unit is its own token. Concretely:

ContentTokens
CJK (你好,世界!)1 per code point (6)
Cyrillic / Arabic1 per code unit
Accented Latin (café)ASCII runs stay grouped (caf + é)
Emoji (😀)2 (surrogate pair)

Every truncation, excerpt, and cap cut is taken at a code-point boundary — a slice never leaves a lone surrogate half, so emoji and other astral characters always reach the model intact (pinned by test/multilang.test.js). The character-density ceiling uses UTF-16 length, which is the conservative side for astral content.

The harness token meter (used for the shrink guarantee and /compact reporting) is a separate chars / 4 + block overhead estimator; the two deliberately coexist — see the top-level design notes.

Method 3 — Direct install + manual preset configuration

dsh plugin --profile web add dsh-compaction-instant
mkdir -p "$DSH_HOME/.agent-presets/"