rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:yli42409-tech/dsh-session-durability
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A small pill in the DeepSeek Harness composer that tells you how used up the current conversation is.
Long coding sessions do not fail all at once. They get compacted, details get folded away, and the model starts restating the same skeleton with less and less underneath it. By the time the answers feel circular, you have usually been paying for it for a while. This plugin puts a number on that wear so you can see it coming.
● 74 ← the pill, always visible in the composer dock
click it:
74 / 100 Good
██████████████░░░░░░
Context (after compaction) 52% · 520K
Compactions 3 (shed 180K)
Degeneracy 0.0%
assistant 210
Tool calls 260
Nodes 470
Healthy, keep going.
Three independent kinds of wear, folded into one score from 5 to 100:
| Signal | Source | Why it matters |
|---|---|---|
| Context occupancy | Host contextPressure projection |
How full the real context window is. Only starts to hurt past ~70%. |
| Compaction count | Host durabilityCompaction projection |
Compactions that actually produced a summary. A failed attempt logs compaction/start, then compaction/end carrying an error, and never a summary — counting starts over-reports (one real session showed 4 starts for 3 successful compactions). |
| Degeneracy | The conversation snapshot | Repetition inside a single reasoning block. A trailing sign-off habit scores a few percent; real looping scored 22-24% in the sessions that broke down. |
| History growth | maxSeq of the log |
How old the conversation is, even when only a window of it is loaded. |
The compaction numbers are the reason this needs a Host half at all: compaction/start,
compaction/summary and compaction/prune are session log events, not surface events, so they never appear
in the conversation snapshot the client can see. The plugin registers a session projection, folds those events
into counters, and wires the result to the client under the key durabilityCompaction.
There are exactly two halves, and each exists for a reason.
┌───────────────────── Host ─────────────────────┐
│ session log events │
│ compaction/start · summary · prune · end │
│ │ │
│ ▼ fold (pure, synchronous) │
│ durabilityCompaction projection │
│ │
│ contextPressure projection │
│ { pressureTokens, contextWindow } │
└─────────────────────┬───────────────────────────┘
│ wire.view, pushed on change
▼
┌──────────────────── Client ────────────────────┐
│ useChat → chat.legacy.nodes │
│ useProjection('contextPressure') │
│ useProjection('durabilityCompaction') │
│ │ │
│ ▼ computeMetrics() │
│ score · bar · panel · tooltip │
└────────────────────────────────────────────────┘
compaction/* records live only in the session log. The client
literally cannot see them, and the plugin must not scan the log on the client. So the Host folds them once
into a projection and ships the small result: that is the entire reason for index.js.contextPressure projection
already knows the real window per session, so the pill asks for it. Guessing a number would silently produce
wrong percentages on every model with a different window size.The Host half also stays deliberately tiny: a pure fold (apply returns the same state reference for events
it does not care about, so unchanged sessions cost nothing), and a view that only carries four counters.
| Penalty | It means | It does not mean |
|---|---|---|
contextPenalty |
The window is genuinely filling up | That the answer quality has dropped |
degeneracyPenalty |
The model is repeating itself inside one block — a detail-loss symptom | That the whole session is broken |
historyPenalty |
The log is old and long | Anything about the currently loaded window |
Compaction count is shown but not scored. Compaction is a healthy, normal mechanism — the number next to the score is there so you can see how much detail has already been folded away, not to punish the session for using it.
Two things here are easy to get wrong. Both were wrong in the first release and are now covered by tests:
compaction/start is an attempt, not a success. Attempts fail — one real log had start, then
end one second later carrying "Service is too busy...", and no summary at all. The count therefore
comes from compaction/summary, which exists only when a summary was actually produced. Failed attempts
are counted separately and shown as · N failed.compaction/prune reports the tool results trimmed alongside a
compaction; compaction/summary reports the whole block replaced by the abstract. On one real session
those were 189K and 355K — using the prune total under-reported by nearly half, and on another session
by 21×.Run npm test to check the fold against synthetic event sequences, including the failure and mismatch cases
above.
This is a DSH bundle (it ships dsh.bundle.patch). Install the directory with the Harness plugin manager,
either from the Plugins page or through the plugin_manager tool with install_bundle and this directory as
the target. It has no runtime dependencies and needs no build step: client.js is loaded as-is by the
browser module loader.
After installing, the pill appears in the composer dock next to the other session indicators.
If you are adding it to a session that is already open, switch to another session and back once. The Host only pushes projection values on change, so a brand-new key does not reach an already-open session store until it is re-seeded. This affects every new projection key, not just this plugin.
Replacing an existing installation of the same package name with one from a different directory reports
restart-required(reasonpackage-moved) and needs a full app restart. A first-time install does not.
score = 100 - contextPenalty - degeneracyPenalty - historyPenalty (clamped to 5..100)
contextPenalty = 0 below 70% occupancy, ramps to 70 points at a full window
degeneracyPenalty = 0 below 12% repetition, +5 per point above, capped at 60
historyPenalty = min(30, maxSeq / 300)
Good ≥ 70, Tight 40-69, Replace < 40.
These thresholds are calibrated, not derived: they come from long Chinese coding sessions where the breakdown point was observable. Treat them as a starting point.
Everything tunable sits in one object at the top of client.js (DEFAULTS): the context fallback window, the
70% soft start, the 12% degeneracy floor, the 300-seq history scale, and how many recent nodes the degeneracy
scan looks at. Edit the values and reload the page.
Localized strings live in the STRINGS object in the same file, currently zh and en. Adding a language
means adding one object.
好。. For English sessions the metric is disabled by default (empty pattern)
rather than reporting a meaningless zero. Set degeneracyPattern to a pattern that fits the language you
actually see looping.legacy.nodes is an internal snapshot shape. It works on the DSH version below, and a future Harness
release may change it. The score then degrades gracefully to — rather than throwing.npm test replays synthetic compaction sequences through the
Host half's fold; the client panel is verified by hand.Developed and tested against DSH 0.2.2-rc.1 (profile desktop). It depends on:
conversation.composer.dock slotcontextPressure session projection (falls back to a 1,000,000 token window if absent)chat.legacy.nodes with per-node usage.totalTokens and blocksCode written by 宝贝, the AI assistant running inside DeepSeek Harness, working together with @yli42409-tech. The idea, the thresholds and the calibration data come from running real long coding sessions in the harness, where the failure mode was visible long before it was diagnosable.
This plugin stands on these open-source projects:
| Project | What this plugin takes from it |
|---|---|
| DeepSeek Harness | The host application itself: its plugin model, slot system, theme tokens, client module loader and session projections. |
@deepseek-ai/dsh-session-projection (part of DeepSeek Harness) |
The projection contract this plugin's Host half implements: a pure synchronous fold, reference-equality publication, and a wired view for the client. |
@deepseek-ai/cordis |
The plugin/context framework the harness is built on. |
| React | Rendering. Supplied by the harness module table; not bundled here. |
| The harness's own composer indicators | The visual and interaction pattern for a dock pill and its pop-over — matched rather than invented, so the plugin reads as part of the app instead of a widget bolted on. |
The scoring model is a heuristic assembled from observation rather than taken from a paper. Its thresholds are calibrated on real sessions and documented as calibrated values, not as theory.
MIT. See LICENSE.
对话耐久度面板,挂在 DSH 输入框下方。它把这条会话的「磨损」折成一个 0-100 的分数:
contextPressure 投影给的真实窗口大小,不是猜的compaction/* 是会话日志事件,客户端看不到,所以由 Host 侧折成投影再传下来。只数真的产生了摘要的压缩(compaction/summary)——失败的尝试也会留下 start,但不计入,真实日志里出现过 4 次 start 只成功 3 次的情况。「吃掉多少」取 summary 记的整块 token,不是 prune 记的工具结果:后者只覆盖被裁剪的工具输出,实测会少算一半到二十倍。装上以后,已经打开的会话需要切换一次再切回来才能拿到新投影。
如果是用同一包名、换一个目录重装(例如先装了别的副本再换回来),DSH 会报 restart-required
(原因 package-moved),必须整个重启应用;首次安装不需要。
阈值都在 client.js 顶部的 DEFAULTS 里,文案在 STRINGS 里,想加语言加一个对象即可。
代码由 宝贝 编写——运行在 DeepSeek Harness 里的 AI 助手。需求和阈值调校来自 @yli42409-tech 在真实长会话里的观察:会话是先变得啰嗦、再开始打转的, 这个面板就是把那段过程变成能看见的数字。
项目站在这些开源项目上面,不是从零发明的:
| 项目 | 它给了这个插件什么 |
|---|---|
| DeepSeek Harness | 宿主本体:插件模型、slot 系统、主题 token、客户端模块加载器、会话投影 |
@deepseek-ai/dsh-session-projection(DSH 的一部分) |
Host 半边实现的投影契约:纯同步 fold、引用相等才发布、wire view 推给客户端 |
@deepseek-ai/cordis |
DSH 底下的插件 / 上下文框架 |
| React | 渲染,由宿主模块表提供,不打进包里 |
| DSH 自带的 composer 指示器 | 标签胶囊和弹层的视觉与交互参照——照着宿主做,而不是自己造一套 |
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。