Introduction¶
As DeepSeek Harness (DSH) conversations grow longer, the accumulated content in the context window becomes easier to lose control over. Tool outputs (especially error logs) and repeated intermediate results often occupy most of the token budget, while the truly important decisions and ongoing tasks become buried. Once compaction is triggered, these critical pieces of information may be condensed into vague summaries along with the noise.
dsh-context-maid is designed to address this issue. It takes over DSH’s context compaction and slimming workflow, separating “garbage cleanup” from “important content protection”. Before compaction, it archives content that is worth retaining, then performs content-aware slimming of tool outputs, and ensures that high-authority “pinned” facts are not accidentally removed.
Plugin Overview¶
- Name: dsh-context-maid
- Positioning: Automatic context curation plugin for DeepSeek Harness
- Core Value: Content-aware slimming of Tool outputs + invalid log cleanup + workflow/memory pinning protection + archive before compaction + configurable summarization model
- Maintainer: Icstick
- Category: Memory
- License: MIT License
Core Features¶
dsh-context-maid implements feature coverage by inheriting and registering DSH’s official services:
- Official compaction takeover: Inherits
BasicCompactionEngineand registers asctx.compaction. The officialpressure,overflow, andmanualtrigger paths are fully preserved, but the thresholds are user-controlled through mapping. - Compaction summarization enhancement: Before folding summaries, high-authority PIN (pinned) facts are injected into the summarization instructions. The summarization model is configurable (supporting cheaper models, local models, or smart routing); if not configured, it follows the conversation model.
- Tool output slimming: Inherits
ToolResultPrunerand registers asctx.toolResultPruner. WheneventSlimis enabled (on by default), each step performs incremental slimming on newly added over-budget tool results before the step (preserving the head and tail, keeping errors at the tail, and retaining JSON skeletons). - Garbage sweep: Uses a deterministic model to identify ineffective events such as repeated reads and retries after failures, then generates non-LLM stub nodes for cleanup. Disabled by default; must be enabled in configuration.
- Archive before compaction: Folding summaries are first archived through the ACP (Agent Composition Protocol) ledger and marked as ordinary observations, ensuring that important content does not disappear with compaction.
- Observability: The plugin provides audit logs, recording every compaction (fold), slimming (slim), and sweep operation. Use the
/context-maid statuscommand to view engine state, threshold configuration, PIN verification distribution, and folding depth.
Installation and Enablement¶
Add the plugin directly via CLI:
dsh plugin --profile <name> add github:Icstick/dsh-context-maid
After installation, the official default engine must be disabled in cordis.patch.yml; otherwise maid cannot properly take over the services.
Add the following configuration to the profile’s cordis.patch.yml:
- id: compaction-basic
disabled: true
- id: tool-result-pruner
disabled: true
- id: context-maid
name: dsh-context-maid
config:
auditDir: C:\path\to\context-maid
trigger.userRatio: 0.4
Note:
* In Windows environments, the DSH process must be stopped before running pnpm install; otherwise, native DLL locking issues may occur.
* If the status output shows BasicCompactionEngine, the official engine has not been disabled. Check the configuration in step 3.
Configuration¶
| Configuration Key | Default | Description |
|---|---|---|
trigger.userRatio |
0.4 | Context threshold (ratio of the model context window), mapped to the official thresholdRatio. |
trigger.eventSlim |
true | When enabled, incremental slimming is applied at step boundaries to newly added over-budget tool results. |
slim.thresholdChars |
4000 | Character-count threshold that triggers content-aware slimming. |
slim.headChars / slim.tailChars |
800 / 800 | Number of head/tail characters retained during slimming. |
sweep.enabled / sweep.aggressive |
false / false | Whether to enable garbage sweep (disabled by default). |
fold.retainRatio |
0.16 | Retained tail-segment ratio after compaction. |
fold.verify.enabled |
true | Whether to enable post-folding constraint verification (warn only by default; non-blocking). |
pin.enabled |
true | Whether to enable soft protection for PIN facts. |
archive.enabled |
true | Whether to enable archive before compaction. |
summarization.provider / summarization.model |
’’ / ‘’ | Custom summarization model (leave empty to use the conversation model). |
auditDir |
$DSH_HOME/context-maid |
Audit log directory. |
Usage Example¶
Enter /context-maid status in the conversation. You should see output such as:
engine: ctx.compaction = MaidCompactionEngine(maid 提供,阈值映射生效)
Notes¶
- Dependency conflicts: The official
compaction-basicandtool-result-prunerservices must be disabled. A DSH cordis service allows only one provider per key; disabling the official services is a prerequisite for maid to take over. - Validation logic: Post-folding constraint verification currently only compares literal anchors in the summary body and does not read the folded
session surface. This means it cannot detect cases where a constraint remains in the context but is not present in the summary. - Default behavior: Validation results only warn by default and do not block folding. Setting
fold.verify.enabledtofalsedisables validation and tracing, but does not change the folding behavior. - Version compatibility: Ensure you use a compatible DSH version (within the range required by peerDependencies).