fu827707013/dsh-concurrency-guard ↗★ 0
dsh-concurrency-guard
DSH 并发请求监控与门闩:挂钩 llm/stream 瀑布,统计全部在途模型请求并按来源分类(主会话/子代理/插件/压缩/标题)与会话活跃聚合,达到上限 FIFO 排队,防止并发超限被供应商锁号;提供 WebUI 实时面板(含历史清理)、HTTP JSON 端点、状态文件与 concurrency_status 工具。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:fu827707013/dsh-concurrency-guard说明文档
阅读完整 README ↗使用
实时监控(四选一)
| 方式 | 用法 |
|---|---|
| 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_CONCURRENCY | 5 | 并发上限(供应商/中继限制数) |
DSH_CG_MODE | queue | queue=排队节制;monitor=只监控不拦 |
DSH_CG_WARN_AT | 4 | 活跃并发达到该值记 warn |
DSH_CG_STATE_FILE | $DSH_HOME/concurrency-guard/state.json | 状态文件路径 |
DSH_CG_MAX_QUEUE_WAIT_MS | 300000 | 排队超时强制放行;0=无限等待 |
DSH_CG_HISTORY | 30 | 最近完成记录保留条数(硬上限) |
DSH_CG_HISTORY_TTL_MS | 3600000 | 历史记录时间 TTL ms;0=关闭(只靠条数上限) |
DSH_CG_MAX_STREAM_STALL_MS | 600000 | 流式请求"无输出"判死阈值 ms(弃流兜底记中断;0=仅靠提前弃流路径) |
优先级:运行时 configure() > loader config > 环境变量 > 默认值。