tianji-qingtian/dsh-model-router ↗★ 1
dsh-model-router
模型路由与成本优化器,用于 DeepSeek Harness:在廉价模型和强大模型之间进行启发式分层路由,临时故障时自动回退,并在 composer 停靠栏中提供每会话的令牌/缓存/成本面板。
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:tianji-qingtian/dsh-model-router说明文档
阅读完整 README ↗dsh-model-router
Model Router & Cost Optimizer for DeepSeek Harness (dsh). Routes every agent step to the cheapest sufficient model, 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.
Features
- Heuristic tier routing — at turn start the newest user message is classified (
agent/pre-step: task keywords + payload size; history is deliberately ignored so a long agentic conversation can still route a trivial follow-up cheap). Trivial prompts (是什么 / 解释 / 翻译 / hello …) go to the cheap catalog model; agentic work (实现 / 重构 / 调试 …) stays on the strong one. The chosen tier is sticky within a turn. - Switch-cost hysteresis — every model flip pays a full-prefix cache miss on the target model (a long cached session is cheapest staying put). So cheap routing engages only after two consecutive cheap-classified turns, while heavy turns switch back immediately. Manual mode (
/router,route_model, dock buttons) bypasses the hysteresis. - 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 — tier buttons (Auto / 省 / 强), current model,
miss/out/cache%/≈$line, and a per-model usage breakdown. Reactively driven byuseProjection; buttons reuse the built-incommandsremote — no custom wire protocol. - Manual control —
/router auto|cheap|strongslash command, and a model-visibleroute_modeltool so the agent itself can request a tier mid-task.
Install
Prerequisites
The dsh CLI must be on your PATH. If you only ever ran the harness through npx, dsh is not installed and you will get — install it globally first: