tianji-qingtian/dsh-model-router 预览 preview

tianji-qingtian/dsh-model-router

模型路由与成本优化器:针对DeepSeek Harness,简单问题由flash快速回答,故障自动降级,实时显示token/缓存/成本面板

Project Overview项目介绍

This is a native model routing and cost optimization plugin built exclusively for DeepSeek Harness (DSH). To install it, you first need to have the DSH CLI installed globally on your system PATH, version 0.1.1-rc.2 or newer. If you installed DSH via pnpm, you need to ensure your pnpm global bin directory is added to your system PATH, otherwise you can run the pnpm setup command first or prefix installation commands with npx. The plugin is added directly to your DSH web profile via the dsh plug command, and no additional build step is required as prebuilt artifacts are already committed.

This plugin is designed for any DSH user who wants to reduce their LLM API costs without sacrificing functionality for simple queries. It automatically classifies queries with a fast zero-prefix judge call that checks whether a query is simple enough for a cheaper model. If the plugin is set to auto mode, it will ask the user for confirmation before routing a simple query to the cheap model, and users can also disable automatic routing entirely at any time. The routing logic respects any manually selected model in the composer, and handles image queries correctly by routing them to vision-capable cheap models when available.

The plugin is released under the open-source MIT license, so it is free to use, modify, and distribute. It automatically detects cheap and strong model pairs from your existing provider catalog at runtime, based on simple model name matching rules. There are a few known limitations: transient failure degradation flags are stored process-locally and reset when DSH restarts, while the auto/off toggle state is durable and survives restarts. The forged step envelope used for direct quick answers is tightly coupled to DSH's current session structure, so users should check compatibility after DSH upgrades.

这是一款专为 DeepSeek Harness (DSH) 开发的原生模型路由与成本优化插件。它可以将简单问题路由到廉价模型回答,避免额外缓存税费,同时在服务商出现短暂故障时自动降级重试,还能在编辑器底部停靠栏实时显示会话内的 token 用量、缓存命中率和成本估算。插件支持中英双语界面,可通过 DSH 官方 CLI 命令直接安装到本地配置中。

对于日常使用 DSH 进行开发和对话的用户来说,这款插件可以在不改变原有使用习惯的前提下降低使用成本。插件会自动通过零前缀快速判断任务类型,如果判断为简单问题会弹出询问,让用户选择是使用廉价模型快速回答还是调用主模型处理,也支持手动开关自动路由功能。图像类消息会自动路由到支持视觉的廉价模型,没有对应模型则回退到主模型,不会出现无依据回答。

该插件基于 MIT 许可开源,使用前需要先全局安装 DSH CLI 0.1.1-rc.2 或更新版本,若使用 pnpm 需确保 pnpm 的全局 bin 路径已添加到系统 PATH 中。目前插件存在一些已知限制:自动路由状态可持久化保存,但故障降级标记是进程本地的,重启后会重置;直接快速回答会在会话日志中生成伪造的步骤封包,升级 DSH 后需要重新检查兼容性。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 6 stars - very few users, little community feedback星标只有 6,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add "github:tianji-qingtian/dsh-model-router#v0.9.5"

把 tianji-qingtian/dsh-model-router 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-model-router

Model Router & Cost Optimizer for DeepSeek Harness (dsh). Answers simple questions directly on the cheap model (zero prefix, no cache tax), degrades gracefully on transient provider failures, and shows live per-session token / cache-hit / cost figures right under the composer.

The harness is in developer preview and iterates quickly — expect compatibility-breaking changes.

中文说明见 README.zh.md。

Features

  • Cheap-model judge routing — clearly heavy work (strong keywords / long payloads) goes straight to the main model with zero added latency. Everything else is decided by a zero-prefix flash judge call (SIMPLE / AGENTIC, one word, 64-token cap, thinking off). The judge also sees the last assistant reply, so context-dependent follow-ups (它 / 这个 / 继续 …) are never misrouted to a context-free answer.
  • Ask before quick-answering — in auto mode, every SIMPLE hit asks the user through the built-in question UI: ⚡ 快速回答(flash) or 主模型回答. Choosing the main model (or dismissing the question) takes the normal flow; subagent sessions fall back automatically. The question text follows the request language.
  • Direct quick-answer — when the user picks the quick option (or a quick answer is otherwise produced), the router rejects the step, runs a zero-prefix one-shot stream on the cheap model (no cache-miss tax), and writes the question + answer straight into the session log inside a step envelope — the user sees an ordinary Q&A exchange prefixed with a ⚡ 快速回答 / Quick answer · <model> marker (matched to the question language), the main model never runs for it, and no subagent sessions, relay cards, or toasts are created. The main session's model and prefix cache are never touched.
  • Vision-aware routing — messages carrying image blocks are routed to the catalog's image-capable model when one exists (e.g. deepseek-v4-flash-vision-exp), including the quick-answer judge/stream; without an image-capable model they fall back to the main model instead of being answered blind on a text-only flash.
  • Model picker respected — the router never overrides the model chosen in the composer picker or via selectModel, including relay/proxy providers (e.g. kabuai): agent/request passes the harness's requested config through unchanged, and quick answers always run on the session provider's own cheap model. (No drift healing — its original cause, a forged request/header, was removed at the root in v0.9.2.)
  • Auto / off toggle — the dock panel and /router auto|off (plus the route_model tool) simply enable or disable quick-answering for the session. There is no per-request model flipping to configure.
  • Automatic fallback — transient failures (RATE_LIMIT, SERVER, TIMEOUT, EMPTY_RESPONSE) degrade the turn to the cheap model and retry once; anything else delegates to the provider's own retry policy.
  • Real usage metering — a session projection folds the durable log: real adapter token usage (input / output / cache read / cache write / reasoning), per-model breakdown, and estimated cost from a model-class price table. Projection-based, so the numbers are replay-safe and survive cold sessions.
  • Composer dock panel (i18n zh/en) — Auto / 关闭 toggle, current model, miss/out/cache%/≈$ line, a QA×N quick-answer counter (with a brief inline highlight on each direct answer), and a per-model usage breakdown. Reactively driven by useProjection; the toggle reuses the built-in commands remote — no custom wire protocol. UI strings are localized through the harness locale service.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-comfyui-ctl 下一个 Next dsh-vision-bridge →