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.

Package
dsh-tool-result-trimmer
Compatibility
Unverified
Harness peer range
*
Cordis peer range
>=4.0.0
Version
2.0.0
License
MIT
Last updated
Oct 31, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add dsh-tool-result-trimmer

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

FieldTypeDefaultDescription
enabledbooleantrueWhether the trimmer is enabled.
stripAnsibooleantrueWhether to strip terminal ANSI escape codes and styling (saves tokens).
thresholdCharsnumber10000Global safety threshold (in characters). Recommended to exceed headChars + tailChars (default 6500). Outputs below threshold or within budget sum pass through with zero object allocations.
headCharsnumber1500Global character budget for output head (keeps command invocation & starting context).
tailCharsnumber5000Global character budget for output tail (keeps errors, stack traces, exit codes).
excludeToolsstring[]['read', 'read_image']Tool names excluded from trimming.
overridesRecord{}Per-tool budget overrides and toggles. Supports custom thresholdChars, headChars, tailChars, stripAnsi, or enabled: false.
semanticReducersobject{ enabled: true, ... }Command-aware semantic reducers settings (enabled, git, packageManager, test, build, lint).
spilloverobject{ enabled: false, ... }Controlled disk spillover settings (enabled, directory, maxFileBytes, maxTotalBytes, maxFiles, ttlMs, onSemanticReduction).
structuredOutput.modepreserve | summary | offpreserveProtect complete JSON, opt into array summaries, or use legacy text trimming.
metrics.enabledbooleanfalseEmit privacy-preserving per-result metrics; disabled by default.