Foreword¶
In DSH, running long sessions—multi-turn tasks, repeatedly editing files, repeatedly running tests—context windows will eventually be filled by historical messages. The typical manifestation is that the model starts forgetting early constraints or triggers context alerts. Relying on manual compression is unrealistic, and relying on the model to “forget” itself is uncontrollable.
dsh-Context-Drawer turns this into a reliable utility: only when the context reaches a threshold, it first archives earlier messages to a folder on disk associated with the current session, and only after successful persistence does it release the oldest finished turns from the model’s visible context. The original chat history and session append logs remain untouched throughout.
Below is an introduction to its positioning, behavior, configuration, and installation.
What is this¶
dsh-Context-Drawer is a DeepSeek Harness (DSH) plugin maintained by yue7ye, version 0.1.0, MIT License. It does one thing: when the dialogue context reaches a threshold (default 50% of the model window), it appends earlier messages to a folder “associated with that session”, and then removes the oldest finished turns from the model’s visible context. It has no interface, no buttons, no memory writing, no prompt injection, and does not modify chat history or append-only session logs.
In the community plugin directory, it is categorized under “Memory”. But functionally, it is more like a context management plugin: the only thing truly adjusted is the “context visible to the model”; disk archives and session logs remain intact.
DSH’s philosophy is “Everything is a plugin”, maintained by third parties. The directory page mentioned in this article is an independent community site with no official affiliation to DeepSeek / Huafang, and is not an official app store.
Core Functionality¶
The plugin estimates context usage at the first step of every dialogue round: it prioritizes the actual usage returned by the provider, otherwise it uses character estimation. When usage reaches the model window’s thresholdRatio (default 0.5), archiving and releasing is executed.
- Append new messages “after the last archive watermark” to
{archiveDir}/{sessionShort}/{date}.md, first usingfsyncto ensure persistence; - Only after the file is safely written to disk, remove the oldest finished turns from the model’s visible context via the surface layer’s
replaceevent.
There are three constraints for release:
- The last
keepRecentTurnsturns (default 6) are always kept; - At most
releaseMaxTurnsturns can be released at once (default 40); - Release stops when approaching
releaseTargetRatio(default 0.45).
Archives are plain text Markdown, can be opened anytime. Session logs and chat history remain intact: the released parts are just invisible to the model; the archives on disk always have them.
Status is written to ~/.dsh/context-drawer/state/state.json, one watermark record per session, used to prevent duplicate archiving.
Default archive path:
~/context-archives/{sessionShort}/{YYYY-MM-DD}.md
sessionShort is the first 8 characters of the session ID after removing the session- prefix. One session has one subfolder, so it is easy to distinguish which file belongs to which conversation at any time.
Installation and Enablement¶
Officially there are two ways. One is to search dsh-Context-Drawer in the DSH plugin market and install; the other is using the command:
dsh plugin --profile <profile> add dsh-context-drawer
<profile> in the command needs to be replaced with the actual profile name used. The plugin requires DSH version not lower than 0.2.0-rc.2 (see engines field), you can confirm the current environment version before installing.
After enabling, the plugin is injected via bundle patch, configuration is written in cordis.patch.yml:
- insert:
- id: context-drawer
name: dsh-context-drawer
config:
archiveDir: C:/deepseek/context-archives # optional; default ~/context-archives
thresholdRatio: 0.5
archiveDir is an optional field, if not filled, the default ~/context-archives is used; thresholdRatio controls the occupancy ratio triggering archiving.
Configurable Items¶
Besides archiveDir and thresholdRatio, cordis.patch.yml also supports the following optional fields:
thresholdTokens: Absolute token threshold, triggers based on token count when configured;modelWindow: Model window size, default1048576;charsPerToken,baselineTokens: Character estimation parameters;keepRecentTurns: The number of recent turns to always keep, default6;releaseMaxTurns: Maximum number of turns released at once, default40;releaseTargetRatio: Release target ratio, default0.45;format: Archive format, optionalmd,jsonl,txt;includeRoles: Roles included during archiving;minTextLength,maxEntryChars: Text length filtering;timeZone: Timestamp timezone, defaultAsia/Shanghai;stateDir: State directory.
The plugin has no standalone documentation; field meanings are subject to the source code.
Typical Usage¶
The repository comes with an offline test script that can be used to reproduce the archiving and releasing process. Enter the plugin directory and execute:
node test.mjs
The test case described in the README is: an offline mock session containing 10 finished turns -> triggers threshold -> archives 20 messages and releases 8 turns -> the second trigger only appends new messages -> does nothing on non-first steps and low usage.
Applicable Scenarios and Notes¶
Suitable for DSH users who need to work continuously in long sessions while wanting to preserve complete session history: archiving happens on disk, the original chat history is not affected, and archives can be opened on demand later.
Notes:
- The plugin runs with the current DSH process permissions, has the ability to read/write the archive directory and modify the model’s visible context. You should check the source code and license (MIT) before enabling;
- It only releases “finished” turns; turns currently in progress will not be archived;
- The trigger condition is the threshold; the actual amount released is jointly constrained by
keepRecentTurns,releaseMaxTurns, andreleaseTargetRatio; - Requires DSH version
>= 0.2.0-rc.2.
Closing¶
The value of dsh-Context-Drawer lies in turning “what to do when context is full” into a definite persistence and release, rather than letting the model gradually lose early information in long sessions. Directory page: https://www.skillhub.cn/plugins/yue7ye/dsh-Context-Drawer; Source code: https://github.com/yue7ye/dsh-Context-Drawer.