r-ayin/dsh-stream-index-guard ↗★ 0

dsh-stream-index-guard

Patches the LLM assistant-stream accumulator at runtime to clamp invalid chunk indices, downgrading hard stream failures to dropped or merged chunks; ships a stats tool. 适合遇到流式输出因索引错误导致会话卡死或中断的用户。

패키지
dsh-stream-index-guard
호환성
미검증
Harness peer 범위
>=0.0.1-rc <2
버전
0.0.1
라이선스
MIT
최근 업데이트
2026. 10. 15.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:r-ayin/dsh-stream-index-guard

dsh-stream-index-guard

Runtime guard for the DSH LLM assistant stream.

Some upstream LLM relays occasionally emit text-delta / reasoning-delta / tool-call-delta chunks with an invalid index. Left alone, one bad chunk hard-fails the whole turn (stuck session, truncated output).

This plugin patches AssistantStreamAccumulator.push at runtime and clamps an illegal index to the last valid index (or 0), downgrading the hard failure into dropping/merging the bad chunk. It ships a stats tool and on-disk state.

How it works

  • On apply it discovers the host's @deepseek-ai/dsh-llm module files (derived from the host entry script path, so it patches the exact loaded instances), and is idempotent via Symbol.for('dsh-stream-index-guard').
  • Override discovery with DSH_STREAM_GUARD_TARGETS — comma-separated file:// URLs of the dsh-llm modules to patch.
  • Registers the stream_index_guard_stats tool (patch targets, clamped-chunk count, samples).
  • Writes stats to /tmp/dsh-stream-index-guard/stats.json.

Build

bash scripts/build.sh   # or: npm run build (tsc)

Install

Install it from the DSH Plugin Market (Settings → Plugin Market), or add it to your profile bundle stack manually — see cordis.patch.yml.

License

MIT