Preface¶
When connecting agents to third-party models or OpenAI-compatible gateways in DeepSeek Harness (DSH), two types of interruptions commonly occur: the model service returns 400/422 for optional parameters, causing the entire conversation turn to fail; or the usage frames at the end of the stream are zeroed out, duplicated, or missing fields, causing dashboard numbers to mismatch bills. Switching providers often means dealing with a different set of parameter names or restrictions, making manual configuration changes and session restarts costly.
Here we introduce the community plugin dsh-llm-fidelity (Maintainer: philipho01, Category: Model Inference). Without registering model routes or replacing official services, it monitors the llm/stream path: it performs in-request corrections and resends for responses that “explicitly reject optional parameters”; it prevents zeroing and duplication for usage statistics and merges fields, without fabricating numbers that were not reported.
What is this¶
dsh-llm-fidelity is a plugin for DeepSeek Harness. The current npm version is 0.1.3, and the license is MIT. Its positioning can be summarized as: high-fidelity model invocation—automatically adapting rejected optional parameters and maintaining consistency between token usage accounting and provider reporting.
It works out of the box after installation; it does not compete for routes with other adapters. The official dsh-llm-retry still handles scenarios like 429s and server errors, and this plugin yields in these cases.
Core Features¶
Conversations do not break due to 400/422 on optional parameters¶
Typical errors include unsupported stop, max_tokens, temperature, reasoning effort, etc. Without the plugin, an agent might receive the following mid-way through a multi-step tool call:
400 — 'stop' is not supported with this model.
With the plugin, within the same HTTP request: it reads the rejected field from the provider’s error text, removes it or clamps it according to the error hint (e.g., output limit), and immediately resends; the user typically only sees the answer continue rather than an error page.
The current correction list is intentionally kept short, involving only optional scalars: temperature, reasoningEffort, stop, maxTokens (omitted if unsupported, or lowered according to a clear limit in the error). Message bodies, system prompts, tools, and constraints are not modified. Context overflow, quota, authentication, and network errors are passed through as-is, without “guessing parameters” retries.
There is a maximum of 4 auto-adaptations per request (maxAdaptations default 4), and each adaptation must actually change the request to avoid infinite loops. Learned strategies are cached in-process by provider + model for approximately 1 hour (strategyTtlMs default 3600000 ms); the same routing typically experiences the same rejection only once.
The default recognized HTTP statuses are 400 and 422 (rectifyStatuses).
Usage Statistics: Anti-zeroing, Anti-duplication, No Fabrication¶
Gateways may send all-zero usage, duplicate snapshots, or lack cache-related fields at the end of the stream, causing statistics to be overwritten or double-counted. The plugin guards the usage stream by frame: later frames cannot erase fields already present in earlier frames, all-zero placeholders cannot overwrite real totals, and duplicate frames are not double-counted. If the provider never reports a specific number, the plugin will not fabricate it.
This behavior is controlled by the option usageFidelity (default true).
Relationship with the Ecosystem¶
The plugin does not register any model routes and does not replace existing services; it runs parallel to official and community adapters, as well as dsh-llm-retry. The DSH community plugin directory is at SkillHub. It has no official affiliation with DeepSeek / High-Flyer and is an independent entry in the “Everything is a Plugin” ecosystem.
Installation and Activation¶
Compatibility (from README): DSH 0.1.0-rc.6 and later versions, covering the 0.2.0-rc line; tested on DeepSeek Desktop 0.2.0-rc.2. If installation reports incompatibility, please verify your DSH version first. The runtime environment requires Node >= 22.
Official installation command:
dsh plugin add dsh-llm-fidelity
Or use npm-based workflows:
pnpm add dsh-llm-fidelity
After installation, enable it in the DSH plugin settings. The defaults are production-ready; the following switches are optional:
| Option | Default | Meaning |
|---|---|---|
usageFidelity |
true |
Usage guard (deduplication, anti-zeroing, field merging) |
rectify |
true |
Auto-adapt parameter rejections |
rectifyStatuses |
[400, 422] |
Status codes treated as “explicit parameter rejection” |
maxAdaptations |
4 |
Max auto-resend count per request |
strategyTtlMs |
3600000 |
Retention time for learned provider preferences (milliseconds) |
strategyCacheSize |
256 |
Max limit for learned entries retained in memory |
rectifyAuxiliary |
false |
Whether to adapt background tasks (e.g., auto titles) as well |
Modifying Configuration¶
The plugin is installed as a profile bundle layer; configuration is written in the profile’s patch file. Example path for Desktop:
~/.dsh/profiles/desktop/cordis.patch.yml
Override the configuration by id llm-fidelity. Note: The config section is entirely replaced rather than merged; omitted keys will revert to built-in defaults. When changing configuration, you must write out all items you wish to retain:
- id: llm-fidelity
config:
maxAdaptations: 2
rectifyAuxiliary: true
Typical Behavior (Can be compared with README scenarios)¶
Sending a request with temperature when the model does not support it:
You send: { temperature: 0.7, stop: ["END"], ... }
Model: 400 — 'temperature' is not supported with this model.
Plugin: (removes temperature, re-sends immediately)
Model: 200 — here is your answer.
You see: the answer. Nothing else. Ever.
This is consistent with the before/after comparison in the README regarding “fixing a bug, suddenly getting a 400 at step three”: with the plugin, errors are absorbed and resent within milliseconds, and subsequent requests on the same route can reuse the learned parameter combinations.
Use Cases and Notes¶
Who it is for: Developers connecting multiple providers, OpenAI-compatible gateways, or reasoning models (which often reject max_tokens / stop / temperature, etc.) via DSH; teams that need usage to be consistent with billing and dashboards, and do not want to manually maintain parameter whitelists for every gateway.
Please be aware before use:
- The plugin runs under the permissions of the current dsh process. Before installation, it is recommended to review the GitHub source code and the MIT license to ensure compliance with your security and compliance requirements.
- It only handles optional parameter rejections explicitly stated by the provider in error messages; it cannot replace correct authentication, quota management, or model selection.
- Background tasks do not participate in parameter adaptation by default (
rectifyAuxiliary: false); if you want auxiliary calls like auto-titles to self-heal, you must explicitly enable it and understand the impact on latency and request counts. - The learning cache is in-process and time-sensitive; after a process restart or TTL expiration, the same rejection may occur once more, but it will still be handled automatically within the same request.
Conclusion¶
dsh-llm-fidelity consolidates two common issues—“optional parameter 400/422” and “unreliable usage frames”—on the llm/stream side: conversations are kept uninterrupted as much as possible, and numbers are reported truthfully. It is ready to use with zero configuration, and you can tighten retry limits or extend auxiliary adaptation in cordis.patch.yml as needed.
- Community Directory: https://www.skillhub.cn/plugins/philipho01/dsh-llm-fidelity
- Source Code & Documentation: https://github.com/philipho01/dsh-llm-fidelity