Jaylor-Wang/dsh-tool-result-trimmer ↗★ 2
dsh-tool-result-trimmer
Eager, tail-heavy, line-aware tool result trimmer plugin for DeepSeek Harness (dsh) and Cordis.
Install
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add dsh-tool-result-trimmerREADME
Read the full README ↗Configuration
Add the plugin to your cordis.patch.yml or agent preset:
- name: dsh-tool-result-trimmer
config:
enabled: true
stripAnsi: true # Strip terminal ANSI escape codes (default: true)
thresholdChars: 10000 # Trigger trimming when output exceeds 10,000 chars
headChars: 1500 # Characters retained at the head
tailChars: 5000 # Characters retained at the tail
excludeTools: # Tools excluded from trimming
- read
- read_image
overrides: # Per-tool custom budgets and flags
bash:
thresholdChars: 15000
headChars: 2000
tailChars: 8000
git:
enabled: false # Completely disable trimming for git
semanticReducers: # Command-aware semantic reducers control
enabled: true # Enable semantic reduction (default: true)
git: true # Git status & diff refinement
packageManager: true # npm / pnpm / yarn / pip noise filtering
test: true # Clean test suite folding with strict Fail-Open
build: true # Recognized successful build progress
lint: true # Recognized successful formatter progress
structuredOutput:
mode: preserve # preserve (default), summary, or off
metrics:
enabled: false # Opt-in counts only; logs through the Cordis logger
spillover: # Controlled disk spillover for full output recovery
enabled: false # Offload raw outputs to disk on truncation (default: false)
directory: null # Storage dir (null defaults to os.tmpdir()/dsh-trimmed)
maxFileBytes: 20000000 # Max single file size (~20MB)
maxTotalBytes: 200000000 # Max total disk budget (~200MB)
maxFiles: 1000 # Max files to retain
ttlMs: 604800000 # Retention TTL (7 days)
onSemanticReduction: false # Also save semantic-only reductions and show a recovery path
Options
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Whether the trimmer is enabled. |
stripAnsi | boolean | true | Whether to strip terminal ANSI escape codes and styling (saves tokens). |
thresholdChars | number | 10000 | Global safety threshold (in characters). Recommended to exceed headChars + tailChars (default 6500). Outputs below threshold or within budget sum pass through with zero object allocations. |
headChars | number | 1500 | Global character budget for output head (keeps command invocation & starting context). |
tailChars | number | 5000 | Global character budget for output tail (keeps errors, stack traces, exit codes). |
excludeTools | string[] | ['read', 'read_image'] | Tool names excluded from trimming. |
overrides | Record | {} | Per-tool budget overrides and toggles. Supports custom thresholdChars, headChars, tailChars, stripAnsi, or enabled: false. |
semanticReducers | object | { enabled: true, ... } | Command-aware semantic reducers settings (enabled, git, packageManager, test, build, lint). |
spillover | object | { enabled: false, ... } | Controlled disk spillover settings (enabled, directory, maxFileBytes, maxTotalBytes, maxFiles, ttlMs, onSemanticReduction). |
structuredOutput.mode | preserve | summary | off | preserve | Protect complete JSON, opt into array summaries, or use legacy text trimming. |
metrics.enabled | boolean | false | Emit privacy-preserving per-result metrics; disabled by default. |