Introduction¶
In the plugin-based architecture of DeepSeek Harness (DSH), when a tool (such as web scraping) returns an overly large result, it can directly consume the conversation context window and cause task interruption. dsh-result-cap, as a model inference plugin, solves the problem of length control for a single tool result. It does not manage the overall context window; instead, it performs deterministic truncation on an individual tool response.
What is dsh-result-cap¶
This is a plugin maintained by jwilson411. Its core behavior is applying a deterministic UTF-8 byte limit to tool results. It retains the first N bytes of the result and returns the SHA256 hash of the complete original content, ensuring that truncated results can be identified as incomplete.
Core Features¶
This plugin provides the following capabilities:
- Deterministic truncation: truncates the result by UTF-8 bytes, retaining the first N bytes.
- Explicit marking: returns a
truncatedboolean flag andomitted_bytes(the number of discarded bytes). - Full-content hash: returns the SHA256 hash of the complete original content, rather than the hash of the truncated content.
- Configuration and precedence: supports configuring
maxBytes(default 8192), and can be set via the environment variableDSH_RESULT_CAP_MAX_BYTES. Configuration precedence is: config file > environment variable > default value. - Direct invocation: supports using the
capResultfunction directly for unit testing. - Type limitation: the current version only limits string types (
textfield) and does not handle Buffers or images.
Installation and Enablement¶
Installing the plugin requires the @deepseek-ai/dsh-tools dependency.
- Install:
dsh plugin --profile default add github:jwilson411/dsh-result-cap
- Configure:
- id: result-cap
config:
maxBytes: 32000
Typical Usage¶
You can directly use the capResult function for testing in code:
import { capResult } from 'dsh-result-cap'
capResult('short enough', 8192)
// → 'short enough' (未截断)
capResult('x'.repeat(20000), 8192)
// → { text: 'xxxx…', truncated: true, omitted_bytes: 11808, sha256: '…' }
Use Cases and Notes¶
- Use case: when tool-returned content far exceeds the context window, it acts as a last line of defense, retaining only the beginning of the content and marking it as truncated, preventing the entire task from being interrupted due to a single oversized result.
- Notes:
- It is not Headroom, a compression model, semantic compression, or a summarizer; it is only simple byte slicing.
- The current version v1 only supports string types and does not support Buffers or images.
- When configuring, an
id-targeted patchreplaces the entireconfigblock and cannot be merged. - It does not truncate silently; it must return the
truncated: trueflag. - The configuration parameter must be an integer and at least 1. Invalid values (such as floating point numbers, negative numbers, boolean values, or unknown keys) are rejected, throwing
InvalidResultCapConfigError(codeRESULT_CAP_CONFIG).
Conclusion¶
dsh-result-cap provides a controllable byte-truncation capability that, combined with a SHA256 hash, solves the problem of tool results overflowing the context. For more details, see the GitHub repository or the Skill Center catalog.