When using DeepSeek Harness (DSH) for long-context model inference, generic compaction often fails to meet specific needs. Manually trimming conversations is cumbersome and error-prone. The ya8d/dsh-directive-compact plugin provides a natural-language-based compaction solution that lets you precisely control what is kept and what is trimmed in the context via directives. It can even help repair incorrectly configured context in some cases.
What Is the Plugin?¶
This is a custom natural-language compaction plugin maintained by ya8D. It does not modify the upstream ctx.compaction and is a purely additive plugin. Its core value is enabling developers to precisely trim context using natural-language directives (such as “keep error logs and compress the middle process”) and even fix context configuration errors.
Core Features¶
The plugin provides two core commands that execute different compaction logic through natural-language directives.
1. /compact-directive: Compact the Middle Section¶
This command compacts the middle part of the conversation. It preserves the head (the first 3 user turns + the fixed skeleton) and the most recent turns, and compresses only the middle content.
2. /trim-directive: Trim the Entire Conversation¶
This command trims the entire conversation. It has no region protection and can theoretically remove the head, the injected skeleton, and any other content, enabling more aggressive compaction.
3. Directive Support¶
It supports performing the following operations through natural language:
* delete: Delete a node
* delete-text: Delete a text fragment
* rewrite: Rewrite a node
* summarize: Replace with a summary
4. Purely Additive Implementation¶
The plugin is purely additive and does not affect the upstream ctx.compaction. The original conversation remains in the UI, while only the context visible to the model is compacted.
Installation and Enablement¶
Install the plugin via the DSH CLI. The <name> in the installation command must be specified by the user (for example, web or headless).
dsh plugin --profile <name> add @ya8d/dsh-directive-compact@rc
Typical Usage¶
Invoke commands with natural-language directives during the conversation.
Compact the Middle Section:
/compact-directive keep the login-related errors, compress the rest of the middle process
Trim the Entire Conversation:
/trim-directive delete all git-operation records, keep the user's original instructions and the plugin-development goal
Applicable Scenarios and Notes¶
Destructive Operations¶
The operations are destructive and permanently remove content. It is recommended to fork the session before running them. If there is nothing to delete, <<NO_CHANGE>> is returned. This is a normal result, not an error.
Parameter Limitation¶
The directive argument for /compact-directive must not be empty; otherwise, an error is reported.
Performance Notes¶
/trim-directive may take a relatively long time (several minutes), because the model needs to reason about how to trim according to the directive. If the conversation is large (for example, 180K+ tokens), processing may take up to 5–10 minutes.
Environment Dependency¶
The plugin requires Node.js version ^22.19.0 || >=24.0.0.
This plugin is a model inference tool in the DSH ecosystem and is maintained by the community. For more details, refer to the GitHub repository or the community catalog.