The built-in web search of DSH incurs charges based on official token quotas. Even if a self-configured gateway is already in place, these calls still go through the official channels, causing costs to accumulate imperceptibly. This plugin resolves this issue by routing web searches through the model selected in the current session (these calls are also recorded in the dsh-cost-meter ledger and attributed to the current session) and integrating with a self-hosted search backend to retrieve real web sources.
Installation¶
Install using the official command:
dsh plugin add dsh-web-search-session
Restart DSH after installation. The plugin switches the searchProvider of the web line to session via a bundle patch.
If you need to install from source, execute install_bundle on the plugin directory within a session that has the plugin_manager tool, filling in the absolute directory path for target. The installation writes to the current profile and applies the patch, requiring no manual editing of configuration files.
Features¶
- Session Routing: Uses the provider/model of the current session to rewrite search queries, rather than using a fixed model.
- Self-hosted Search: Supports SearXNG (no key required, recommended), Tavily, and Brave; both endpoints and keys are configurable.
- Controlled Fallback: When there is no routing or search failure, selects fallback to official provider, searches with the raw question, or throws an error directly based on
noRoute. - Credential Isolation: Keys are only referenced via credential services or environment variables; they are never written to plugin or setting files.
- Visual Configuration: Directly configure addresses, keys, and call counts on the “Plugins” page.
Configuration¶
Configuration items are written in the cordis.patch.yml of the profile; items marked with “GUI” can also be modified directly on the plugin page.
| Field | Type | Default | Description |
|---|---|---|---|
backend |
string | none |
Search backend: none / searxng / tavily / brave |
endpoint |
string | '' |
Backend base URL; uses the backend’s default endpoint if empty |
apiKeyEnv |
string | '' |
Key reference name; uses the backend’s default name if empty |
sessionPlanning |
boolean | true |
Whether to use the session model to rewrite search queries |
noRoute |
string | official |
On no routing or search failure: official / raw / error |
providerId |
string | session |
Provider ID registered by this plugin; must match web.searchProvider |
officialProviderId |
string | deepseek-official |
Official provider ID to delegate to when falling back |
maxQueries |
number | 3 |
Maximum number of backend calls per request, range 1–20 |
maxResults |
number | 8 |
Maximum number of returned sources, max 20 |
planMaxTokens |
number | 512 |
Output token limit for search query rewriting |
planTimeoutMs |
number | 20000 |
Timeout for search query rewriting (ms) |
searchTimeoutMs |
number | 20000 |
Timeout for a single backend search (ms) |
debug |
boolean | false |
Output debug logs for search queries and source counts |
Backends and Keys¶
| Backend | Default Endpoint | Key Variable |
|---|---|---|
searxng |
http://127.0.0.1:8888 |
Not required |
tavily |
https://api.tavily.com |
TAVILY_API_KEY |
brave |
https://api.search.brave.com |
BRAVE_API_KEY |
Credential Resolution Priority¶
Keys are not written to plugin or setting files and are resolved by the following priority:
- Credential service: the reference name takes
apiKeyEnv, or the backend’s default name if empty; - Environment variable with the same name.
Missing credentials are considered a deterministic configuration error and will not silently fall back to the official provider.
How It Works¶
- Read the provider/model routing of the current session.
- Use that model to rewrite the user’s question into several search queries, constrained by
sessionPlanningandmaxQueries. - Call the selected backend concurrently, deduplicate by URL, and return no more than
maxResultssources. - Handle failures in any step according to
noRoute.
Compatibility Requirements¶
- Node.js >= 20
- DSH >= 0.1.7-rc.2 (This version includes
@deepseek-ai/schemastery>= 3.18.3 built-in, and the instant effect of setting items relies on its.volatile())
Quick Start Example¶
- Prepare a SearXNG instance and ensure
http://<host>:8888/search?q=test&format=jsonreturns JSON. - Open “Plugins → Installed → dsh-web-search-session” and point the platform address to this instance.
- Initiate a normal web search.