Introduction¶
The core philosophy of DeepSeek Harness (DSH) is “everything is a plugin”. In multi-model development environments, manually selecting the appropriate model for every conversation (for example, using DeepSeek for coding and GLM for general Q&A) is inefficient. The dsh-smart-scenario-router plugin solves this problem by analyzing the content of user messages, automatically routing requests to the most suitable model, and automatically trying the next model when a request fails, thereby reducing operational overhead.
What Is It¶
This is a model inference plugin maintained by xobexo that provides conversation-scenario-based model routing capabilities for DeepSeek Harness. It does not store API keys; provider authentication information is still managed by DSH itself.
Core Features¶
- Scenario recognition: Automatically recognizes scenarios based on message content, including project decomposition, plugin discovery, code review, code change comparison, coding and debugging, complex reasoning, everyday conversation, extreme high concurrency, multimodal processing, and long-text analysis.
- Model priority: By default, it prefers domestic models (DeepSeek, GLM, Qwen), with configured GPT models as the fallback.
- Automatic fallback: When a request fails, it automatically tries the next model in the candidate chain for the current scenario.
- Visual configuration: Displays the model pool, scenario mappings, and current routing state on the DSH Web settings page, and supports persisting configuration.
Installation and Activation¶
Before installing, ensure the following environment requirements are met:
- DeepSeek Harness version >= 0.1.1-rc.1
- Node.js and pnpm are installed
- At least one available model Provider is configured in DSH
Run the following command to install:
npx -y @deepseek-ai/dsh plugin --profile web add github:xobexo/dsh-smart-scenario-router
After installation, restart the Web profile to activate the plugin:
npx -y @deepseek-ai/dsh web
Configuration¶
After installation, open the settings page of the DSH Web interface and find the “Smart Scenario Routing” module. You can perform the following operations here:
- Manage the model pool: Enable or disable models in the model pool. All models are selected from DSH’s Settings → Models dropdown; manual name input is not required.
- Edit candidate chains: Configure the candidate model order for each scenario. The order is the fallback order, and the plugin tries them in sequence until one succeeds.
- View status: View the current routing status and model mapping relationships.
On first use, the plugin automatically writes default rules. If a default model does not exist in DSH’s Settings → Models, the plugin attempts to replace it with an actually configured model from the same family (deepseek / glm / qwen / gpt). If a model is not registered or its Provider is unavailable, routing automatically skips that model and tries the next one.
How It Works¶
The plugin workflow is as follows:
- Reads the user message in the current session.
- If the message contains an image or explicitly involves image content, it routes to the
multimodalscenario. - If the text is long, it routes to the
long_contextscenario. - Matches high-priority intents: requests involving tool recommendations go to
plugin_discovery, Git diffs go tocode_diff, code quality analysis goes tocode_review, architecture planning goes toproject_planning, and development implementation requests go tocoding. - Remaining messages are matched to scenarios using a bilingual keyword table. If the confidence is below the threshold, a referee model (default Flash) is invoked to make another judgment.
- Checks whether candidate models are available and selects the first available model to send the request.
- If the request fails, it continues to try the next model in the candidate chain.
- If the user has manually selected a non-default model, the plugin preserves that selection and does not force override it.
Upgrading and Troubleshooting¶
Upgrade notice: Starting from 0.3.0, the rule table version (schemaVersion) was introduced. After upgrading from an older version, persisted default rules are automatically replaced with the new default mappings; manually customized candidate chains and model pools are preserved.
502 upstream error troubleshooting: If a model can be called when selected directly, but 502 upstream service unavailable appears after enabling the plugin, open the Smart Scenario Routing settings and ensure that the model’s Provider in DSH’s Settings → Models exactly matches the actually available Provider. The plugin validates the provider/model combination before injecting the request. Restart the Web profile after modifying the configuration.
Summary¶
This plugin helps developers reduce manual model switching by automating scenario recognition and model fallback. It has simple configuration and is fully compatible with DSH’s existing authentication system. For more details, refer to the GitHub repository.