dsh-shake
No description
- Stars
- 0
- Language
- TypeScript
- Created
- Oct 5, 2026
- Updated
- Oct 10, 2026
Introduction
dsh-shake
A plugin for manually reducing context usage in DeepSeek Harness (DSH). It replaces old tool output and large code and XML blocks in assistant replies with short placeholders. When needed, the model can retrieve the original text through shake_read.
Third-party plugin notice: dsh-shake is an independently maintained third-party plugin for DeepSeek Harness (DSH), not an official DeepSeek product. References to DeepSeek Harness indicate compatibility only and do not imply recognition, sponsorship, or endorsement by DeepSeek.
No model-generated summaries. No deletion of original logs. /shake only schedules cleanup; the actual replacements happen before the model request in the next normal conversation turn.
Installation · Usage · Cleanup Scope · Configuration · Reading the Original Text · Limitations and Recovery
Installation
Requirements
| Component | Declared support range | Verified baseline |
|---|---|---|
DeepSeek Harness (@deepseek-ai/dsh and the corresponding @deepseek-ai/dsh-* host services) | 0.2.0-rc.2 | 0.2.0-rc.2 |
The Cordis fork used by DSH (@deepseek-ai/cordis) | ~4.0.4 (>=4.0.4 <4.1.0) | 4.0.4 |
The supported host service versions are defined by peerDependencies in package.json. Cordis refers to @deepseek-ai/cordis, not the unscoped cordis package. Compatibility outside the ranges above is not guaranteed.
- Node.js:
^22.19.0 || >=24.0.0. - Environment: An initialized DSH Web profile.
Install dsh-shake@latest from npm.
Install into a Web Profile
Check the DSH version, then install dsh-shake@latest from npm:
dsh --version
dsh plugin --profile web add dsh-shake@latest --ignore-scripts
dsh --profile web --dump-config
Confirm that the configuration output includes dsh-shake. If DSH is already running, stop it first, then start Web:
dsh web
Installing the prebuilt package does not require linking source code or running build scripts. The default configuration is ready to use.
Usage
-
Wait until the current session is idle, then send the following in the Web message input:
/shake -
Once you receive the confirmation “Scheduled; will run before the next model request,” the cleanup request has been saved. This does not call the model or immediately reduce the context.
-
Send your next normal message. The plugin replaces eligible older text before DSH sends the model request.
If execution has not started, you can cancel:
/shake cancel
Cancellation applies only to pending requests. It cannot undo completed replacements.
| Situation | Meaning and action |
|---|---|
| “No cleanup needed” message | There is currently no eligible text that would save tokens. No further action is needed. |
| The session is busy or under maintenance | Wait until the session is idle and retry. The command neither interrupts existing work nor queues itself. |
| A request is already pending | Each session can have at most one pending request. Repeating /shake does not reselect content. Cancel first if you want to schedule a new selection. |
| Attachments or other arguments are included | Only /shake and /shake cancel are supported; neither accepts attachments. |
Cleanup Scope
By default, the plugin counts backward from the newest history and protects approximately the most recent 4,000 tokens. Any message that crosses this boundary is also kept in full. Only earlier history is searched for the following content:
| Content | Default eligibility criteria |
|---|---|
| Successful tool results | The combined text within a single result must contain at least 1,000 tokens. Only text is replaced; non-text content such as images and the original metadata are preserved. |
| Plain-text assistant replies | A single complete fenced code block or XML block must contain at least 400 tokens. Text outside the block and its order are preserved. |
Placeholders also have a cost, so content is skipped if replacing it would not produce a net saving. Eligibility is checked again during execution; fragments that have already been replaced by another operation or are no longer suitable for cleanup are also skipped.
The following content is never cleaned up:
- User, system, and developer messages.
- Error tool results,
shake_readresults, and this plugin's control records, history excerpts, and content carrying those origins. - Assistant messages containing images, thinking, tool calls, or other non-text blocks—the entire message is skipped.
- Ordinary long paragraphs in assistant replies, tool call arguments, and unclosed code fences or XML structures.
Note: Skill and plan text returned by ordinary read tools receives no extra protection and may still be cleaned up as tool results. The mandatory protections above cannot be disabled through configuration.
Configuration
Keep the defaults unless you need to change them. To adjust settings, add a configuration override to the target profile's cordis.patch.yml. Do not insert a second plugin instance.
The default configuration is shown below:
- id: dsh-shake
config:
protectedTokens: 4000
toolTextMinTokens: 1000
assistantBlockMinTokens: 400
readDefaultLimit: 2048
readMaxLimit: 4096
| Parameter | Default | Purpose |
|---|---|---|
protectedTokens | 4000 | The amount of recent history to protect, counted using locally estimated tokens, with whole messages preserved. |
toolTextMinTokens | 1000 | A tool result is considered for cleanup only when its total text reaches this threshold. |
assistantBlockMinTokens | 400 | An individual code or XML block in an assistant reply is considered for cleanup only when it reaches this threshold. |
readDefaultLimit | 2048 | The page size for shake_read when limit is omitted, measured in Unicode code points. |
readMaxLimit | 4096 | The maximum page size allowed by shake_read, in the same units. |
The first three values must be non-negative safe integers. Pagination settings must be integers satisfying 1 ≤ readDefaultLimit ≤ readMaxLimit ≤ 4096. No other configuration fields are accepted.
Restart DSH after making changes. Requests that have already been scheduled retain the configuration and candidate fragments saved when they were scheduled.
Reading the Original Text
Replaced text leaves a placeholder containing a ref. The model can call the shake_read tool to retrieve that fragment; it is not a slash command for users to enter.
Example arguments (replace the sample ref value with the full reference from the placeholder):
{
"ref": "<copy the full ref from the placeholder>",
"offset": 0,
"limit": 2048
}
The response contains the current page's text, the current offset, the fragment's totalLength, the next page's nextOffset, and the completion flag done.
- For the next page, use the same
refand setoffsetto the previously returnednextOffset. done: trueandnextOffset: nullindicate that reading is complete.- Offsets and lengths are counted in Unicode code points, not bytes or the UTF-16 length of a JavaScript string.
offsetmust be a non-negative safe integer and cannot exceed the fragment's total length. An empty page is allowed when the offset is exactly at the end.limitmust be a positive integer no greater than the configuredreadMaxLimit.
A reference is a locator, not permission to read. The tool verifies the original text, actual replacement records, and checksums in the current session. Only fragments that were actually removed can be read. File paths and other session IDs are not accepted.
Limitations and Recovery
Before You Use It
- This is not
/compact. It is manual text cleanup, not model-generated summarization. It does not provide the automatic, images, or thinking modes, or artifact files, of OMP's full shake implementation. - This is not secure erasure. The original text remains in the raw session log. Log files do not shrink, and old output is not guaranteed to disappear from the interface.
- Assistant message roles change. Cleaned-up assistant replies are written as history excerpts with provenance markers under
user/message. Unselected text is preserved, but the original assistant-role semantics are not. - Savings are local estimates. They do not represent provider billing or a guaranteed reduction ratio. Reading original text brings it back into context, and history changes may trigger a KV cache rebuild. No cache benefit is guaranteed.
What Happens After Restarts, Forks, or Interruptions?
| Situation | Behavior |
|---|---|
| Restarting DSH or reopening a session | Pending requests are recovered from the log and wait for the next normal input before executing. No model call is made automatically. |
| Forking a session | Pending requests inherited from the parent session are not executed automatically. Reading is limited to the original text and replacement evidence inherited by the child session itself; parent and sibling sessions are not queried. |
| Cancellation or failure during execution | Committed replacements remain; there is no automatic rollback. Recovery determines progress from the actual log and does not silently send model requests. Cleanup that has been recorded as failed is not retried automatically. |
| Session persistence cannot be confirmed | The command does not report success, and execution does not allow subsequent model requests to proceed. Check the host's save capability and logs. |
Uninstalling
Stop DSH first, then remove the plugin:
dsh plugin --profile web remove dsh-shake
If you added a custom configuration override, remove it as well, then restart:
dsh web
Uninstalling does not undo completed replacements or delete the original text. DSH can still open the session, but shake_read is no longer available. Pending requests remain and can be recovered when the plugin is loaded again.
Implementation and persistence details
- The package loads a single Host plugin through
dsh.bundle.patch. The plugin manager adds the bundle to the profile'sdsh.profile.bundles; the bundled patch explicitly suppliesconfig: {}to enable defaults. The pinned host rejects plugin configurations that omitconfigentirely. - Tool results are replaced through the host's surface replacement mechanism. Identity, error, and provenance metadata, along with non-text blocks such as opaque/offload blocks, remain unchanged. The plugin does not delete images or reasoning blocks or reduce their cost.
- Schema-v1 state stores only references, ranges, checksums, and frozen policies, without copying the original text. References use the format
shake:1:<operationId>:<requestSeq>:<regionIndex>. Persisted ranges use half-open UTF-16 indices and UTF-16LE SHA-256 checksums; they cannot be used as pagination offsets forshake_read. - Only events known to the host are appended. Later compaction does not automatically erase the evidence needed to read original text from the raw log. State records, provenance checks, and reads incur additional logging or query costs.
- To conservatively confirm persistence, every subsequent natural step runs
flushfirst while the latest result in the same session remainscompleted. This is not a one-time retry. - Unloading first removes command, tool, and listener entry points, then waits for operations already in progress to finish. Unconfirmed persistence receives only one bounded attempt; failures are reported through the host logger. A successful Cordis
disposereturn does not mean saving succeeded, nor does it imply a hardware-level fsync guarantee.
License
MIT. See THIRD_PARTY_LICENSES for attribution of the adapted OMP scanner, the pinned upstream commit, and the full license notices.