mili1360/dsh-history-fold ↗★ 0
dsh-history-fold
将超长会话的历史记录折叠并归档至本地 适合拥有极长上下文会话、希望减少每次请求Token费用的用户。
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:mili1360/dsh-history-fold说明文档
阅读完整 README ↗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.
| Key | Default | Meaning |
|---|---|---|
enabled | false | Master switch. false ⇒ loaded but completely idle. |
dryRun | true | true ⇒ observe and log only, never write. |
profile | true | Write one size/profile line per turn. |
triggerSurfaceTokens | 250000 | Fold only above this much visible history. |
targetSurfaceTokens | 180000 | Fold down to about this much. Must be reachable — see below. |
keepRecentNodes | 60 | Never fold the most recent this-many nodes. |
minFoldNodes | 20 | Refuse to fold fewer nodes than this. |
minFoldTokens | 20000 | Refuse to fold fewer tokens than this. |
archive | true | Write the lossless pre-fold archive. Leave this on. |
archiveDir | history-fold/archive | Relative to $DSH_HOME. |
digestMaxChars | 30000 | Cap on the in-context index. Over budget ⇒ sample, never truncate. |
digestLineChars | 160 | Characters of each sampled message shown in the index. |
onlyAtTurnStart | true | Fold only before a turn's first step, never mid-turn. |
logFile | logs/history-fold.jsonl | Relative to $DSH_HOME. |
memoryFeed | false | Post the same digest to a memory service after each fold. |
memoryFeedUrl | — | e.g. http://127.0.0.1:7999/memory-eternal/api. |
targetSurfaceTokensmust be reachable. At leastkeepRecentNodesnodes 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 logno-safe-cutevery turn.
Relation to the built-in compactor, and to the other "fold"-named plugins
built-in dsh-compaction-basic | this plugin | UI-fold plugins | |
|---|---|---|---|
| What replaces the history | a model-written summary | an extractive index + an archive pointer | nothing — the request is untouched |
| Cost per fold | one extra model call | none, no model call at all | none |
| Is the original kept | no — the summary is all that survives | yes, verbatim, in $DSH_HOME/history-fold/archive/ | n/a |
| Recoverable | no | yes, with one rg over the archive | n/a |
| What it changes | the surface (what the model is sent) | the surface (what the model is sent) | the display (long messages collapsed in the UI) |
| Trigger | thresholdRatio × contextWindow, 800k by default | triggerSurfaceTokens; keep it below the compactor's line | n/a |
Keep the trigger below the compactor's line.
dsh-compaction-basicfires atthresholdRatio × contextWindow—0.8 × 1,000,000, so 800k — and keeps0.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.