Introduction¶
When running long sessions in DeepSeek Harness (DSH), context compaction is a common path: the official compaction-basic replays the entire conversation prefix to call the summarization model, intending to reuse the provider’s warm prefix cache. DeepSeek’s prefix cache is bucketed by reasoning effort tier (reasoningEffort / output_config.effort) — a hit only happens with the same prefix and the same tier; when the tier changes, cache_read_input_tokens resets to zero and the whole context is re-billed at the uncached price.
The official compaction path reads only provider / model from the session request headers, dropping reasoningEffort; the missing tier is then filled in by the LLM layer with the adapter default value. As a result, when a session runs at a non-default tier such as max, every compaction may land in a different cache bucket, and the long prefix is repeatedly billed at full price. Below we introduce the community plugin dsh-compaction-effort-inherit: it inherits the session’s current reasoning effort tier onto the compaction request, with zero dependencies and no modification to the official plugin files.
What Is This¶
dsh-compaction-effort-inherit is maintained by rezon-aki and classified as a model-inference-related DSH plugin. It does exactly one thing: when DSH makes an LLM streaming call with purpose: 'compaction', it aligns the effort tier to the reasoningEffort used by “the last session request actually sent out”, so that the compaction summary and the main conversation land in the same DeepSeek prefix cache bucket.
The plugin writes no files, no settings, adds no tools, and has no client resources; uninstalling leaves nothing behind. It is licensed under MIT and distributed as a DSH bundle (cordis.patch.yml).
Where the Problem Comes From: The Tier Enters the Cache Key¶
The maintainer provides real measurements in the README hitting api.deepseek.com/anthropic directly (model deepseek-flash): for the same brand-new prefix, when only output_config.effort is changed, cacheRead becomes 0 after switching tiers (full miss); requesting again on the same tier yields a large amount of cacheRead (hit). Changing max_tokens does not affect hits (line 8 still hits). Conclusion: the effort tier enters the cache key; each tier keeps its own bucket and they do not interfere with each other.
On the real DSH compaction path (ctx.llm.stream + purpose: 'compaction'), with the session tier set to max, before installing the plugin the input is about 8030 with cacheRead 0 (MISS); after installing it, the same session gets cacheRead of about 7552 (HIT) on the same bucket. A high session can also read its corresponding bucket (about 7808 hit). After uninstalling, it is a MISS again. The third row shows that the tier comes from the session itself, rather than being hard-coded to some value.
Core Functionality¶
- Only intercepts compaction calls: listens on
llm/stream(global: true). Whenoptions.purpose !== 'compaction'it simply callsnext(), leaving the main conversation, sub-agents, and session titles unaffected. - Inherits the session tier: reads the tier from
ctx.sessions.get(sessionId)?.requestHeader?.()(consistent with the agent-loop resolution rules: when the request header carriesadapterDefaults.reasoningEffort: true, both sides ignore that field), and if a valid value is obtained, writes it intooptions.reasoningEffortin place. - Fail-open: the whole listener body is wrapped in try/catch; on exception it lets the call pass through, without blocking compaction.
- Doesn’t touch the official plugin: no patching, no wrapping, no changes to
compaction-basicconfiguration; the mount point is the same kind of seam asdsh-session-title,dsh-session-checkpoint-policy, anddsh-llm/invariant. - Zero dependencies, zero build: hand-written ESM, no runtime dependencies, no build step.
npm testin the repo covers 7 assertion cases (node –test).
Implementation highlights (excerpt from the README): cordis’s next does not accept arguments, so you must mutate options in place; returning next({ ...options }) silently does nothing. If compaction is configured with a different summarizationProvider/Model, the inherited tier may not be supported by the target model (cross-routing needs to be assessed on your own).
Installation and Activation¶
The plugin runs with the permissions of the current DSH process; before installing, it is recommended to review the source code and the MIT license on GitHub. Community directory page: skillhub.cn/plugins/rezon-aki/dsh-compaction-effort-inherit (independent site, with no official affiliation with DeepSeek / High-Flyer).
Method 1: DSH plugin panel — sidebar → “Plugins” → “Add Plugin”, fill in:
github:rezon-aki/dsh-compaction-effort-inherit
Method 2: Command line:
dsh plugin --profile web add github:rezon-aki/dsh-compaction-effort-inherit
After installing, restart the profile.
Uninstall:
dsh plugin --profile web remove dsh-compaction-effort-inherit
Compatibility (see package.json): DSH >=0.1.7-rc.2, profile web; the README states it has only been verified against DSH 0.1.7-rc.2 + profile web.
Typical Usage¶
No additional configuration options. After installing and restarting the profile, when a long session triggers context compaction it automatically carries over the current session’s reasoning effort tier, with no need to change the compaction policy or maxTokens.
The plugin’s core logic is equivalent to (excerpt from the README):
ctx.on('llm/stream', (options, next) => {
if (options.purpose !== 'compaction') return next()
try {
const effort = inheritEffort(options, ctx.sessions.get(options.sessionId)?.requestHeader?.())
if (effort !== undefined) options.reasoningEffort = effort
} catch { /* fail open */ }
return next()
}, { global: true })
Design details are in the repo’s docs/DESIGN.md; measured steps and where the numbers come from are in docs/ACCEPTANCE.md.
Use Cases and Caveats¶
Who it’s for: developers who use DeepSeek (via DSH), often set their sessions to a non-default reasoning effort tier (e.g. max), and rely on compaction-basic for context compaction. When the session’s explicit tier equals the adapter default tier (e.g. default high), compaction and the main conversation are already in the same bucket, so the observable benefit is smaller.
Boundaries (verbatim from the README):
- It does not change the compaction behavior itself: the summary range, the retention policy, and
maxTokensare all untouched. - It does not handle
session-title: the adapter forcesofffor it, and there is no reused prefix. - The tier may be ineffective when crossing summarization routes.
The DSH ecosystem’s philosophy is “everything is a plugin”; this plugin is a small patch for the gap between the official compaction path and DeepSeek’s bucketed cache. Stars and versions are based on GitHub (current package version 0.1.0).
Conclusion¶
Following the steps above, on the verified DSH version and web profile, installing dsh-compaction-effort-inherit lets compaction summary requests share the same reasoning effort tier as the session, avoiding the long prefix being treated as a new bucket and re-billed at full price on every compaction. Directory and source code:
- Directory page: https://www.skillhub.cn/plugins/rezon-aki/dsh-compaction-effort-inherit
- GitHub: https://github.com/rezon-aki/dsh-compaction-effort-inherit