dsh-delegate-router
Automatic Flash/Pro routing for DeepSeek Harness subagent calls.
Your main conversation keeps running on a strong model (e.g. V4 Pro). When the agent delegates a task to a subagent, this plugin classifies the task and sends light tasks to a cheap model (e.g. V4 Flash) while heavy tasks stay on the strong model — deterministically, without relying on the model's cooperation. Every decision is recorded in a ledger you can inspect from the sidebar (⚡ 分派记录).
- Auto routing — light tasks run on Flash, heavy tasks stay on Pro.
- DIY rules — all rules live in
~/.dsh/dsh-delegate-router.json: keyword lists, the short-task threshold, the budget cap, and the Beijing peak-hour demotion. - Manual overrides — per-call
provider/modelparameters on thesubagent/subagent_forktools. /delegatecommand — per-session mode:/delegate auto | off | flash-all.- Decision ledger — the ⚡ 分派记录 panel lists every routed delegation (task, route, trigger) for the active session.
Why
DeepSeek V4 Flash costs exactly one third of V4 Pro on every line (official
pricing, effective 2026-08-17; peak/off-peak only scales both). Stock DSH runs
every subagent on the parent's model — a search task delegated from a Pro
session costs the full Pro rate. Measured on real sessions: 4 routed runs,
~156K tokens, ¥0.32 actual (Flash) vs ¥0.96 hypothetical (Pro) — 66.7%
saved on every routed task. Run node scripts/measure-savings.mjs against
your own ~/.dsh/sessions to reproduce.
Rules (in order)
- explicit per-call
provider/model→ used as-is (manual) /delegate off→ inherit;/delegate flash-all→ all Flash- session tokens over
budgetCapTokens→ Flash (budget) - task text hits
heavyKeywords→ Pro (auto-heavy) - task text hits
lightKeywords→ Flash (auto-light) - task text ≤
shortTaskMaxChars→ Flash (auto-short) - unmatched + Beijing peak hours (default 9–12, 14–18) → Flash (
peak) - otherwise → inherit the parent model
Task text = the subagent call's description + prompt, matched
case-insensitively as substrings. Heavy beats light.
Install
dsh plugin --profile web add dsh-delegate-router
Configure
All knobs are optional and live in ~/.dsh/dsh-delegate-router.json:
{
"flashProvider": "opencode-go",
"flashModel": "deepseek-v4-flash",
"proProvider": "opencode-go",
"proModel": "deepseek-v4-pro",
"mode": "auto",
"lightKeywords": ["search", "搜索", "查找", "总结", "summarize", "list", "列出"],
"heavyKeywords": ["refactor", "重构", "implement", "实现", "debug", "调试"],
"shortTaskMaxChars": 120,
"peakDemoteUnknown": true,
"peakHours": [[9, 12], [14, 18]],
"budgetCapTokens": 0
}
shortTaskMaxChars: 0disables the short-task rule;peakDemoteUnknown: falsedisables peak-hour demotion;budgetCapTokens: 0disables the cap.- Providers can also come from
DSH_DELEGATE_ROUTER_FLASH_PROVIDER/DSH_DELEGATE_ROUTER_FLASH_MODEL/DSH_DELEGATE_ROUTER_PRO_PROVIDER/DSH_DELEGATE_ROUTER_PRO_MODELenv vars. - Restart DSH after editing the file. Switch mode at runtime with
/delegate <mode>.
Development
npm install
npm run smoke # manifest sanity
node scripts/test-routing.mjs # deterministic rule checks
node scripts/measure-savings.mjs # real savings over ~/.dsh/sessions
node scripts/e2e-panel-loop.mjs # browser E2E against a test instance
License
MIT
Acknowledgements
Built for the DeepSeek Harness plugin ecosystem — thanks to the community on LINUX DO for feedback and testing.
No comments yet. Be the first to write one.