mili1360/dsh-history-fold ↗★ 0

dsh-history-fold

将超长会话的历史记录折叠并归档至本地 适合拥有极长上下文会话、希望减少每次请求Token费用的用户。

套件
dsh-history-fold
相容性
待驗證
版本
0.1.0
授權
MIT
最近更新
2026年10月12日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:mili1360/dsh-history-fold

Configuration

$DSH_HOME/dsh-history-fold/config.json (falling back to ~/.dsh/…). It is re-read on every turn, so edits apply without a restart.

KeyDefaultMeaning
enabledfalseMaster switch. false ⇒ loaded but completely idle.
dryRuntruetrue ⇒ observe and log only, never write.
profiletrueWrite one size/profile line per turn.
triggerSurfaceTokens250000Fold only above this much visible history.
targetSurfaceTokens180000Fold down to about this much. Must be reachable — see below.
keepRecentNodes60Never fold the most recent this-many nodes.
minFoldNodes20Refuse to fold fewer nodes than this.
minFoldTokens20000Refuse to fold fewer tokens than this.
archivetrueWrite the lossless pre-fold archive. Leave this on.
archiveDirhistory-fold/archiveRelative to $DSH_HOME.
digestMaxChars30000Cap on the in-context index. Over budget ⇒ sample, never truncate.
digestLineChars160Characters of each sampled message shown in the index.
onlyAtTurnStarttrueFold only before a turn's first step, never mid-turn.
logFilelogs/history-fold.jsonlRelative to $DSH_HOME.
memoryFeedfalsePost the same digest to a memory service after each fold.
memoryFeedUrl—e.g. http://127.0.0.1:7999/memory-eternal/api.

targetSurfaceTokens must be reachable. At least keepRecentNodes nodes always stay, which is at least that many steps' worth of tokens. A target below that floor can never be met and the plugin will log no-safe-cut every turn.

Relation to the built-in compactor, and to the other "fold"-named plugins

built-in dsh-compaction-basicthis pluginUI-fold plugins
What replaces the historya model-written summaryan extractive index + an archive pointernothing — the request is untouched
Cost per foldone extra model callnone, no model call at allnone
Is the original keptno — the summary is all that survivesyes, verbatim, in $DSH_HOME/history-fold/archive/n/a
Recoverablenoyes, with one rg over the archiven/a
What it changesthe surface (what the model is sent)the surface (what the model is sent)the display (long messages collapsed in the UI)
TriggerthresholdRatio × contextWindow, 800k by defaulttriggerSurfaceTokens; keep it below the compactor's linen/a

Keep the trigger below the compactor's line. dsh-compaction-basic fires at thresholdRatio × contextWindow — 0.8 × 1,000,000, so 800k — and keeps 0.16 × window (160k). Its replacement is a model-written summary, which is lossy. Folding first is what stops that summarizer from ever firing at all.

A plugin with fold in its name is often a display fold: it collapses a long message in the UI so it is easier to read, and leaves the request payload exactly as it was. This plugin is the opposite — it does not touch the UI at all, and every byte it moves is aimed at the tokens sent on the next request. Decide which of the two you actually want before installing.

For the on-disk side of the same problem — session logs growing because finalised streaming fragments are never removed — see dsh-session-vacuum.