dsh-cache-stabilizer: Stabilize DeepSeek Harness cache prefix

Introduction

In DSH or agent development, if the system prompt prefix changes for every request due to variable content such as the working directory, the provider-side prompt cache based on prefix matching may not be easily reused. dsh-cache-stabilizer is an MIT-licensed plugin for DeepSeek Harness, maintained by dongsheng123132. It performs two main tasks: first, relocating the working directory from known default persona sentences in DSH to the runtime-context snapshot; and second, normalizing the order of object-keys within tool schemas. The plugin also provides a /cache command to report cache read tokens, uncached input tokens, and cache write tokens returned by the provider.

What is this

dsh-cache-stabilizer is designed for cache-prefix stabilization and evidence-based cache metrics. It does not implement a second cache layer, does not proxy model responses, does not freeze the tool catalog, and does not reuse stale context. It only performs semantic-preserving prefix stabilization during the current DSH request construction phase and displays cache evidence through provider metrics.

This plugin requires Node.js >=22.

Core Features

Relocating cwd from Default Persona Sentences

The plugin relocates the working directory from known exact sentences in the DSH standard/headless coding persona out of the system prompt prefix and places it into the runtime-context snapshot. This allows different projects to share the same system-prompt prefix, while each request still receives the correct cwd.

There is a clear boundary here: only exact sentences used by the DSH standard or headless coding persona will be migrated. If a custom persona mentions {{cwd}} in another form, the plugin will not modify it, as blindly moving arbitrary natural language could alter its meaning.

Normalizing Tool Schema Key Order

The plugin normalizes the order of object-keys inside tool schemas. This change serves prefix stability but does not change the tool set itself.

Adding the /cache Command

The plugin adds the /cache command. This is a human-only command used to report provider’s persistent metrics:

  • cacheReadTokens
  • inputTokens (uncached)
  • cacheWriteTokens

/cache does not fabricate a cache hit out of thin air. DeepSeek provider caching is automatic and relies on precise prefix matching starting from token zero; cache storage and eviction remain controlled by the provider.

Installation and Usage

Install under the web profile:

dsh plugin --profile web add dsh-cache-stabilizer

If using a custom profile, replace web with the corresponding profile name.

Typical Usage

  1. Install the plugin:
dsh plugin --profile web add dsh-cache-stabilizer
  1. Restart DSH, send a few messages, then enter in a command-supporting client:
/cache

If you need to disable an optimization in a specific profile, use a profile patch configuration:

- id: dsh-cache-stabilizer
  config:
    relocateCwd: false
    canonicalizeTools: false

Applicable Scenarios and Notes

Suitable for developers using the DSH standard/headless coding persona, who wish to reduce the impact of variable content on system prompt prefixes, and want to view provider cache evidence.

Note the following before use:

  • The plugin runs with the current DSH process permissions; check the source code and license before installing.
  • This plugin does not create a new cache layer, nor does it change the provider’s cache storage and eviction strategy.
  • If the custom persona’s {{cwd}} is not in the exact form of known default sentences in DSH, the plugin will not automatically migrate it.
  • /cache only reports metrics given by the provider and does not infer or generate non-existent cache hits.

Development and Verification

The repository provides development commands:

npm test
npm run check

Links

GitHub:

https://github.com/dongsheng123132/dsh-cache-stabilizer

Community directory page (provided by the community, not confirmed by README/package.json):

https://www.skillhub.cn/plugins/dongsheng123132/dsh-cache-stabilizer

The community directory is an independent site and is not an official app store for DeepSeek or Huanfang.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye