Introduction¶
DeepSeek Harness (DSH) uses compaction-basic for context compaction by default. If you wish to use a specified model (especially a low-cost or free small model) to compress conversations to save on Token costs, or to handle scenarios where a short context window cannot accommodate the full conversation, dsh-quilt-compact is a viable alternative. It takes over the default ctx.compaction backend.
What is it¶
A plugin maintained by bvbhu, licensed under MIT. Its core logic performs “chunked summarization and merging” compression on conversations using a specified model pool, ultimately producing a small yet comprehensive checkpoint.
Workflow¶
The compaction process follows this order:
- Stage 0 Preprocessing: Preprocesses the area to be compacted, including merging adjacent duplicate lines, condensing consecutive blank lines, stripping terminal noise (ANSI escapes, cursor marks, etc.), and preserving file/image attachment names; optional code skeletonization and log condensation.
- Model Selection & Chunking: Selects an available model for each round and splits the context according to that model’s capacity. Each chunk is assigned a summary length limit to ensure the final merge does not exceed restrictions.
- Summarization: Each chunk is summarized into a small digest via a call to the model pool.
- Merging: All digests are integrated into the final checkpoint in a single call.
- Checkpoint: The final digest replaces the original area and is written to the session.
Installation & Activation¶
Install directly from the GitHub repository:
dsh plugin --profile <name> add github:bvbhu/dsh-quilt-compact
The installation command automatically activates the bundled layer and disables compaction-basic (making this plugin the ctx.compaction). It is recommended to pin the commit using a #<sha> suffix to avoid the bare repository following the default branch:
dsh plugin --profile <name> add github:bvbhu/dsh-quilt-compact#<sha>
Configuration¶
Configuration is done via the settings page in the Web UI or by directly editing the profile’s cordis.patch.yml.
Model Pool¶
Configure multi-tier models for automatic selection and fallback based on capacity.
- id: dsh-quilt-compact
config:
tiers:
- name: primary
models:
- provider: openrouter
model: openrouter/free
maxConcurrent: 1
cooldownHours: 1
cooldownHours: Hours to cooldown after a failure (positive number, default 1 hour).maxConcurrent: Defaults to 1.
Merge Window¶
Controls the maximum context (token count) to retain before merging; default is 128k.
mergeMaxContextTokens: 64000 # Max context to retain before merge (merge window), default 128000
Chunking¶
Controls chunk ratio and overlap ratio.
chunkRatio: 0.8 # Proportion of model available input used for chunks
chunkOverlapRatio: 0.1 # Proportion of chunk budget for overlap between adjacent chunks
Preprocessing¶
Enable Stage 0 preprocessing options.
preprocessing:
dedup: true # Merge adjacent duplicate lines
purgeErrors: true # Strip terminal noise
astSkeleton: { enabled: false, maxDepth: 2 } # Code skeletonization (requires explicit enabling)
logCondense: { mode: balanced, maxLines: 200 } # Condense overly long logs
Run Records¶
Optional quality assessment/diagnostic records; disabled by default.
runRecord:
enabled: false # No run records produced when disabled
maxEntries: 200 # Max entries to retain in the file
snapshotChars: 0 # >0 embeds a truncated copy of original conversation text per entry (default 0 = no text stored)
path: '' # Fixed file location; empty uses DSH storage root directory
When enabled, each compaction appends a JSON line to <DSH home>/storages/dsh_quilt_compact_runs.jsonl.
* ref: Points to the compacted interval in the session event log.
* chunks: Model attribution info for each chunk.
* cooldowns: Error details for each cooldown entry.
* snapshotChars: Must be explicitly set to a positive number to embed a truncated copy of the original conversation text.
Scenarios & Notes¶
- Version Dependency: Requires DSH version
>=0.1.7-alpha.2 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0. - Privacy: By default, original conversation text is not saved; only references are logged. Even when
runRecordis enabled, text is not saved by default unlesssnapshotChars > 0is set. - Fallback Mechanism: If the model pool fails or there are no sufficient models during merging, the session model will perform a fallback compaction.