rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
1960697431/dsh-difficulty-router
Difficulty-aware + taste-aware model routing plugin for DeepSeek Harness (DSH): hard/ambiguous tasks → strong model, UI/design → taste model, easy work stays cheap. Provider-agnostic, safe-by-default, calibrated on real bake-offs. MIT.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:1960697431/dsh-difficulty-router
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Difficulty-aware + taste-aware model routing for DeepSeek Harness (DSH).
Hooks the agent/request waterfall and, per request step, decides which model
should actually serve it:
The goal: spend strong-model money only where it buys quality, and protect your codebase from the places where a weak model guesses wrong and creates cruft.
中文:难度 + 品味双通道的模型路由插件。困难/含糊任务升级到强模型,UI/设计 任务路由到有品味的模型,简单活留在便宜的默认模型上。只在真正需要质量的地方 花强模型的钱。
Same session, three requests — the router reads each step and routes it
(logFile JSONL, one line per decision):
{"kind":"keep", "model":"aliyun/deepseek-v4-flash", "score":1, "reason":"1+1=?"} // easy → stays cheap
{"kind":"escalate", "to":"aliyun/qwen3.8-max", "score":5, "hits":["重构","契约","幂等"]} // hard → strong
{"kind":"escalate-ui", "to":"aliyun/kimi-k3", "score":1, "uiHits":["样式","配色","布局","动效"]} // UI → taste
{"kind":"keep", "model":".../deepseek-v4-flash", "score":4, "hits":[]} // "安全加固…只改一个文件" → NOT hard, stays cheap
Every line is a real measured decision from a live session. Install it, run
dryRun: true for a day, and watch what would have routed — then flip to
false and let it work.
A real bake-off on a production monorepo (backend security task + frontend redesign, hidden acceptance tests, token usage read from session logs) showed:
| Task | cheap model | strong model |
|---|---|---|
| single-file security fix | passed, ¥0.03 | passed, ¥0.50 |
| pricing-page redesign | good, ¥0.04 | slightly better, ¥0.78 |
Two lessons:
From the DSH plugin market, or manually:
dsh plugin add dsh-difficulty-router
# or
dsh plugin add github:YOUR_USER/dsh-difficulty-router
By default every target is empty, so a fresh install is a log-only bystander
—it records decisions but never switches any model. Set your targets in the
profile cordis.patch.yml insert row:
# dsh-plugin-manager:managed:start
- insert:
- id: dsh-difficulty-router
name: 'dsh-difficulty-router'
config:
dryRun: false # true = observe only (recommended first)
threshold: 4 # difficulty score that triggers escalation
strongProvider: openai # difficulty-escalation target
strongModel: gpt-5.2
uiProvider: anthropic # taste-lane target
uiModel: claude-sonnet-5
exemptRoutes: [] # never escalate from these (prefix/regex)
weakRoutes: [] # empty = auto (see below)
classifier: # optional v2 second opinion (default off)
enabled: false
model: ''
baseUrl: '' # any OpenAI-compatible endpoint
apiKeyEnv: '' # env var name holding the API key
timeoutMs: 1500
# dsh-plugin-manager:managed:end
Nothing here names a specific vendor — point the targets at whatever models your DSH profile has configured.
| key | type | default | meaning |
|---|---|---|---|
dryRun |
bool | true |
log decisions without switching (start here) |
threshold |
int | 4 |
difficulty score (1–5) that escalates |
strongProvider / strongModel |
str | '' |
difficulty target; empty disables the lane |
uiProvider / uiModel |
str | '' |
taste target; empty disables the lane |
uiAlwaysStrong |
bool | true |
UI tasks always go to the taste model |
exemptRoutes |
list | [] |
provider/model prefixes/regex never escalated from |
weakRoutes |
list | [] |
explicit weak list; empty = auto |
classifier.* |
obj | on (host llm) | v2 second opinion — defaults to asking the current request's own model via DSH's llm service; an external OpenAI-compatible endpoint can override |
logFile |
str | /tmp/difficulty-router.log |
JSONL decision log |
A request is eligible for escalation when its route is not one of the
configured targets, not in exemptRoutes, and either matches weakRoutes
or weakRoutes is empty (auto mode: anything left over is weak). Explicit
strong-model requests are never downgraded.
uiKeywords + a design verb, or
≥2 UI nouns) → taste model.threshold and real evidence (true-hard
signal, or a tool loop ≥6 steps deep) → strong model.Escalated routes stick for the rest of the turn. Scary words alone and long context alone never escalate.
All lists are overridable via config (trueHardKeywords, scaryKeywords,
ambiguousKeywords, uiKeywords, uiVerbs).
Keywords are free, instant, and testable — but they miss paraphrases and
domain slang. So for the ambiguous middle (heuristic score 3), the router asks
whatever model the current request is already using (via DSH's own llm
service) for a one-line difficulty verdict. No extra provider, no API key, no
vendor binding: users of OpenAI, Alibaba, local models, anything — the router
uses what they already have. If the host llm service is unavailable, it
falls back to the heuristic alone (safe).
Decisions are appended as JSONL to logFile:
tail -f /tmp/difficulty-router.log
# kinds: keep | escalate | escalate-ui | escalate-v2 | dry-run-* | keep-v2
Run dryRun: true for a day, watch what would escalate, then flip to false.
npm test # node --test classifier.test.js router.test.js (29 tests)
The decision core (decideStep) is pure and unit-tested; the plugin shell only
wires the agent/request waterfall and session-feature reading.
Found a task that routed wrong? Have a routing rule you need? Feature requests and tuning ideas are very welcome — this plugin got good because real mistakes were measured and fixed. Open an issue, or send a PR that tweaks the keyword lists / thresholds / lanes.
Ideas that would land well:
欢迎提需求、提路由失误案例、或 PR 调整词表/阈值/通道。这个插件是靠真实 盲测数据校准出来的,你的反馈会让它更好用。
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。