DSH Hub

JohnXu22786/context-pruner

dsh-context-triage

BundleWorkflow0 GitHub stars· updated 2026-08-16

Session context triage plugin for DeepSeek Harness (dsh): prunes stale, repeated, failed and oversized context to save token budget.

Install

npx @deepseek-ai/dsh plugin --profile demo add github:JohnXu22786/context-pruner

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-context-triage DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/context-pruner.svg)](https://dshhub.dev/plugins/context-pruner)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from JohnXu22786/context-pruner, cleaned of badges and images.

简体中文

dsh-context-triage

A session context triage plugin for DeepSeek Harness (dsh) that automatically manages context volume during long sessions: it identifies and handles stale, duplicate, failed, oversized, and low-value message content to save token budget and curb context bloat.

Features

  • Deterministic, zero model dependency: all verdicts and rewrites are produced by heuristic rules—no LLM calls, no extra services; behavior is predictable and testable offline.
  • Five Screeners, each independently switchable:
    ScreenerVerdict ruleHandling action
    Stale output staleOutputTool call pairs more than N turns after the latest user message, with results still completeCall block rewritten to an archive summary, result block removed
    Repeated call repeatedCallCall pairs with the same tool and same arguments (JSON key order irrelevant)Only the most recent is kept; older call pairs are cut
    Failed call failedCallStale error results (isError)Input arguments replaced with a failure stub (prevents leakage / saves space), error text kept and trimmed
    Oversized block oversizedBlockTool result text exceeds the character capHead/tail trimmed, middle annotated with the omitted amount
    Stale reasoning staleReasoningReasoning blocks beyond the retention turns; kept blocks exceeding the length capRemoved; or trimmed (within the reserve region only trim, never delete)
  • Reserve area (reserve): content within the most recent N user turns is never touched, avoiding disruption of context the model is currently using.
  • Exemption list (exempt): two-dimensional tool-name and file-path glob exemption (protects stateful tools like task/skill/todowrite/todoread/write/edit/batch by default).
  • "Worth it" check: any archive/stub action requires the rewrite to be strictly smaller than the original, ruling out changes that cost more; call-pair-level actions (archive = rewrite + cut) take effect or are abandoned as atomic groups.
  • Audit report: every triage outputs structured statistics—counts and savings per reason, per-item details, and suggested compression ranges; visible through the tool, the command, and the CLI.
  • Native integration with the dsh compression seam: implements ctx.compaction (CompactionEngine); auto-pressure, context overflow, manual, and forced region compression all go through the official harness mechanism. Replacement summary messages use a checkpoint source recognized by any backend-agnostic consumer.

Installation and mounting

The plugin is distributed as a bundle: dsh.bundle.patch in package.json points to cordis.patch.yml (the patch inserts the plugin line; config can be overridden on the line).

Installing in DSH

dsh plugin --profile demo add github:JohnXu22786/context-pruner

Option 1 (mount from a local directory, recommended):

dsh plugin --profile web add link:/absolute/path/context-pruner

Option 2 (manual patch): merge the entry in cordis.patch.yml into the profile's cordis.patch.yml, or launch it directly as an overlay:

dsh web --patch ./cordis.patch.yml

Option 3 (git source):

dsh plugin --profile web add "github:your-repo/context-pruner#main"

Related plugins