Introduction¶
When developing agents with DeepSeek Harness (DSH), you frequently encounter situations where the model’s response is truncated at max-tokens, or the upstream raises an error after visible text has already been produced, causing the conversation to break. Downstream agent loops expect a clean “completed” end state, and any change to that contract would ripple through existing logic.
dsh-continuation exists to solve this layer of truncation. It hooks into the llm/stream layer and, upon detecting truncation or an error, automatically issues a new continuation request. The newly generated fragments are appended to the same stream, so downstream consumers still see a single finish event — no changes to consumption logic required.
Plugin Scope¶
dsh-continuation is a DSH plugin maintained by lanmeigezi. It addresses the problem of “how to smoothly complete a long response that was truncated on the model side.” The plugin operates at the llm/stream layer, generating continuation content by replaying partial conversation context with reasoning disabled.
Core Features¶
The plugin handles only specific truncation scenarios:
- The original stream ends with a
max-tokensstatus or an error (and no tool call was triggered, and the stream was not interrupted). - Upon detecting the above state, it builds a new continuation request: on top of the historical messages, it appends a user turn carrying roughly the last 1500 characters as a “continue from here” anchor, and sets
reasoningEfforttooff. - It streams back the continuation content, remaps the deltas to the original stream’s index, and merges them so the agent loop perceives a single, longer response.
- A maximum of 3 continuation rounds are supported, each of which must add at least 20 characters; otherwise the original end state is preserved.
- If an upstream error occurs mid-continuation, or a tool call appears in the continuation fragment, the continuation content is discarded and the original response and end state are retained.
- A kill switch is provided via the environment variable
DSH_CONTINUATION_DISABLED=1; when set to 1, the plugin passes everything through unchanged.
Installation & Activation¶
The install command requires an absolute path:
dsh plugin --profile web add "<absolute path to this repo>"
After installation, dsh must be restarted once, because the bundle list does not support hot-reloading. The plugin includes a bundle patch that will be automatically mounted into DSH.
Typical Usage¶
The plugin is stateless and takes effect automatically once installed. No additional configuration file is needed, as the relevant parameters (e.g., max rounds, minimum growth characters, anchor length) are currently constants hardcoded in the source. To disable continuation, set the environment variable before launching dsh:
DSH_CONTINUATION_DISABLED=1
The plugin ships with a self-test script that verifies eight scenarios locally:
node test/self-test.mjs
These scenarios cover truncation-and-continuation, normal stop, tool-call interception, error handling, and the kill-switch behavior — all passing.
Use Cases & Caveats¶
Suitable for scenarios requiring long-form text output, such as summarizing lengthy documents, code generation, and multi-step reasoning chains. The plugin runs with the privileges of the current dsh process; review the source code and license (MIT) before installing.
The prerequisite is that the model’s output triggered max-tokens or a specific error after visible text was produced, and that no tool call is present. If the response is truncated in the middle of a “thinking block,” continuation is not possible because the thinking block carries a non-portable signature.
Summary¶
dsh-continuation intercepts truncation at DSH’s llm/stream layer. By replaying context and disabling reasoning, it automatically completes the model’s response so that downstream agent loops perceive a single finished turn. It does not alter existing consumption logic, imposes no mandatory configuration, and offers an environment-variable-based kill switch — making it well-suited for agent development that requires long-form text output.
- Directory page: https://www.skillhub.cn/plugins/lanmeigezi/dsh-continuation
- GitHub: https://github.com/lanmeigezi/dsh-continuation