rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:WaveBird/dsh-fallback-models
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
A DeepSeek Harness plugin that gives model requests a fallback chain: when the selected model fails before producing output, the same request is tried on the next configured provider/model route instead of surfacing the failure.
The plugin has two surfaces over one live configuration:
Fallback models switch row is added above the shipped model/effort card. Off shows the shipped model page; on covers it with the Session fallback editor. The model selector stays the single entry point.No build step. The Host half is plain ESM; the browser half is one hand-written client.js that imports only React and styles itself with host theme tokens.
src/, no bundler, no pnpm run build.Agent loop ──► llm/stream waterfall ──► primary adapter
│
├── terminal error before content? ──► prepare next route
│ (prepareCall + own adapter)
└── content already streamed? ──► pass the failure through
The failover engine is an llm/stream listener registered with prepend: true. It reads the live Config on every request, builds primary + fallbacks (deduplicated by provider/model), and tries at most maxFallbacks backup routes.
Two details make it safe:
block-start chunks are held. If the provider opens a block and then fails before any delta, the held chunks are dropped and the fallback starts a clean stream. Once a content or usage chunk is exposed, the failure is passed through instead of replaying a partial answer.prepareCall() resolves the route's model metadata and adapter defaults; the dispatch options are copied from the prepared config so callConfigEquals holds. A route that rejects the primary's reasoning level or output cap is retried once without those optional constraints.Why the LLM boundary instead of agent/request-error: the Agent loop fixes one ModelSelection per step (step() passes decision.selection to every retry), so changing agent.model.select() inside a request-error listener cannot change the model of the retry it asks for. llm/stream is the documented routing seam and runs after the loop has logged the request.
Captured from the DeepSeek Harness Web GUI; these show the v1.0.0 global settings page and the Session fallback page inside the model selection card.

Maintain the global default chain, its switch, the fallback budget, and skipped failure codes in Settings → Fallback models.

The model selector is the single entry point: the switch at the top of the card chooses between the shipped model page and the fallback page. When enabled, the first model in the list is the primary and later models take over a failed request in order; the circular-arrow button resets the Session to the global configuration.
Requirements: DeepSeek Harness 0.2.2-rc.1 or a compatible 0.2.x, Node.js >= 24.9, and the profile launcher (dsh web / the desktop app).
cd /path/to/dsh-fallback-models
npm install # resolves @deepseek-ai/schemastery into ./node_modules
Then, through the DSH plugin manager:
plugin_manager { "action": "install_bundle", "target": "/absolute/path/to/dsh-fallback-models" }
A linked install keeps the folder as the plugin body, so editing client.js or the Host files can be picked up by HMR / a page refresh. Uninstall before deleting or moving the folder.
The package is published on npm, so the DSH plugin CLI can install it directly:
dsh plugin --profile web add dsh-fallback-models
The CLI installs the package into that profile, adds it to dsh.profile.bundles, and activates the bundle layer (verified with a clean profile on 1.0.0). Restart dsh web / the desktop app if the running Host has not picked up the new profile composition. Remove it with dsh plugin --profile web remove dsh-fallback-models.
npm pack
# produces dsh-fallback-models-1.0.0.tgz
plugin_manager { "action": "install_bundle", "target": "/absolute/path/to/dsh-fallback-models-1.0.0.tgz" }
A tarball install extracts a copy into the profile; the source folder can then be moved or deleted. Upgrade with a new version and another install_bundle.
cordis_inspect_query → host / Config / listConfigs, { "name": "dsh-fallback-models" }.cordis_inspect_query → client / Slots / listSubTree, roots settings.section and conversation.input.model.label; both should list an active fallback-models occupant.Fallback models switch row sits above the model list, with a reset button when the session carries its own configuration.The Host row is the settings namespace and stores both layers:
- id: fallback-models
name: dsh-fallback-models
config:
enabled: true
fallbacks:
- provider: deepseek-official
model: deepseek-v4.1-flash
- provider: workbuddy-mannager-cn
model: auto
maxFallbacks: 3
skipCodes: [IMAGE_OFFLOAD_REQUIRED]
sessions:
session-abc:
enabled: true
fallbacks:
- provider: workbuddy-mannager-cn
model: glm-5.3-flash
| Field | Meaning |
|---|---|
enabled |
Global switch. A Session override carries its own switch. |
fallbacks |
Ordered global model list: { provider, model, reasoningEffort? }. The first entry is the primary when fallback is enabled; the rest are fallbacks. |
maxFallbacks |
Maximum backup routes attempted for one request (1–10). |
skipCodes |
Failure codes that never fail over. Empty means every error fails over. Default: IMAGE_OFFLOAD_REQUIRED, so the image-offload recovery keeps ownership. |
sessions |
Per-Session overrides keyed by Session id. An absent key follows the global chain. |
When a Session has fallback enabled and a non-empty list, the plugin treats the first entry as the active model:
session.selectModel Remote. The outer model name follows, and the Agent loop's next request uses that route as its normal primary request. An existing session whose selection predates the chain therefore self-heals on the next page load.base in the Session override). Reset to global removes the override; a globally enabled chain then selects the global first entry, while a disabled global chain restores base.If the route cannot be selected (unavailable model, writer conflict), the selection is left unchanged; the chain stays configured and the first entry remains a fallback after the currently selected model. The fallback editor still shows the configured order.
sessions.<id> means follow global, live: the effective chain is the global one, resolved at request time.maxFallbacks and skipCodes remain global policy.Per-Session overrides live in the profile patch, so they are shared by every browser on the same Host and survive restarts. They are not written into the Session log; deleting the profile or clearing sessions removes them.
aborted finish and an aborted request signal end the chain immediately.assistant/message.source as the route it assembled. With fallback on, the plugin selects the chain's first entry as the session model, so the logged source normally matches the active primary. A later fallback is recorded in the adapter's replayState.response (for adapters that report provider/model there) and in the Host warning log; the transcript's model label is not rewritten per attempt. If the alignment Remote fails, the old selection remains the logged primary while the configured first entry is a fallback.llm/stream, the primary's llm-retry policy does not see a failure that a fallback absorbed. If every fallback fails, the last failure reaches agent/request-error and the retry policy applies to the primary route.sessionId are untouched. The engine only reads a chain for a Session-bound request; auxiliary one-shot callers that pass no Session id keep their existing behavior.sessions map.docs/design.md as future work.npm install
npm test
The suite uses Node's built-in test runner:
test/fallback-stream.test.js — config normalization, route deduplication, hold/commit behavior, fallback selection, budget, skip codes, aborted streams, unavailable routes, and optional-constraint retry.test/client-smoke.test.js — loads client.js through a fake window.__ModuleLoader__ and asserts the registrations, the locale dictionaries, and the injected form/catalog faces.Layout:
| Path | Role |
|---|---|
index.js |
Host entry: name, inject, Config, apply (installs the listener and suppresses the generic form). |
lib/config.js |
Schemastery Config, normalization, global/Session resolution. |
lib/fallback-stream.js |
The llm/stream engine, prepared dispatch, streaming hold. |
client.js |
Settings page, navigation icon, model label, model-menu switch card, styles. |
cordis.patch.yml |
The single Host row inserted into the profile composition. |
locale/*.json |
Plugin-manager title and description. |
docs/design.md |
Design decisions, API references, and deferred work. |
MIT. See LICENSE.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。