dsh-stream-index-guard
其他 活跃维护

dsh-stream-index-guard

r-ayin/dsh-stream-index-guard

对LLM助手流累加器实施运行时补丁,自动钳制无效块索引,将硬性流故障降级为丢弃或合并数据块,避免会话中断,内置统计工具便于监控修补效果。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
8 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:r-ayin/dsh-stream-index-guard
git clone https://github.com/r-ayin/dsh-stream-index-guard.git
git clone git@github.com:r-ayin/dsh-stream-index-guard.git
README.md main

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