fu827707013/dsh-concurrency-guard0

dsh-concurrency-guard

DSH 并发请求监控与门闩:挂钩 llm/stream 瀑布,统计全部在途模型请求并按来源分类(主会话/子代理/插件/压缩/标题)与会话活跃聚合,达到上限 FIFO 排队,防止并发超限被供应商锁号;提供 WebUI 实时面板(含历史清理)、HTTP JSON 端点、状态文件与 concurrency_status 工具。

包名
dsh-concurrency-guard
版本
1.3.2
许可证
MIT
最近更新
2026年8月27日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:fu827707013/dsh-concurrency-guard

使用

实时监控(四选一)

方式用法
WebUI 面板会话页顶部视图切换 →「并发监控」页签(1.5s 轮询,可暂停)
HTTP 端点GET http://127.0.0.1:3080/api/concurrency-guard/status?full=1 带最近历史)
状态文件Get-Content $DSH_HOME\concurrency-guard\state.json(防抖 250ms)
工具模型可直接调用 concurrency_status{"full": true} 带历史)

面板内/HTTP 热改

  • 面板按钮:切换模式(排队节制/仅监控)、上限− / 上限+🗑 清历史
  • POST http://127.0.0.1:3080/api/concurrency-guard/config,body 如 {"mode":"monitor"}{"maxConcurrency":8}
  • POST http://127.0.0.1:3080/api/concurrency-guard/history,body {"action":"clear"}(清空历史)或 {"action":"prune"}(按 TTL 清理);
  • 其它插件:ctx.concurrencyGuard.configure({...}) / .status() / .reset() / .clearHistory() / .pruneHistory()

配置

环境变量默认说明
DSH_CG_MAX_CONCURRENCY5并发上限(供应商/中继限制数)
DSH_CG_MODEqueuequeue=排队节制;monitor=只监控不拦
DSH_CG_WARN_AT4活跃并发达到该值记 warn
DSH_CG_STATE_FILE$DSH_HOME/concurrency-guard/state.json状态文件路径
DSH_CG_MAX_QUEUE_WAIT_MS300000排队超时强制放行;0=无限等待
DSH_CG_HISTORY30最近完成记录保留条数(硬上限)
DSH_CG_HISTORY_TTL_MS3600000历史记录时间 TTL ms;0=关闭(只靠条数上限)
DSH_CG_MAX_STREAM_STALL_MS600000流式请求"无输出"判死阈值 ms(弃流兜底记中断;0=仅靠提前弃流路径)

优先级:运行时 configure() > loader config > 环境变量 > 默认值。