dsh-continuation
Manifest validDSH plugin: auto-continue truncated model responses at the llm/stream layer
dsh-continuation
A DeepSeek Harness (DSH) plugin that keeps a long answer going when the model gets cut off.
When a response ends with max-tokens — or an upstream error after the model has already produced visible text — this plugin sends one continuation request and appends the new chunks to the same stream. The agent loop still sees a single finish, so nothing downstream has to change.
What it actually does
llm/stream (waterfall)
├─ original stream → text-delta / tool-call-delta / usage / finish
├─ finish.kind === 'max-tokens' or 'error' (and no tool call, and not aborted)
├─ build a continuation request:
│ messages + a user turn carrying the last 1500 chars as a "resume from here" anchor
│ reasoningEffort: 'off' ← required, see below
└─ stream the continuation and merge its deltas with remapped indices
Up to 3 rounds. Each round must add at least 20 characters, otherwise the original finish is kept and the response is left as-is.
Why reasoningEffort: 'off'
A continuation request replays a partial assistant turn. With thinking enabled and tools present, the DeepSeek adapter rejects that with content[].thinking must be passed back. Turning reasoning off for the continuation round is what makes the retry legal — this was found by testing, not by reading the docs.
Install
dsh plugin --profile web add "<absolute path to this repo>"
Then restart dsh once (bundle list change is not hot-reloaded).
The bundle patch is included, so the plugin mounts itself:
- insert:
- id: dsh-continuation
name: '@local/dsh-continuation'
Kill switch
DSH_CONTINUATION_DISABLED=1
Set it before starting dsh and the hook becomes a pass-through. The self-test asserts this.
Tests
node test/self-test.mjs
Eight offline cases, no network, no real model calls — they drive the hook with synthetic streams:
| case | what it pins down |
|---|---|
| truncation continuation | max-tokens → continuation text is appended, finish becomes stop |
| stop regression | a normal stop response is forwarded byte-for-byte |
| no continuation on abort | signal.aborted disables the hook |
| no continuation on tool call | once a tool call appears, do not continue |
| no continuation on text-free error | error without any text → nothing to continue |
| continuation failure preserves original finish | upstream throws mid-continuation → original response survives |
| sentinel kill switch | DSH_CONTINUATION_DISABLED=1 turns the hook into a pass-through |
| incompatible runtime error | a kernel without ctx.on / runtime.stream fails loudly |
Last run: ALL PASS.
Design notes
- Fail loudly, never silently. If the kernel does not provide
ctx.onorruntime.stream, the plugin throws an explicit error instead of degrading to "no continuation". - Never rewrite a good response. Any response that does not qualify is replayed exactly as received, including its original
finishchunk andreplayState. - Discard continuation segments that emit tool calls. A half-answer resumed into a tool call would corrupt the turn; the segment is dropped and the original finish wins.
- WeakSet guard against re-entry. A continuation re-enters the same waterfall through
runtime.stream(); the exact options object is marked so the hook only forwards it once.
Limitations
- Continuation text is appended in the same message; consumers see one longer response, not two messages.
- If the cut happens inside a thinking block, the turn cannot be continued — thinking carries a signature that is not portable.
MAX_ROUNDS,MIN_GROWTHandTAIL_CHARSare constants inlib/index.js; there is no config surface yet.
License
MIT
Comments
Loading…
Similar plugins
by quekenao
Auto-continue plugin for DSH: continues model responses truncated at max-tokens
★ 0
MIT
JavaScript
Nov 13, 2026
dsh plugin --profile web add @quekenao/dsh-auto-continue-communityby 54nanmiao
DSH plugin: detects repetitive or self-referential reasoning inside the token stream, and truncates that block before it is written back into context.
★ 0
MIT
JavaScript
Nov 7, 2026
dsh plugin --profile web add dsh-no-loop-pluginby hbx111
DeepSeek Harness plugin: in-stream refusal detection and auto-retry that keeps streaming intact
★ 0
MIT
JavaScript
Nov 17, 2026
dsh plugin --profile web add dsh-policyby Frog755
DSH client plugin: auto-sends 「继续」 when a turn is interrupted/errored/overlong. No model/provider switching. Ships with a settings card.
★ 4
↓ 203/wk
MIT
JavaScript
Nov 21, 2026
dsh plugin --profile web add @frog755/dsh-client-auto-retryby Zenjibad
Enables or disables DSH plugins from Settings → Plugins: each toggle stops or starts the plugin immediately without a restart and the change persists across restarts.
★ 1
↓ 51/wk
MIT
TypeScript
Aug 28, 2026
dsh plugin --profile web add dsh-plugin-toggleby lyc0110
Guardrail for DSH llm/stream: detects when model reasoning or text degenerates into a periodic repetition loop and aborts the request instead of streaming until you give up.
★ 0
MIT
JavaScript
Oct 21, 2026
dsh plugin --profile web add dsh-loop-guard