dsh-rtk-filter: Passing Oversized Command Output to RTK for the Model

Preface

When building agents in DeepSeek Harness (DSH), tool outputs go directly into the model context. Tools like bash and job_output sometimes return very long command outputs; if passed through as-is, they significantly increase token usage and context consumption, but they may also carry important status information such as exit codes, timeouts, and signals.

dsh-rtk-filter handles this by: when a tool result meets the conditions, it pipes the body to the external rtk CLI for compression, then presents the RTK output as the model-visible content. It does not rewrite the tool’s canonical value and preserves trailing status markers; if the external dependency is unavailable or fails, it silently falls back to the original output.

The community directory within the DSH plugin ecosystem is an independent site and is not an official app store operated by DeepSeek or our company.

What This Is

dsh-rtk-filter is a DSH plugin maintained by Aeternus123, licensed under the MIT License.

Its purpose is to process overly large command outputs through the external rtk CLI pipeline, then present the RTK-compressed text to the model instead of placing the raw large text block directly into the model context. It registers a tools/post-execute result transformer, replacing the model-visible content after tool dispatch but before lossless materialization.

It depends on the external rtk CLI. If rtk is missing, fails to execute, times out, is cancelled, produces no output, or produces unchanged output, the plugin preserves the original output.

Core Features

  • Only processes results that meet the criteria: accept decision, non-failed results, tool name in the configured list, plain text content, and byte size at or above minBytes.
  • Registers a tools/post-execute result transformer, replacing only the model-visible content without altering the tool’s canonical value.
  • Preserves trailing status markers, such as:
  • [exit code: N]
  • [killed by signal: ...]
  • [timed out after Nms]
  • [sandbox: ...]
  • [status: ...]
  • Silently degrades to the original output when rtk is missing, exits non-zero, times out, is cancelled, produces no output, or produces unchanged output.
  • Supports bare command names. If the configuration uses rtk, the plugin probes candidate directories, for example:
  • ~/.cargo/bin
  • /opt/homebrew/bin
  • /usr/local/bin
  • /opt/local/bin
  • ~/.local/bin
  • Supports rtk pipe mode and optional filters, for example -f cargo-test.

Installation and Enablement

Preparing rtk

First, confirm that rtk is installed locally. For example:

brew install rtk

If it is not installed, the plugin will silently degrade without causing command execution to fail.

GitHub Installation

Install using the DSH CLI:

dsh plugin --profile web add github:Aeternus123/dsh-rtk-filter

This command uses the web profile as an example. After installation, the bundled cordis.patch.yml takes effect automatically.

Local Mounting

For local development, you can also mount the plugin into the profile’s node_modules directory:

mkdir -p ~/.dsh/profiles/web/node_modules
ln -s /path/to/dsh-rtk-filter ~/.dsh/profiles/web/node_modules/dsh-rtk-filter

Then append the mounting configuration to the profile’s cordis.patch.yml.

Mounting Configuration

Here is a basic configuration example:

- insert:
  - id: rtk-filter
    name: dsh-rtk-filter
    config:
      command: /opt/homebrew/bin/rtk
      args: ['pipe']
      minBytes: 2048

This configuration does three things:

  1. Specifies the path to the rtk executable.
  2. Uses pipe mode, meaning raw text comes in via stdin and compressed text goes out via stdout.
  3. Sets minBytes: 2048; outputs below this byte size are passed through directly.

DSH’s bash tool uses a non-login shell, which may not inherit the PATH from your terminal. Therefore, it is recommended to use the absolute path for rtk, such as /opt/homebrew/bin/rtk. If you use the bare name rtk, the plugin will attempt to probe the candidate directories listed above.

Typical Usage

General pipe Mode

The most straightforward configuration is to use pipe:

- insert:
  - id: rtk-filter
    name: dsh-rtk-filter
    config:
      command: /opt/homebrew/bin/rtk
      args: ['pipe']
      minBytes: 2048

pipe mode corresponds to the usage pattern of “raw text in via stdin, compressed text out via stdout.”

Specifying a Filter

If you mainly handle a specific type of output, you can specify a filter for rtk pipe:

- insert:
  - id: rtk-filter
    name: dsh-rtk-filter
    config:
      command: /opt/homebrew/bin/rtk
      args: ['pipe', '-f', 'cargo-test']
      minBytes: 2048

Here, -f cargo-test is used, which is suitable for workflows that mainly process cargo test output.

Note: rtk pipe only compresses input when it matches the specified -f filter; non-matching input is passed through unchanged. When the plugin detects no output change, it does not append any additional hints either.

Applicable Scenarios and Notes

Scenarios suitable for dsh-rtk-filter:

  • Agents frequently execute commands like bash and job_output, and the output is often quite large.
  • You want to reduce model context consumption while preserving status markers such as exit codes, timeouts, and signals.
  • You already have the rtk CLI and want to uniformly manage output compression logic through a DSH plugin.

Things to note before use:

  • The plugin depends on the external rtk CLI. If rtk is unavailable or fails to execute, the plugin preserves the original output.
  • The plugin only changes model-visible content and does not alter the tool’s canonical value.
  • When rtk pipe is used with the -f filter, non-matching input is passed through unchanged.
  • The DSH bash tool may not inherit the terminal PATH, so it is recommended to configure the absolute path for rtk.
  • The plugin runs with the current DSH process permissions. You should review the source code and the MIT license before installation.
  • The runtime requires Node >=20.
  • Peer dependencies include:
  • @deepseek-ai/cordis ^4.0.0
  • @deepseek-ai/dsh-llm ^0.1.0-rc.6
  • @deepseek-ai/dsh-tools ^0.1.0-rc.6
  • @deepseek-ai/schemastery ^3.18.0

Links

  • GitHub: https://github.com/Aeternus123/dsh-rtk-filter
  • Directory page: This document does not provide a verified URL; you can search for the plugin name dsh-rtk-filter in the community directory.
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye