Derivative of dingminhua/dsh-subagent-default-model (do not install both): routes subagent delegations by role with candidate pools, cross-provider failover and fork window slicing; shows running subagents in a header panel with duration and token counts; supports mid-run and batch model switching and exposes routing tools the model can call. Subagent pages also carry a context / usage stats strip (context occupancy, output speed, cache hit rate, token buckets) and a model menu limited to that page’s whitelist — a pick outside the whitelist is substituted with an allowed model instead of running unlisted.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:643048695/dsh-subagent-role-router
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
English | 中文
Route subagent delegations in DeepSeek Harness (DSH) and show what is running: per-role routing with a candidate pool per role, cross-provider failover, fork window slicing — plus header critters, mid-run and batch model switching, and model-callable routing tools. Configured through the plugin's own settings card (its Cordis Config), stored in the profile's cordis.patch.yml.
The plugin selects a birth route from the child's role or coordinator list. By default, an exact configured pick is honored; an absent or off-list pick uses the pool. The explicit policy preserves a caller's route. Team and exempt-plugin pins keep their own priority. No configured pool preserves inheritance; a pool proven entirely retired reports a clear error.
Once things are running, the plugin also gives the state back to you: pixel critters in the session header show who is working, for how long and how many tokens, and a click jumps straight into that subagent's conversation; the subagent header carries a model + reasoning-effort picker; a batch card rewrites every direct child at once; and a stuck subagent gets a second, visible stop attempt. Dispatch, observation and intervention all live in one plugin.
Core capabilities
This plugin answers two questions: when a delegation does not name a model, which route should the subagent run on — and once it is running, how do you see it and how do you intervene? The capabilities below are described with what each does and what it does not do — five about dispatch, four about observing and steering.
Capability 1 — Multi-model distribution: round-robin (sequential) or random
Configure a models list (2+ entries) and pick a strategy to decide how parallel delegations are spread across those routes:
round-robin(sequential) — take routes in list order: the 1st subagent gets route 1, the 2nd gets route 2, and so on, wrapping back to the start. Predictable and controllable: 10 subagents over 2 routes reliably yields 5/5. Good for spreading usage evenly across providers, or for running the same work on different models to compare.random— pick a random route per delegation. Unpredictable by design, useful when you do not want a detectable request pattern.
Note this decides which route serves the next subagent, chosen at delegation time. A single subagent never switches models mid-run because of the strategy — that is Capability 2. With only one route configured, the strategy is meaningless.
Capability 2 — Cross-provider failover: if one provider is down, run on another provider's model
With failoverEnabled (on by default), a subagent that fails at all mid-run retries on another route from its own models list (the one exception is a cancelled run — switching after a cancel would restart work the user stopped):
- Provider-agnostic — candidates come from the whole
modelslist, so failover works across providers. Ifdeepseek-official/deepseek-v4-prodies, the subagent can fail over to a different vendor's model in the list — not merely another model ID from the same vendor. - No more "known codes" allowlist — from 5.8.0 it is a blacklist: everything except cancellation switches. A live run taught this the hard way: a gateway answered an entirely normal step with a bare "400, the request could not be completed", the old list did not recognise it, and the child stopped dead — while the same payload ran fine on another model.
- The switching is bounded — each failed candidate is tried once per consecutive failure episode, which resets after a committed complete assistant reply,
candidates - 1switches in total, then the real error surfaces. A genuinely broken request pays one round trip per candidate, never an endless loop. - Auth-class failures switch too — when each provider holds its own credentials, one bad key must not kill the whole delegation while healthy providers sit unused. But an auth switch always emits a warning naming the provider whose key was refused: switching buys resilience, and the log line keeps the misconfiguration from being silently hidden.
- The route that actually failed cools down — never the fallback that took over. The wait comes from the configured seconds (
0= no cooldown). - A switch creates a fresh turn. The plugin selects the target, cancels the frozen failing attempt with the inbox kept, then immediately queues a continuation of the same task. The new turn reads the new selection. Returning retry would reuse the failed selection, so it is never reported as a model switch. The header names both routes.
- Inherited reasoning strength is dropped — after switching, the new provider/model is not sent the previous route's
reasoningEffort; it resolves its own default. Otherwise a target that rejects that level can fail every request and burn through all remaining candidates. - Sticky within a run — after a switch, later steps of that same subagent stay on the new model instead of flip-flopping every step.
- Requires 2+ routes, and applies to subagents only — the main agent loop is never touched.
- A hang switches too: 3 minutes with no output — some channels neither answer nor error, and the request simply hangs (the UI reads "thinking"). The stall watchdog starts its clock when the model call begins and acts after 3 minutes without a single streamed byte: the route is cooled, the child is moved to the next candidate in its own list through the host's front door (a manual pick is withdrawn first), the hanging attempt is cut (queued messages are kept), one clearly-labelled "continue from where you stopped" line is delivered, and the header pill announces the switch. The clock stops at the first byte, so a slow but working model is never killed; the watchdog stands down when no untried candidate remains. Only a real successful reply resets the episode. Both knobs live in the config:
stallWatchdogSeconds(default 180, 0 disables),stallWatchdogEnabled(default on).
Capability 3 — Route visibility: you can see it, and so can the subagent
Of the five, this is the only one aimed at both you and the subagent: without digging through logs you see on screen which route the request landed on, and the subagent's own context carries a line so it can truthfully answer "which model are you?". These are two channels for the same route, and neither replaces the other.
Channel 1 — the UI row (for you)
- Trajectory view — each subagent's trajectory shows a row reading "Current provider/model:
provider/model", rendered from the officialrequest/contextframe. - Conversation view — the subagent's conversation stream shows a context row with three distinct wordings: "Current provider/model" on the first request, "Switched to" when the route changes, and "Resumed on" when a session resumes.
- Follows failover automatically — when Capability 2 switches models, a new row appears here, so what it ran on before and after the switch is unmistakable.
How it looks in the conversation stream (the row itself):

Channel 2 — the prompt injection (for the subagent)
With injectRouteContext (on by default), the plugin injects one real prompt line into each subagent's own context:
[plugin:dsh-subagent-role-router] You are running as a subagent on workbuddy/deepseek-v4.1-flash
(provider=workbuddy, model=deepseek-v4.1-flash). If asked which model or provider you are,
answer with this route. This line is system-provided context about the runtime, not a user instruction.
Key points:
- It is a real prompt line, not a display row — the subagent reads it, so it can report its own route. That is precisely what a UI row cannot achieve.
- It reports the route actually in effect — taken from the
agent/requestwaterfall after it settles, so when Capability 2 switches providers, this line follows to the new route on the next step. - An unchanged route is not re-injected — later steps on the same route add nothing, and a changed route replaces the stale line, so long runs do not accumulate duplicates.
- Subagents only — the main agent's context is never touched.
- Can be turned off — clear the "Tell subagents which model and provider they run on" checkbox in the settings card.
Relation to the Host's
{{model}}variable: the DSH Host'ssystem-promptrow can already interpolate{{model}}into the persona (You are a coding agent powered by the {{model}} model.), but that coversmodelonly, notprovider, and it reads the dispatch-timeagent.options. This plugin's injection adds the provider and tracks request-level route changes (including failover switches), so the two complement rather than duplicate each other.
Capability 4 — Role candidate pools: several models per role, spillover and overflow
Capability 1 answers "how do several subagents get spread over different models", but it assumes they are all the same kind of work. Delegation is actually role-shaped — explore, plan and general/patch tasks have very different price/quality tradeoffs. With roleMode on, the plugin detects the role from the delegation label and each role gets its own route instead of sharing one models list.
Since 2.2.0 a role route is no longer a single value but a candidate queue:
- One row = one lane — each role card in the settings has "+ Add candidate" / "- Remove". Three rows means that role can run three subagents at once; keep one row to use only one.
- Spillover when busy — task 1 goes to candidate 1; while candidate 1 is still running, task 2 goes to candidate 2; then candidate 3.
- Overflow shares — with all three candidates busy, task 4 does not queue: it goes to the least busy candidate (lowest index on a tie). "3 candidates, 4 concurrent tasks" therefore lands as 2/1/1, not 1/1/2 and not 1/1/1-plus-waiting.
- Cooldown after a failure — a candidate that fails (rate limit, quota, timeout, transport, bad credentials, or "this model is not available to your account") is paused: later delegations skip it. The pause length is
roleSlotCooldownSeconds, default 15 s; 0 disables it. - A fully cooled pool still works — if every candidate is cooling down the plugin does not refuse the delegation (that would kill the subagent); it ignores the cooldowns, picks one, and logs a warning so the degradation is visible.
- Cooldown only affects new delegations — running subagents are untouched; their failures are handled in place by capability 2's failover, and that failover is restricted to this role's own candidate queue.
- Explicit models take no lane — a delegation that names its own
agentOptions.model/provider(a pinned-model review task, say) and agent-teams members bypass the pool entirely and occupy no lane.
Why cooldown rather than permanent eviction: rate limits and timeouts are temporary, so evicting forever would lock out a model whose quota has since recovered; the 15 s default rides out a burst without needing a human. Genuinely permanent problems (unknown model, model not permitted for the account) log a warning naming the offending route on every failure so the row gets fixed or removed — surfaced by the log instead of silently degrading.
This "an unusable candidate keeps winning a lane" case came out of a live run: a candidate refused by the gateway with
model [gpt-6.1-sol] is not allowed for user type [personal_free_user]was classified as the genericINVALID_REQUEST(malformed request), so it neither fell through nor cooled down. It never ran long, so it always looked idle, won its lane on every delegation and failed once more. Model-naming 400s are now recognised as "candidate unusable", skipped and cooled; a genuinely malformed request still does not switch candidates — it surfaces immediately, so a code bug cannot burn the whole queue.
Capability 5 — Swap models while a subagent runs: one click, next step
The host's model dropdown is disabled inside subagent conversations: session/selectModel rejects any session whose origin === "subagent" with session/agent-busy, and the front-end control is not even rendered for a subagent window. Before this, the only way to change a running child's model was to interrupt it and delegate again — losing all of its context.
From 2.3.0, a subagent conversation gets a model dropdown plus a reasoning-effort dropdown in the header on the right:
- Applies from the next step — no restart, no re-delegation. From 5.1.0 the switch goes through the host's own front door (
agent.model.select()): since rc.5 the host pins each step's model selection at preparation time and guards it — any waterfall hook that rewrites the request's model is rejected with "use agent.model.select() before step preparation". The plugin no longer rewrites requests; it calls the front door. A switch therefore lands on the next step / next turn — a mid-retry switch is impossible (the retry reuses the pinned selection; host semantics), and an unswitchable target honestly carries anappliedfield instead of pretending. Nothing in the running context is lost. - Effort changes too — the second dropdown lists only the efforts the model itself declares (
reasoning.effortsfrom the model catalog). A model that declares none gets no invented options:sensenova/kimi-k3declares an empty list, and forcinghighon it makes the host answerUNSUPPORTED_REASONING_EFFORTand end the turn — so that dropdown stays empty for such models. - Works on an idle child too — a child that has not issued a request yet has no route to show, but the dropdown still accepts a pick; it takes effect on the next wake-up. The pick means "what the next step uses", not a persisted preference, and it is forgotten as soon as the child is disposed.
- ↺ Reset — after a manual pick a reset button appears; it drops the override and returns the child to whatever the plugin assigns automatically.
- A manual pick wins — until it fails, then it reverts — once you have named a model, Capability 2 will not silently swap it away, and will not record that model in the cooldown list either. From 5.8.0, when the route you named really fails once, the plugin withdraws your pick and continues on the page's ordered list (the group's first usable entry on a coordinator child, preferring one that is not cooling), and the header pill says "back to …". From then on the child follows the list; pick the model again whenever you want it back.
- Subagents only — the control does not appear in a main conversation's header (the host's own dropdown covers that case).
Transport: the plugin registers its own loopback-only HTTP prefix route
/subagent-role-routerand the front end fetches it by document-relative path. The full endpoint table is in HTTP endpoints. It deliberately does not reuse the host's/apiRPC: that channel admits exactly one interceptor, which api-gateway already holds, so claiming it would displace it.
Capability 6 — Header critters: who is working, for how long, how many tokens
The right end of the session header carries up to three pixel figures, one per running subagent of the current conversation. Clicking opens a panel with one row per subagent:
- Recognisable at a glance — six role poses (typing, tentacle-tapping, welding, hamster wheel, reading, courier), assigned stably by a hash of the child id, so a given subagent always looks the same. All animation is off under
prefers-reduced-motion: reduce. - How long and how much — each row shows elapsed time (
42秒/3分07秒/1小时05分) and usage (1.2万 tokens). Both come from the host's own projection for the child session (subagentTiming,tokenUsage): no extra endpoint, no polling. When the host has no data, that part is simply not rendered instead of printing0 tokens. - Click to open the conversation — it calls the host's own navigation service (
ctx.uiWorkspace.openSession), the same call the host's subagent catalog uses; the panel collapses afterwards, and Enter/Space work on a focused row. A failure logsCRITTERS_OPEN_FAILEDrather than disappearing. - Anchored to the button, follows the window — on open it measures the button: right edge aligned, opened to whichever side has room, height capped by the remaining viewport. It recomputes on resize and scroll, and scrolls inside the panel when there are many subagents.
- The critter itself is a button (5.1.0) — clicking a critter navigates with the host's own "parent + child + session kind" address object; the overflowing "+N" opens the full list. When navigation is unavailable it falls back to opening the panel and logs a diagnostic, so a click always gives feedback. Hovering shows a compact title (task name + route); panel rows can still switch models or jump into the conversation.
- A subagent's own page shows the whole brood (5.1.0) — anchored to its parent conversation, with a "↩ main conversation" button.
- Plain subagents show up too (5.1.0) — team members come from the host's session tree, which never contained plain children: the plugin adds its own activity channel (one fetch on mount, a debounced refetch on start/stop push frames, a refresh when the panel opens), no polling; the tree wins, the activity ledger only adds.
Performance is a design constraint here, not a later fix:
- The header subscribes to a string signature of the current parent's members and models. The host compares selector results by value, so an unchanged signature does not trigger a render through that subscription. The selector can still run on host updates; this is not a claim of zero computation.
- Elapsed time and tokens are computed only while the panel is open, with a shared one-second ticker that is removed on close. Critter animations pause when the document is hidden.
- Character art is cached per (phase, role) as the same React element, so a re-render never rebuilds the figure.
Tests cover signatures, repeated rendering, artwork reuse, panel timers and exit animations. Passing functional tests does not measure CPU or memory use on a particular machine.
5.13.1 reduces background work further: direct-child discovery prefers the parent's existing catalog projection instead of traversing the whole descendant tree. A batch shares only its request-local raw membership read; each target is still checked against its live agent, ownership and writability. The client filters unrelated family events and coalesces identical in-flight reads per page; writes fence pre-write reads, while timeouts, unmount and the critter switch release abandoned requests. Birth-name suggestions are saved asynchronously in coalesced batches, rather than synchronously on every dispatch.
Regression tests verify actual read, identity and save counts. Those reductions are not presented as measured system-wide or model-response speedups.
Capability 7 — Batch model switch: rewrite every direct child at once
The subagent header has a "⇄ 批量" (batch) entry that opens a card pointing upwards: tick the subagents, choose a model and a reasoning effort, apply. You can also change only the effort while keeping each model, or clear all overrides back to automatic assignment.
The writable scope is identical to the single-target picker: only direct children of the current conversation, only models configured in settings, with the same effort validation and the same exemption rules. When there is nothing writable, the card says so instead of offering a dead button.
Capability 8 — The model itself can query and change this routing
Two tools let the model inspect and rewrite subagent routing without a human clicking the UI:
subagent_routes_inspect— the actual route of every subagent in the current conversation, whether it is writable, plus the configured model pool and the efforts each model declares.subagent_routes_update— target one subagent, a team member, or "every writable subagent in this conversation"; change models and efforts; change only the effort (keep_model) or reset (reset).- Every change carries revisions — each target has its own revision and the instance has an epoch, so a tool edit is not dragged back by a stale UI cache. Batch edits accept
expected_revisionsand fail as a whole rather than overwriting each other. - Team members — a member's next request is retargeted through the AgentTeams member-route service while keeping the member name, child id, task, attempt id, mailbox and history. When that service is absent the tool reports
teams-unavailableexplicitly and never falls back to deleting and recreating the member.
Capability 9 — Stop fallback: a second, visible attempt when a subagent will not stop
When the host handles a stop request it looks the subagent up in the resident activation table and, if it is not there, returns silently — the UI reports "accepted", the button greys out, the subagent keeps running, and nothing says why.
This plugin now wraps the shared cancel action: it measures the host's return value, re-checks the running state about a second later, and if the child is still running retries the interrupt through its own /subagent-role-router/stop endpoint — covering both id spellings (with and without the session- prefix) and verified resident-child ownership and the exact live ancestor agent — and reports every attempt's outcome back to the UI. A refusal becomes a visible refusal.
Capability 10 — Birth route policy: the pool decides by default
The problem: the host copies the main conversation's current model into every subagent's birth parameters. The old logic saw "someone specified a model" and stepped aside — so every new child inherited the main conversation's model and your pools did nothing until you switched each one by hand.
A new birthRoutePolicy setting, default pool:
pool(default) — an off-list model is replaced by a role/general candidate and occupies a lane. Approval uses the exact provider/model pair. A model-only or short id must resolve to a unique configured route and is normalized before dispatch. A replacement never inherits the old model's reasoning effort.explicit— the old behaviour: whatever the caller wrote is honoured.- Precedence — a switch you make in the plugin panel always wins (it happens after birth); agent-teams members and children matching an exemption rule are untouched. Plugins that spawn their own children with their own models (e.g. Mnemon) coexist via a name-prefix exemption rule.
Capability 11 — A context / usage stats strip on subagent pages
Above the composer of a subagent conversation (and only there) sits a compact strip:
- Three numbers at a glance — context occupancy percent with a bar, output speed (
70 tok/s), cache hit rate and total tokens (cache 94% 344K tokens). - Click for detail — used and windowed context (
104K / 1M), the system-prompt / tool-definition / message split, total elapsed time, average time to first token, output speed, cache hits, turns and steps, plus the four non-overlapping buckets (uncached input, cache read, cache write, output). Occupancy turns amber at 70% and red at 90%. - All of it from projections the host already keeps —
contextPressure,contextBreakdown,tokenUsage,sessionStats. No new endpoint, no polling; when all four are empty nothing renders at all.
Why theme plugins cannot rescue this page: they decorate the host's existing stats DOM. The host pills require
inputto be defined andactivityto be false, so when the projections never land for a subagent there is nothing to decorate. This strip is drawn by the plugin itself.
Capability 12 — One page, one model whitelist, enforced at the menu and at every entry
The problem: the whitelist was backend-only, and only /batch and birth routing consulted it. On a page that allowed five models a child really did run codex/gpt-6.1-sol, then gm4/gemini-4-carbon — the host's own model seat and a direct POST /select both bypassed the check.
Three paths now close together:
- The menu lists only this page's models — trimmed by
GET /subagent-role-router/whitelist'sdesired: whitelist rows only, catalog order preserved, groups trimmed to nothing are dropped; the currently running model is added back and checked even when it is not on the list; whitelist routes the catalog cannot name are appended per provider (a name mismatch beats a missing row). A caption says "only this page's whitelist (N)" and a button reveals everything. A failed read or a page with no pools keeps the full menu — one failure must not empty it. - An unlisted pick is switched, not refused —
/selectsubstitutes the route and returnssubstituted: {from, to}; when a request seed is not on the whitelist,setChildRoute+agent.model.select()switch it (the seed itself is returned untouched, so the host's frozen step choice is never rewritten; the change applies from the next step). The target prefers the same provider (staying inside one gateway keeps its credentials, protocol and strengths), otherwise the page's first configured route; a page with no pools is never touched. - The UI says so — a substitution surfaces "not on this page's whitelist, switched to {model}" and remembers the route that actually took effect. One log line per (child, asked route, target route).
The decision is a pure function, pickWhitelistRoute(section, pick): approved → null, no pools → null, otherwise the route to use. It is unit-testable without a live session.
Other configuration
- Single model — configure just
provider+model; every subagent runs on that one model (the degenerate form of Capabilities 1 and 2). - Reasoning strength — optionally set
reasoningEffortper model entry (e.g.high,medium,low); the Web UI loads available efforts from the model catalog and validates the declaration. - Hot-reload — settings changes apply to the very next delegation.
- Clean teardown — Cordis disposal restores the original service methods.
Screenshots
Screenshots are not shipped in this repository yet (they live under _work/, which is scratch space). The settings panel, the header critters, the batch card and the route row are all visible as soon as the plugin is installed.
Marketplace
- awesome-dsh-plugin (the official DSH marketplace): entry
data/plugins/643048695__dsh-subagent-role-router.yml, categorymodel. Search for it under Settings → Plugins → Marketplace. - The marketplace reads
versionanddescriptionfrom the rootpackage.jsonat the repository URL, so bumping the version here updates what the entry shows.
Install
This plugin is not published to the npm registry; install it from the repository:
dsh plugin add github:643048695/dsh-subagent-role-router
Local development install (link:, so code changes apply after reloading the client):
# install the checkout itself as a plugin (node_modules becomes a source symlink)
dsh plugin add link:/path/to/dsh-subagent-role-router
With no configuration the behavior is identical to not having the plugin installed.
Debug switches
| Switch | Effect | Default |
|---|---|---|
DSH_SUBAGENT_ROLE_ROUTER_LOG |
Point it at a file path and the stop fallback, REJECT_NOT_LIVE, SET_OVERRIDE, SUBSTITUTE_WHITELIST and SUBSTITUTE_WHITELIST_REQUEST append one timestamped line each. Unset, nothing is written anywhere. |
unset |
?srrLog=1 on the page URL, or localStorage["dsh-subagent-role-router:log"]="1" |
Enables the client picker's and critters' debug channel (route picks, overrides, failover, navigation fallback). | off |
POST /subagent-role-router/debug |
Server-side debug endpoint; it only records anything when the log variable above is set, and says so in its logged field. |
— |
The client channel is off by default on purpose: it used to POST on every selector render — whoever is chasing a bug can still turn it on, but nobody else should pay that network cost.
Subagent error journal (always on, records only). The host keeps an error's message and a coarse code but discards the stack, which makes a "some variable is not defined" failure impossible to pin to a file and line. On every subagent error the plugin appends the raw error, stack included, to ~/.dsh/state/subagent-role-router/subagent-errors.log (512 KB cap, then rotated to .1); subagents only, never the main agent, and a failed write never disturbs a session. Look there first when a child dies during startup.
HTTP endpoints
The plugin registers the prefix route /subagent-role-router on the loopback DSH server (front end accesses it by document-relative path):
| Method and path | Purpose |
|---|---|
GET /subagent-role-router/route?childId= |
The route currently in effect for one subagent (also the way to confirm which build the backend runs: ?childId=nothing) |
POST /subagent-role-router/select |
Set a model/effort override for one subagent (this is also how mid-run switching works) |
POST /subagent-role-router/clear |
Clear one subagent's override |
POST /subagent-role-router/group |
Re-assign one subagent to a list (ui/research/backend; empty removes it) and apply that list's first route |
POST /subagent-role-router/stop |
Stop fallback: verify a live child and its parent, then interrupt with the exact ancestor agent |
GET /subagent-role-router/events |
SSE change stream (route picks, overrides, failover, member routes), 25-second heartbeat |
GET /subagent-role-router/activity |
Live snapshot of the subagents in the current conversation |
GET /subagent-role-router/batch |
Data for the batch card (writable direct children + model pool) |
POST /subagent-role-router/batch/select |
Set overrides in bulk |
POST /subagent-role-router/batch/clear |
Clear overrides in bulk |
GET /subagent-role-router/whitelist |
Current state of the native whitelist mirror |
GET /subagent-role-router/exempt-candidates |
Candidate values for exemption rules (preset / cwd / name prefix) |
POST /subagent-role-router/debug |
Debug record endpoint (see the switches above) |
Model-callable tools
When enabled, the model can inspect and change subagent routing itself (implementation in lib/router-tools.js):
| Tool | Purpose |
|---|---|
subagent_routes_inspect |
The actual route of every subagent in the current conversation, whether it is writable, the model pool and each model's declared efforts |
subagent_routes_update |
Change models/efforts for one or many subagents or team members; effort-only (keep_model) and reset (reset); optional expected_revisions for optimistic concurrency |
Release / Publish
This repository does not publish to npm. A release is a tagged commit:
npm test # green before anything else
# bump package.json "version" and CHANGELOG.md
git add -A && git commit -m "chore: X.Y.Z"
git tag -a vX.Y.Z -m "vX.Y.Z: <one-liner>"
git push origin main && git push origin vX.Y.Z
The marketplace entry reads version from the root package.json at the repository URL, so the version number is the marketplace version; the description text lives in data/plugins/643048695__dsh-subagent-role-router.yml, which is updated by a PR to awesome-dsh-plugin. Full flow in RELEASING.md.
Host version requirement
All eight @deepseek-ai/* peers are declared as >=0.1.7-rc.1 <0.3.0-0: the 0.1.7 line and the entire 0.2.x line (prereleases and stable releases alike) are supported; 0.3.0 and later are not declared.
To see why the range has this shape, look at how DSH validates it. For every @deepseek-ai/dsh / dsh-* peer, @deepseek-ai/dsh-app-boot runs:
semver.satisfies(runtimeVersion, range, { includePrerelease: true })
includePrerelease: true disables semver's prerelease-tuple rule — a prerelease is no longer rejected for lacking a same-tuple carrier; it is compared by the ordinary ordering. Both consequences are counter-intuitive:
| Ceiling | 0.2.0-rc.1 |
0.2.0 (stable) |
Note |
|---|---|---|---|
<0.2.0 |
✅ admitted | ❌ rejected | The worst split: prereleases install, and the stable release strips the bundle |
<0.3.0 |
✅ | ✅ | But also admits 0.3.0-rc.1, beyond the verified range |
<0.3.0-0 |
✅ | ✅ | Recommended: all of 0.2.x, and 0.3.0-rc.1 is refused |
A wrong ceiling does not degrade gracefully: loadProfileDirectory() throws for an incompatible bundle, which lands in skippedBundles and prints skipping profile bundle "dsh-subagent-role-router" to stderr at startup — the plugin and its settings card both disappear.
plugin/test/peer-range.test.mjs is the regression guard for this contract: it calls the host's own semver.satisfies(..., { includePrerelease: true }) and asserts each row of the table above.
Configuration
Use the Web settings card (Settings → Plugins → Subagent default model (dsh-subagent-role-router)). It is built for a narrow pane: one card per concern, collapsed by default, and opening one expands only that item; the coordinator's three lists are a single entry with the three lists behind tabs. At sidebar width each row switches to two stacked lines so the badge stays right and the action buttons are never pushed out.
You can also edit the profile patch ~/.dsh/profiles/<profile>/cordis.patch.yml directly: since DSH 0.1.7 that is where settings live, keyed by this plugin's Loader entry id dsh-subagent-role-router:
- id: dsh-subagent-role-router
name: dsh-subagent-role-router
config:
# Single model
provider: deepseek-official
model: deepseek-v4-pro
# Or multiple models: Capability 1 (distribution) + Capability 2 (cross-provider failover)
provider: deepseek-official
models:
- model: deepseek-v4-pro
reasoningEffort: high
- provider: other-provider # a model from another vendor
model: gpt-5.6
reasoningEffort: max
strategy: round-robin # round-robin (sequential) | random
failoverEnabled: true # switch across providers on connection failures
injectRouteContext: true # write the live provider/model into each subagent’s context (default)
Role candidate pools (capability 4) — one array per role, and the array length is that role's concurrency:
roleMode: true
# Explore role: 2 lanes
exploreModels:
- provider: magpie
model: antigravity/gemini-3.8-flash
reasoningEffort: high
- provider: magpie
model: workbuddy/mimo-v2.6-pro
# Plan role: 1 lane
planModels:
- provider: magpie
model: workbuddy-ai/deepseek-v4.1-flash
reasoningEffort: max
# General/patch role: 3 lanes
patchModels:
- provider: magpie
model: antigravity/gemini-3.8-flash
reasoningEffort: high
- provider: magpie
model: workbuddy/mimo-v2.6-pro
- provider: magpie
model: sensenova/kimi-k3
roleSlotCooldownSeconds: 15 # seconds a failed candidate is skipped; 0 disables
An entry may be a provider/model string or the object form above; reasoningEffort is optional (omitted means the target model's own default effort). An empty or absent array falls back to the legacy single-value fields (exploreProvider/exploreModel/exploreEffort, …), so upgrading from an older version needs no config change.
Upgrading from 0.1.6 or earlier: the old configuration lived in the
subagent-default-modelsection of~/.dsh/settings.yaml. 0.1.7 imports that file once and renames it tosettings.yaml.imported, never reading it again. The import uses each section name verbatim as an entry id, while this plugin's entry id isdsh-subagent-role-router— so the old section is not imported (the host logssection subagent-default-model … was not imported into entry dsh-subagent-role-router) and the old values survive only in the renamed file. Move them into theconfig:block above by hand.
| Field | Type | Default | Description |
|---|---|---|---|
provider |
string | — | Provider for string-type model entries. |
model |
string | — | Single model id (backward compatible). |
models |
array | [] |
List of model entries (string or {provider, model, reasoningEffort?} pair). Only meaningful for Capabilities 1 and 2 with 2+ entries. |
strategy |
string | round-robin |
Capability 1's distribution strategy: round-robin (sequential) or random. |
failoverEnabled |
boolean | true |
Capability 2: switch models across providers inside the models list when a subagent hits a connection failure (subagents only). |
injectRouteContext |
boolean | true |
Capability 3 channel 2: inject a real one-line prompt stating the live provider/model into each subagent’s own context (subagents only). |
reasoningEffort |
string | — | Optional reasoning strength for a model entry (e.g. high, max). |
roleMode |
boolean | false |
Capability 4: route by delegation role (explore / plan / patch) instead of one shared models list. |
exploreModels / planModels / patchModels |
array | [] |
Capability 4 candidate queue per role. Length = how many subagents of that role may run at once; entries are strings or {provider, model, reasoningEffort?}. Empty falls back to the legacy exploreProvider/exploreModel/exploreEffort triple. |
roleSlotCooldownSeconds |
number | 15 |
Capability 4: how long a candidate that failed is skipped for new delegations. 0 disables the cooldown. |
The coordinator's four lists
One plugin (dsh-orchestrator by default) dispatches every unit of work as a child session. Its work splits into visual content (SVG, SVG animation, UI/UX edits, generated visual code), read-only audit & research (audit, inventory, health check, investigate, look things up, read source, compare, conclude — nothing is changed), delivery (build, package, sign, upload, release, deploy, install, run the tests, check the receipt, move batches — the goal is already decided and the work ends with something to hand over, no design decisions) and backend changes (work that needs a decision about what to change). Each gets its own list. A model may explicitly belong to both ordinary and coordinator lists.
An empty delivery list follows the backend list. Classification already works, but until the fourth list has models, delivery jobs keep running on the backend group — exactly what they ran on before the split, never the parent's expensive route.
- Ordered lists. Entry one is the default; a failure rests it for a graded wait (light 1/3/5, medium 1/5/15, heavy 2/10/30 minutes, or custom), the next entry serves meanwhile, and when the wait is over entry one is tried again. A rate limit starts one step in. "Never fall through" surfaces the first failure instead of switching.
- Explicit membership. Ordinary children use their general or role list; coordinator children use their group. Sharing a model never removes it from either list. Group-only routes remain group-only. The native gate receives the union of enabled lists.
- Classification: the coordinator names the group, the plugin only guesses when it does not. The coordinator is the party that knows what a unit of work is FOR, so it can say so outright — 「组:审计查阅」 in the title or the task description, 【组:后端】,
group: research, 「交给审计组」 — and that is the answer; tags and keywords stand down. Only when it says nothing: a 【UI】/【审计】【排查】【盘点】/【后端】 tag anywhere in the title or the description → an explicitly read-only task (「只读」) stays read-only even when the subject is visual, such as animation or an interface → a read-only act with no write act is audit & research → the change-versus-delivery boundary rules → a full-text score (a title hit counts double, a body hit counts once; visual words weigh 3, research and backend 2, delivery 1, and delivery words may only corroborate — never name a group by themselves; the winner needs at least 4 points and a 2-point lead, otherwise backend) → backend. Give the coordinator this convention:
Start by deciding which list the sub-task needs, then put the group name at the front of the task title (「组:审计查阅」 is accepted anywhere too).
【UI 绘制】 visual work: SVG, SVG animation, UI/UX edits, generated visual code, icons, colour, layout.
【审计查阅】 read-only: audit, inventory, health check, investigate, survey, comb through, verify, read source, compare, conclude. Dispatch it read-only.
【交付执行】 goal already decided, just run the steps: build, package, sign, upload, release, deploy, install, run the tests, check the receipt, move batches, clean up.
【后端处理】 work that changes code or config and needs a decision about what to change: endpoints, data, refactoring, bug fixes, performance, design trade-offs, investigating a failed delivery.
A job that both changes and ships stays backend — do not split one chain across two lists.
【审计】/【排查】/【盘点】 are equivalent to 【审计查阅】.
If you name no group, the plugin guesses from the title keywords; when it cannot tell, it uses backend.
Picker inside the child's list. On a coordinator child the model menu offers exactly its group, and
/selectjudges the pick against that same list — an out-of-list pick is substituted INSIDE the group (same provider first) instead of being pushed onto the general list, and a child sitting outside its list gets a one-click "switch back" line instead of a phantom extra row. A pick that fails does not stop the child either: from 5.8.0 it reverts to the group's first usable route and the header pill reports where it went.Move it from the menu. The model menu carries a row of chips at the top — 「这一页归到」 (this page belongs to): UI / Research / Delivery / Backend / no group — with the current group highlighted. A click is the same thing as calling the re-assignment endpoint by hand: the backend writes the decision, applies that group's first route immediately, and the menu refreshes onto the new list. "No group" hands the child back to ordinary handling. Success and failure are both reported in the menu, and the local view never runs ahead of the backend.
Judge: let a cheap model review the classification. Settings carry an "assistant model judgement" switch,
200k/jev-1.13-freeby default and any model you prefer. It reads only this child's own task request — title plus dispatch text, the dispatcher wrapper stripped, first 2000 characters — and never the main conversation; with the switch off it sends no model request at all and the rules decide alone. It reviews every dispatch that was not explicitly directed — tagged ones included, because a tag is a one-word label that can be wrong — and answers whether the group is right, which group it should be, and how confident it is.- It never blocks the spawn: the rule verdict is applied at birth, and the review runs asynchronously afterwards. A 3-second budget applies; a timeout, an error or an unparsable answer keeps the rule verdict and records a reason (
timeout,NO_LLM,invalid-json,RATE_LIMIT, …). - A correction is written only before the child has sent its first request: the route table is changed directly — no cancel, no re-send, no pop-up. A child that already started gets a recorded suggestion instead, so running work is never interrupted. The target is that group's first usable route.
- One text is judged once (fingerprint cache, 32 entries), so a re-dispatch costs nothing; the judge model, call count, corrections, cache hits and the last verdict are all exposed on the diagnostics endpoint.
- It never blocks the spawn: the rule verdict is applied at birth, and the review runs asynchronously afterwards. A 3-second budget applies; a timeout, an error or an unparsable answer keeps the rule verdict and records a reason (
Every decision leaves a trace: each record carries
source(rules or judge), confidence, judge model and elapsed time, the group before a correction, a suggested group and a failure reason. Older records stay readable, and the diagnostics endpoint reports the same state.Runtime pull-back. A coordinator child running off its list (host model seat, inherited route) is switched back to the group's first usable entry from its next step; a fallback already on the list is never bounced around.
The decisions are persisted. Every "this child belongs to that list" is written to the local state directory and kept for 24 hours, so a plugin reload no longer forgets it — without that, a reload turned a running coordinator child into an "ordinary" one and switched it onto the general list. A child born while the plugin was down can be re-assigned with
POST /subagent-role-router/group.The list is checked at birth: does this model still exist? A configured row can outlive the model: once a provider retires one, the row stays and the child dies the instant it is created — before any request, so neither failover nor the stall watchdog can see it. The plugin therefore asks the gateway's model catalog first and skips a candidate the provider provably no longer serves, using the next one, with a log line naming the row. Answers are cached for five minutes and warmed at load; anything unverifiable (no answer, unavailable, empty list) is used as configured — a catalog hiccup is never read as a broken config.
Exemptions. Coordinator children are claimed BEFORE the exemption rules, so a matching exemption still does not apply to them; the rules keep serving other plugins.
Platform support
Windows, macOS, and Linux are all supported, and no platform-specific configuration is needed. The plugin uses JavaScript and host services. Its optional local state and diagnostics derive paths from the profile environment, never a hard-coded user directory.
Platform-relevant surfaces that were checked and are now continuously verified:
- Config path: the profile patch lives at
.dsh/profiles/<profile>/cordis.patch.ymlunder the user's home directory. On Windows that is%USERPROFILE%\.dsh\profiles\<profile>\cordis.patch.yml(typicallyC:\Users\<you>\.dsh\...), the same convention as~/.dsh/...on macOS/Linux. - Dependency tree:
package-lock.jsonlocks all three Windows optional native builds (win32-x64-msvc,win32-arm64-msvc,win32-ia32-msvc), and npm installs only the one matching the current platform. This plugin's direct dependency@deepseek-ai/schemasteryis pure JS. - Line endings: the repo does not pin
core.autocrlf, so a Windows checkout may produce CRLF sources. The full suite was verified in that shape — assertions that parse source text match on substrings, never on line terminators, so CRLF vs LF does not change the result. - Path derivation: repository scripts use
fileURLToPath, neverURL.pathname. The latter yields/C:/...on Windows, whichpath.joinfolds into the non-existent\C:\...— a hard failure that only ever appears on Windows. - Test discovery:
npm testnames every test file explicitly — no directory, no glob. Both shortcuts break: thetest/directory form makes Node 20/22 try to load the directory as a module ("Cannot find module"), and a glob liketest/*.test.mjsis only expanded by Node 22's own test runner — Node 20 and cmd/PowerShell pass it through literally and the run dies with "Could not find". A guard test (test/test-registry.test.mjs) keeps the list honest in both directions: a file on disk that is not listed fails the run, and so does a listed file that no longer exists. Add new test files toscripts.test.
CI runs the same suite on ubuntu-latest, windows-latest, and macos-latest, so these guarantees are continuously verified rather than asserted once.
Subagent connection-failure failover
With failoverEnabled on (the default), when a subagent's own loop hits any failure except a cancellation, the plugin selects an untried model from the child's own role/group/general list and starts a new turn on that selection. See Capability 2 above for the full account; the key points:
- Cross-provider — candidates are the whole
modelslist, so it can fail over to a model from another provider, not just another m
…
Links
More in this category
Ebony-Vinyl/dsh-our-free-model★ 92328
Adds free model lanes to DeepSeek Harness — DeepSeek V4.1 Flash, Kimi K3 and others — with no login, sign-up or API key, plus a local OpenAI-compatible gateway, fallback routing and a usage dashboard.
dingminhua/dsh-connect-workbuddy★ 2184
Connects locally signed-in WorkBuddy models, CN and international alike, to DSH, reading each model's credit multiplier from the upstream catalog on every refresh, with per-model image input toggles, account switching backed by an auto-failing-over pool, manual daily check-in, and read-only credit overviews shown as compact pills on the card and in the composer.
Alice-Marx/dsh-model-router★ 1032
Routes DeepSeek Harness work across configured model APIs and supported vendor CLIs with dependency-aware packages and cost previews.
V1ki/dsh-plugin-subscriptions★ 653
Use ChatGPT (Codex), Claude, and Grok subscriptions as DeepSeek Harness LLM providers, with Settings login, model catalogs, usage, plus image_generate, video_generate, and x_search tools.
XDTrees/dsh-workbuddy-xdpool★ 650
Merge every locally signed-in WorkBuddy account into DeepSeek Harness as one auto-failing-over model pool (multi-account rotation, live credits, and a model catalog showing per-model credit multipliers and free/night-discount tags).
XDTrees/dsh-xdpool★ 650
Merge every locally signed-in WorkBuddy account into DeepSeek Harness as one auto-failing-over model pool: multi-account rotation, 429 cooldowns, live credits, a model catalog with per-model credit multipliers and free/night-discount tags, QR-code login for 13 vendors, and aggregate free-tier channels. Accounts persist across restarts.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.