DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

yli42409-tech /

yli42409-tech/dsh-session-durability

Verified

A conversation durability score for DeepSeek Harness: context, compaction and repetition wear in one pill.

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@10f2223a

dsh-session-durability

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.

What it measures

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 Each compaction replaces raw history with a summary. The count is the honest measure of how much detail is already gone.
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.

How it works

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                │
└────────────────────────────────────────────────┘

Why the split exists

  • The conversation snapshot is a surface view. It carries messages and tool results — exactly what the client already subscribes to in order to render the conversation. Everything the pill shows about message counts, token usage and reasoning blocks comes from there, with no extra round trips.
  • Compaction is not a surface event. 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.
  • The context window is model knowledge, not conversation data. The Host's 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.

What each penalty represents

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.

Install

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 (reason package-moved) and needs a full app restart. A first-time install does not.

How the score is computed

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.

Tuning

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.

Known limitations

  • The degeneracy signal is language-specific. It counts occurrences of a calibrated pattern, and the default pattern is the Chinese token 好。. 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.
  • The score is a heuristic, not a measurement. It is useful for noticing a trend, not for grading a session.
  • 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.
  • No automated tests yet. computeMetrics is a pure function over plain data and is easy to test; that is a TODO, honestly listed rather than implied.

Compatibility

Developed and tested against DSH 0.2.2-rc.1 (profile desktop). It depends on:

  • the conversation.composer.dock slot
  • the contextPressure session projection (falls back to a 1,000,000 token window if absent)
  • chat.legacy.nodes with per-node usage.totalTokens and blocks

Credits

Code 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.

License

MIT. See LICENSE.


中文说明

对话耐久度面板,挂在 DSH 输入框下方。它把这条会话的「磨损」折成一个 0-100 的分数:

  • 上下文占用:用宿主 contextPressure 投影给的真实窗口大小,不是猜的
  • 压缩次数:compaction/* 是会话日志事件,客户端看不到,所以由 Host 侧折成投影再传下来,同时显示被压掉的 token 量
  • 退化指数:单条思考里的复读比例,默认只对中文「好。」校准,英文会话默认关闭
  • 历史长度:日志长了本身也是磨损

装上以后,已经打开的会话需要切换一次再切回来才能拿到新投影。

如果是用同一包名、换一个目录重装(例如先装了别的副本再换回来),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 指示器 标签胶囊和弹层的视觉与交互参照——照着宿主做,而不是自己造一套
—/ 5

No ratings yet

Verified DSH bundle

Commit 10f2223ab775

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout