llm-adaptive
Manifest valid★ 3Adaptive model routing: per-request complexity classification with automatic provider routing.
llm-adaptive
Adaptive model routing plugin for DeepSeek Harness. Adds an adaptive provider to the model picker: every LLM request is classified by a flash classifier (low / medium / high / critical) and routed to the matching backend provider through config-driven chains.
Features
- Per-request complexity classification —
deepseek-v4-flashcalled directly (never through a proxy, no recursion). - Context-aware judging — injects a rolling session-goal summary plus the recent turns into the classifier prompt (continuation / wrap-up / error-loop rules).
- Sticky level protection — a mid-task downgrade is held at the previous level unless the message carries explicit downgrade or wrap-up signals.
- Config-driven routing chains — chains come from
pool.json→routing.levels($activeexpands to the active provider, missing entries fall back to defaults); transport failures walk down the chain. - Classifier config from the pool — URL / model / key reference read from the
classifiersection ofpool.json(no hardcoded credentials). - Fail-open — any classification failure degrades to
medium; never blocks a request. - Observable — every decision (level, cause: llm/sticky/cache) is written to the plugin log.
- 120s decision cache — keyed by user-text head plus goal fingerprint.
Requirements
- DeepSeek Harness (dsh)
- A model pool file at
~/.dsh/tools/cc-switch-sync/pool.jsonwith:classifiersection:url,model,key_ref(resolved against~/.dsh/.credentials.yaml, poolapi_keyas fallback)routing.levels:low/medium/high/criticalchains
- A DeepSeek API key for the classifier
The pool file is produced by the cc-switch-sync import tool (or can be authored by hand). The plugin reads it on every request, so pool edits take effect immediately.
Install
dsh plugin add llm-adaptive
or, from a local checkout:
cd ~/.dsh/profiles/web && npx pnpm@10 install # with "llm-adaptive": "file:plugins/llm-adaptive"
Restart the dsh web service, then select adaptive(自动路由) in the /model picker.
Usage
- Open
/modeland chooseadaptive(自动路由). - Every subsequent LLM request is classified (low/medium/high/critical) and routed to the first available provider of that level's chain.
- Decisions are logged with
level=… cause=… chain=…to~/.dsh/hooks/plugin.log.
The explicit level models (low, medium, high, critical) are also listed in the picker for direct selection.
How it works
A custom LlmAdapter for the adaptive provider: stream() awaits classification (async generator), then forwards to the target backend via ctx.llm.prepareCall + stream (unified chunk protocol, passthrough). Request-level interception was chosen over proxy or request-layer hooks because dsh hot-swaps configuration and the prepared-call contract requires matching provider/model options.
License
MIT
Comments
Loading…
Similar plugins
by icyaaaww
Deterministic per-turn adaptive model routing for DeepSeek Harness
★ 0
MIT
JavaScript
Aug 24, 2026
dsh plugin --profile web add dsh-adaptive-model-routerby zhangzhangco
Automatic tier-based model routing for DeepSeek Harness (dsh): a virtual `smart` model classifies every request by difficulty (hard / normal / easy) and by vision need, then delegates it to the models you already configured.
★ 0
NOASSERTION
JavaScript
Sep 22, 2026
dsh plugin --profile web add dsh-tier-routerby ChaoYuZhang001
Configurable Auto model routing tier for DeepSeek Harness
★ 0
MIT
JavaScript
Aug 20, 2026
dsh plugin --profile web add @chaoyuzhang/dsh-auto-routerby andrepontesmelo
DSH plugin: virtual model ids backed by pluggable routing algorithms (priority, round-robin) over real provider candidates, with transparent failover.
★ 0
MIT
JavaScript
Oct 12, 2026
dsh plugin --profile web add @andrepontesmelo/dsh-model-routerby Wany-i
Reorder the model list of any llm-pi-ai route from Settings > Models; the composer model menu follows the same order.
★ 0
MIT
JavaScript
Oct 3, 2026
dsh plugin --profile web add dsh-model-orderby Yaaaaaaa233
On-demand planning for DeepSeek Harness: execute simple tasks directly and call a configurable planning model for complex ones.
★ 0
MIT
JavaScript
Sep 29, 2026
dsh plugin --profile web add dsh-adaptive-plan