Preface¶
DeepSeek Harness (DSH) uses a plugin-based architecture and allows middleware logic to be injected before model inference. The HTTP gateway of Charm Hyper (with a Google Frontend backend) enforces a strict 10 MiB limit on request bodies. When accumulated images in a conversation history exceed this limit, the gateway rejects the request and returns a 400 invalid request body error, causing inference tasks to fail before execution. The dsh-hyper-tools plugin is designed specifically for this scenario.
Plugin Overview¶
The plugin is maintained by samuelrubiodev and is open-sourced under the MIT license. It intercepts requests on specific routes and dynamically adjusts the image payload before sending it to the gateway, ensuring that the request body size does not exceed the limit.
How It Works¶
The plugin registers an llm/stream middleware to implement its functionality. The process mainly includes two steps:
-
Preprocessing and Replacement
Before the request is dispatched, the plugin projects the persisted history based on themaxRequestImageBytesbudget. If the image payload exceeds the budget, the oldest images are replaced with the standard DSH placeholder text ([image omitted to fit request image limits; …]), while the most recent images are retained. If the request body is already within the allowed limit, it is passed directly tonext()for dispatch without any additional processing. -
Failure Retry
If the gateway still rejects the request (usually because the budget estimate underestimated non-image metadata overhead), the plugin captures this error and retries once. During the retry, the image budget is multiplied byrecoveryBudgetFactor(default0.5), causing older images to be replaced further. If there is no replaceable content left, the original error is returned as-is.
Installation¶
Install the plugin using the following command:
dsh plugin --profile <profile> add dsh-hyper-tools
Configuration¶
The plugin supports flexible configuration, and all fields are optional. The following are the core configuration options:
| Configuration | Default | Description |
|---|---|---|
providers |
['charm-hyper', 'hyper'] |
List of affected Provider routes (case-insensitive). |
maxRequestImageBytes |
6291456 (6 MiB) |
Maximum allowed image payload per request (Base64 byte count). |
recovery |
true |
Whether to trigger one retry when the gateway rejects the request. |
recoveryBudgetFactor |
0.5 |
Image budget multiplier used during retry. |
byteQuantum |
1 |
Removal step size when bytes overflow. |
countQuantum |
1 |
Removal step size when count overflow occurs. |
Configuration Example:
- id: hyper-tools
name: 'dsh-hyper-tools'
config:
providers: ['charm-hyper']
maxRequestImageBytes: 6291456
Notes¶
- Budget Calculation Scope:
maxRequestImageBytesonly calculates the Base64 payload of images. Text content, tool schema definitions, and JSON structures are not included in this limit. - Only Specified Routes Are Processed: The plugin only applies to routes listed in
providers. Requests from other Providers are not affected. - Compatibility: Requires
@deepseek-ai/dsh-llm ^0.1.5-rc.1.
Summary¶
dsh-hyper-tools resolves the hard request-body size limit imposed by the Charm Hyper gateway through intelligent replacement of older images and a failure-retry mechanism. For long-conversation scenarios that need to process large numbers of images, it provides a reliable middleware solution.